@@ -81,6 +81,15 @@ void cb_control_error(const std_msgs::Float64MultiArray::ConstPtr& msg)
81
81
Eigen_error (i) = msg->data [i];
82
82
}
83
83
84
+ double dx_ = 0 ;
85
+ double dy_ = 0 ;
86
+ double dz_ = 0 ;
87
+ double gap_x = 0 ;
88
+ double gap_y = 0 ;
89
+ double gap_z = 0 ;
90
+ double gap_up = 0 ;
91
+ double duration_grasping = 3.0 ;// duration of grasping
92
+ double duration_ = 10.0 ;// duration of hand closure
84
93
85
94
int main (int argc, char ** argv)
86
95
{
@@ -92,8 +101,17 @@ int main(int argc, char** argv)
92
101
string relative_path_file_in, on_topic, synergy_joint;
93
102
string file_name_in;
94
103
nn.param <std::string>(" filename_in" , relative_path_file_in, " /bottiglia/test_itself/model_40_8/box_estimate" );
95
- nn.param <std::string>(" on_topic" , on_topic, " /right_hand/joint_trajectory_controller/command" );
96
- nn.param <std::string>(" synergy_joint" , synergy_joint, " right_hand_synergy_joint" );
104
+ nn.param <std::string>(" on_topic" , on_topic, " /right_hand/joint_trajectory_controller/command" );
105
+ nn.param <std::string>(" synergy_joint" , synergy_joint, " right_hand_synergy_joint" );
106
+ nn.param <double >(" dx_box" ,dx_,0 );
107
+ nn.param <double >(" dy_box" ,dy_,0 );
108
+ nn.param <double >(" dz_box" ,dz_,0 );
109
+ nn.param <double >(" gap_x" ,gap_x,0 );
110
+ nn.param <double >(" gap_y" ,gap_y,0 );
111
+ nn.param <double >(" gap_z" ,gap_z,0 );
112
+ nn.param <double >(" gap_up" ,gap_up,0 );
113
+ nn.param <double >(" duration" ,duration_,3.0 );// Duration of hand closure
114
+ nn.param <double >(" duration_grasping" ,duration_grasping,3.0 );
97
115
98
116
ros::Subscriber sub_error = nn.subscribe (" /right_arm/teleoperation_controller/error" , 1 , cb_control_error);
99
117
ros::Publisher hand_publisher = nn.advertise <trajectory_msgs::JointTrajectory>(on_topic.c_str (), 1000 );
@@ -136,9 +154,9 @@ int main(int argc, char** argv)
136
154
137
155
138
156
139
- double dx = - 1 ;
140
- double dy = 0.0 ;
141
- double dz = values_inline[3 ]/2 ;// -0.02 + 0.05;
157
+ double dx = dx_ ;
158
+ double dy = dy_ ;
159
+ double dz = values_inline[3 ]/2 + dz_ ;// -0.02 + 0.05;
142
160
Eigen::MatrixXd transf_World2Box = MatrixXd::Identity (4 ,4 );
143
161
144
162
transf_World2Box (3 ,0 ) = dx;
@@ -219,7 +237,10 @@ int main(int argc, char** argv)
219
237
grasping_pub.publish (hand_pose);
220
238
ros::spinOnce ();
221
239
loop_rate.sleep ();
222
- hand_pose.position .z = hand_pose.position .z + 0.3 ;
240
+
241
+ hand_pose.position .x = hand_pose.position .x + gap_x;
242
+ hand_pose.position .y = hand_pose.position .y + gap_y;
243
+ hand_pose.position .z = hand_pose.position .z + .3 + gap_z;
223
244
while (nn.ok () && error > e_treshold)
224
245
{
225
246
grasping_pub.publish (hand_pose);
@@ -241,9 +262,9 @@ int main(int argc, char** argv)
241
262
Eigen_error (0 ) = 1000 ;
242
263
e_treshold = 0.0001 ;
243
264
244
- hand_pose.position .x = hand_pose.position .x - 0.0005 ;
245
- hand_pose.position .y = hand_pose.position .y - 0.0005 ;
246
- hand_pose.position .z = hand_pose.position .z - .3 - 0.02 ;
265
+ hand_pose.position .x = hand_pose.position .x + gap_x ;
266
+ hand_pose.position .y = hand_pose.position .y + gap_y ;
267
+ hand_pose.position .z = hand_pose.position .z - .3 + gap_z ;
247
268
while (nn.ok () && error > e_treshold)
248
269
{
249
270
grasping_pub.publish (hand_pose);
@@ -272,14 +293,14 @@ int main(int argc, char** argv)
272
293
msg_jointT_hand.points [0 ].accelerations [0 ] = 0.0 ;
273
294
msg_jointT_hand.points [0 ].effort .resize (1 );
274
295
msg_jointT_hand.points [0 ].effort [0 ] = 0.0 ;
275
- msg_jointT_hand.points [0 ].time_from_start = ros::Duration (10.0 ); // 10s;
296
+ msg_jointT_hand.points [0 ].time_from_start = ros::Duration (duration_ ); // 10s; Duration of hand closure
276
297
msg_jointT_hand.joint_names [0 ] = synergy_joint.c_str ();
277
298
hand_publisher.publish (msg_jointT_hand);
278
299
ros::spinOnce ();
279
300
sleep (30.0 );
280
301
hand_pose.position .x = World2Hand (3 ,0 );
281
302
hand_pose.position .y = World2Hand (3 ,1 );
282
- hand_pose.position .z = World2Hand (3 ,2 ) + 0.2 ;
303
+ hand_pose.position .z = World2Hand (3 ,2 ) + gap_up ;
283
304
hand_pose.orientation .x = q3.x ();
284
305
hand_pose.orientation .y = q3.y ();
285
306
hand_pose.orientation .z = q3.z ();
@@ -300,7 +321,7 @@ int main(int argc, char** argv)
300
321
msg_joint_T_hand.points [0 ].accelerations [0 ] = 0.0 ;
301
322
msg_joint_T_hand.points [0 ].effort .resize (1 );
302
323
msg_joint_T_hand.points [0 ].effort [0 ] = 0.0 ;
303
- msg_joint_T_hand.points [0 ].time_from_start = ros::Duration (3.0 ); // 1s;
324
+ msg_joint_T_hand.points [0 ].time_from_start = ros::Duration (duration_grasping ); // 1s;
304
325
msg_joint_T_hand.joint_names [0 ] = synergy_joint.c_str ();
305
326
hand_publisher.publish (msg_joint_T_hand);
306
327
ros::spin ();
0 commit comments