23 priv_node_handle_(
"~")
43 ROS_INFO(
"Start OpenManipulator-P Teleop Keyboard");
49 ROS_INFO(
"Terminate OpenManipulator-P Teleop Keyboard");
69 std::vector<double> temp_angle;
71 for (std::vector<int>::size_type i = 0; i < msg->name.size(); i++)
73 if (!msg->name.at(i).compare(
"joint1")) temp_angle.at(0) = (msg->position.at(i));
74 else if (!msg->name.at(i).compare(
"joint2")) temp_angle.at(1) = (msg->position.at(i));
75 else if (!msg->name.at(i).compare(
"joint3")) temp_angle.at(2) = (msg->position.at(i));
76 else if (!msg->name.at(i).compare(
"joint4")) temp_angle.at(3) = (msg->position.at(i));
77 else if (!msg->name.at(i).compare(
"joint5")) temp_angle.at(4) = (msg->position.at(i));
78 else if (!msg->name.at(i).compare(
"joint6")) temp_angle.at(5) = (msg->position.at(i));
85 std::vector<double> temp_position;
86 temp_position.push_back(msg->pose.position.x);
87 temp_position.push_back(msg->pose.position.y);
88 temp_position.push_back(msg->pose.position.z);
104 open_manipulator_msgs::SetJointPosition srv;
105 srv.request.joint_position.joint_name = joint_name;
106 srv.request.joint_position.position = joint_angle;
107 srv.request.path_time = path_time;
111 return srv.response.is_planned;
118 open_manipulator_msgs::SetJointPosition srv;
119 srv.request.joint_position.joint_name = joint_name;
120 srv.request.joint_position.position = joint_angle;
121 srv.request.path_time = path_time;
125 return srv.response.is_planned;
132 open_manipulator_msgs::SetJointPosition srv;
133 srv.request.joint_position.joint_name.push_back(
priv_node_handle_.
param<std::string>(
"end_effector_name",
"gripper"));
134 srv.request.joint_position.position = joint_angle;
138 return srv.response.is_planned;
145 open_manipulator_msgs::SetKinematicsPose srv;
147 srv.request.kinematics_pose.pose.position.x = kinematics_pose.at(0);
148 srv.request.kinematics_pose.pose.position.y = kinematics_pose.at(1);
149 srv.request.kinematics_pose.pose.position.z = kinematics_pose.at(2);
150 srv.request.path_time = path_time;
154 return srv.response.is_planned;
162 printf(
"---------------------------------\n");
163 printf(
"Control Your OpenMANIPULATOR-P!\n");
164 printf(
"---------------------------------\n");
165 printf(
"w : increase x axis in task space\n");
166 printf(
"s : decrease x axis in task space\n");
167 printf(
"a : increase y axis in task space\n");
168 printf(
"d : decrease y axis in task space\n");
169 printf(
"z : increase z axis in task space\n");
170 printf(
"x : decrease z axis in task space\n");
172 printf(
"r : increase joint 1 angle\n");
173 printf(
"f : decrease joint 1 angle\n");
174 printf(
"t : increase joint 2 angle\n");
175 printf(
"g : decrease joint 2 angle\n");
176 printf(
"y : increase joint 3 angle\n");
177 printf(
"h : decrease joint 3 angle\n");
178 printf(
"u : increase joint 4 angle\n");
179 printf(
"j : decrease joint 4 angle\n");
180 printf(
"i : increase joint 5 angle\n");
181 printf(
"k : decrease joint 5 angle\n");
182 printf(
"o : increase joint 6 angle\n");
183 printf(
"l : decrease joint 6 angle\n");
188 printf(
"v : gripper open\n");
189 printf(
"b : gripper close\n");
191 printf(
"1 : init pose\n");
192 printf(
"2 : home pose\n");
194 printf(
"q to quit\n");
195 printf(
"-------------------------------------------------------------------------------\n");
196 printf(
"Present Joint Angle J1: %.3lf J2: %.3lf J3: %.3lf J4: %.3lf J5: %.3lf J6: %.3lf\n",
203 printf(
"Present Kinematics Position X: %.3lf Y: %.3lf Z: %.3lf\n",
207 printf(
"-------------------------------------------------------------------------------\n");
212 std::vector<double> goalPose; goalPose.resize(3, 0.0);
213 std::vector<double> goalJoint; goalJoint.resize(6, 0.0);
215 if (ch ==
'w' || ch ==
'W')
217 printf(
"input : w \tincrease(++) x axis in task space\n");
218 goalPose.at(0) =
DELTA;
221 else if (ch ==
's' || ch ==
'S')
223 printf(
"input : s \tdecrease(--) x axis in task space\n");
224 goalPose.at(0) = -
DELTA;
227 else if (ch ==
'a' || ch ==
'A')
229 printf(
"input : a \tincrease(++) y axis in task space\n");
230 goalPose.at(1) =
DELTA;
233 else if (ch ==
'd' || ch ==
'D')
235 printf(
"input : d \tdecrease(--) y axis in task space\n");
236 goalPose.at(1) = -
DELTA;
239 else if (ch ==
'z' || ch ==
'Z')
241 printf(
"input : z \tincrease(++) z axis in task space\n");
242 goalPose.at(2) =
DELTA;
245 else if (ch ==
'x' || ch ==
'X')
247 printf(
"input : x \tdecrease(--) z axis in task space\n");
248 goalPose.at(2) = -
DELTA;
251 else if (ch ==
'r' || ch ==
'R')
253 printf(
"input : r \tincrease(++) joint 1 angle\n");
254 std::vector<std::string> joint_name;
255 joint_name.push_back(
"joint1"); goalJoint.at(0) =
JOINT_DELTA;
256 joint_name.push_back(
"joint2");
257 joint_name.push_back(
"joint3");
258 joint_name.push_back(
"joint4");
259 joint_name.push_back(
"joint5");
260 joint_name.push_back(
"joint6");
263 else if (ch ==
'f' || ch ==
'F')
265 printf(
"input : f \tdecrease(--) joint 1 angle\n");
266 std::vector<std::string> joint_name;
267 joint_name.push_back(
"joint1"); goalJoint.at(0) = -
JOINT_DELTA;
268 joint_name.push_back(
"joint2");
269 joint_name.push_back(
"joint3");
270 joint_name.push_back(
"joint4");
271 joint_name.push_back(
"joint5");
272 joint_name.push_back(
"joint6");
275 else if (ch ==
't' || ch ==
'T')
277 printf(
"input : t \tincrease(++) joint 2 angle\n");
278 std::vector<std::string> joint_name;
279 joint_name.push_back(
"joint1");
280 joint_name.push_back(
"joint2"); goalJoint.at(1) =
JOINT_DELTA;
281 joint_name.push_back(
"joint3");
282 joint_name.push_back(
"joint4");
283 joint_name.push_back(
"joint5");
284 joint_name.push_back(
"joint6");
287 else if (ch ==
'g' || ch ==
'G')
289 printf(
"input : g \tdecrease(--) joint 2 angle\n");
290 std::vector<std::string> joint_name;
291 joint_name.push_back(
"joint1");
292 joint_name.push_back(
"joint2"); goalJoint.at(1) = -
JOINT_DELTA;
293 joint_name.push_back(
"joint3");
294 joint_name.push_back(
"joint4");
295 joint_name.push_back(
"joint5");
296 joint_name.push_back(
"joint6");
299 else if (ch ==
'y' || ch ==
'Y')
301 printf(
"input : y \tincrease(++) joint 3 angle\n");
302 std::vector<std::string> joint_name;
303 joint_name.push_back(
"joint1");
304 joint_name.push_back(
"joint2");
305 joint_name.push_back(
"joint3"); goalJoint.at(2) =
JOINT_DELTA;
306 joint_name.push_back(
"joint4");
307 joint_name.push_back(
"joint5");
308 joint_name.push_back(
"joint6");
311 else if (ch ==
'h' || ch ==
'H')
313 printf(
"input : h \tdecrease(--) joint 3 angle\n");
314 std::vector<std::string> joint_name;
315 joint_name.push_back(
"joint1");
316 joint_name.push_back(
"joint2");
317 joint_name.push_back(
"joint3"); goalJoint.at(2) = -
JOINT_DELTA;
318 joint_name.push_back(
"joint4");
319 joint_name.push_back(
"joint5");
320 joint_name.push_back(
"joint6");
323 else if (ch ==
'u' || ch ==
'U')
325 printf(
"input : u \tincrease(++) joint 4 angle\n");
326 std::vector<std::string> joint_name;
327 joint_name.push_back(
"joint1");
328 joint_name.push_back(
"joint2");
329 joint_name.push_back(
"joint3");
330 joint_name.push_back(
"joint4"); goalJoint.at(3) =
JOINT_DELTA;
331 joint_name.push_back(
"joint5");
332 joint_name.push_back(
"joint6");
335 else if (ch ==
'j' || ch ==
'J')
337 printf(
"input : j \tdecrease(--) joint 4 angle\n");
338 std::vector<std::string> joint_name;
339 joint_name.push_back(
"joint1");
340 joint_name.push_back(
"joint2");
341 joint_name.push_back(
"joint3");
342 joint_name.push_back(
"joint4"); goalJoint.at(3) = -
JOINT_DELTA;
343 joint_name.push_back(
"joint5");
344 joint_name.push_back(
"joint6");
347 else if (ch ==
'i' || ch ==
'I')
349 printf(
"input : i \tincrease(++) joint 5 angle\n");
350 std::vector<std::string> joint_name;
351 joint_name.push_back(
"joint1");
352 joint_name.push_back(
"joint2");
353 joint_name.push_back(
"joint3");
354 joint_name.push_back(
"joint4");
355 joint_name.push_back(
"joint5"); goalJoint.at(4) =
JOINT_DELTA;
356 joint_name.push_back(
"joint6");
359 else if (ch ==
'k' || ch ==
'K')
361 printf(
"input : k \tdecrease(--) joint 5 angle\n");
362 std::vector<std::string> joint_name;
363 joint_name.push_back(
"joint1");
364 joint_name.push_back(
"joint2");
365 joint_name.push_back(
"joint3");
366 joint_name.push_back(
"joint4");
367 joint_name.push_back(
"joint5"); goalJoint.at(4) = -
JOINT_DELTA;
368 joint_name.push_back(
"joint6");
371 else if (ch ==
'o' || ch ==
'O')
373 printf(
"input : o \tincrease(++) joint 6 angle\n");
374 std::vector<std::string> joint_name;
375 joint_name.push_back(
"joint1");
376 joint_name.push_back(
"joint2");
377 joint_name.push_back(
"joint3");
378 joint_name.push_back(
"joint4");
379 joint_name.push_back(
"joint5");
380 joint_name.push_back(
"joint6"); goalJoint.at(5) =
JOINT_DELTA;
383 else if (ch ==
'l' || ch ==
'L')
385 printf(
"input : l \tdecrease(--) joint 6 angle\n");
386 std::vector<std::string> joint_name;
387 joint_name.push_back(
"joint1");
388 joint_name.push_back(
"joint2");
389 joint_name.push_back(
"joint3");
390 joint_name.push_back(
"joint4");
391 joint_name.push_back(
"joint5");
392 joint_name.push_back(
"joint6"); goalJoint.at(5) = -
JOINT_DELTA;
395 else if (ch ==
'v' || ch ==
'V')
399 printf(
"input : v \topen gripper\n");
400 std::vector<double> joint_angle;
401 joint_angle.push_back(0.0);
405 else if (ch ==
'b' || ch ==
'B')
409 printf(
"input : b \tclose gripper\n");
410 std::vector<double> joint_angle;
411 joint_angle.push_back(1.1);
417 printf(
"input : 2 \thome pose\n");
418 std::vector<std::string> joint_name;
419 std::vector<double> joint_angle;
420 double path_time = 2.0;
422 joint_name.push_back(
"joint1"); joint_angle.push_back(0.0);
423 joint_name.push_back(
"joint2"); joint_angle.push_back(-
PI/4);
424 joint_name.push_back(
"joint3"); joint_angle.push_back(
PI/8);
425 joint_name.push_back(
"joint4"); joint_angle.push_back(0.0);
426 joint_name.push_back(
"joint5"); joint_angle.push_back(
PI/8);
427 joint_name.push_back(
"joint6"); joint_angle.push_back(0.0);
432 printf(
"input : 1 \tinit pose\n");
434 std::vector<std::string> joint_name;
435 std::vector<double> joint_angle;
436 double path_time = 2.0;
437 joint_name.push_back(
"joint1"); joint_angle.push_back(0.0);
438 joint_name.push_back(
"joint2"); joint_angle.push_back(0.0);
439 joint_name.push_back(
"joint3"); joint_angle.push_back(0.0);
440 joint_name.push_back(
"joint4"); joint_angle.push_back(0.0);
441 joint_name.push_back(
"joint5"); joint_angle.push_back(0.0);
442 joint_name.push_back(
"joint6"); joint_angle.push_back(0.0);
449 tcsetattr(0, TCSANOW, &
oldt_);
456 tcgetattr(0, &
oldt_);
458 newt.c_lflag &= ~(ICANON | ECHO);
459 tcsetattr(0, TCSANOW, &newt);
462 int main(
int argc,
char **argv)
465 ros::init(argc, argv,
"open_manipulator_p_teleop_keyboard");
470 while (
ros::ok() && (ch = std::getchar()) !=
'q')
475 openManipulatorTeleop.
setGoal(ch);
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
std::vector< double > getPresentKinematicsPose()
ros::ServiceClient goal_joint_space_path_client_
void jointStatesCallback(const sensor_msgs::JointState::ConstPtr &msg)
ros::ServiceClient goal_tool_control_client_
std::vector< double > getPresentJointAngle()
ros::ServiceClient goal_joint_space_path_from_present_client_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool setTaskSpacePathFromPresentPositionOnly(std::vector< double > kinematics_pose, double path_time)
void restoreTerminalSettings(void)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
void kinematicsPoseCallback(const open_manipulator_msgs::KinematicsPose::ConstPtr &msg)
std::vector< double > present_joint_angle_
bool setJointSpacePath(std::vector< std::string > joint_name, std::vector< double > joint_angle, double path_time)
int main(int argc, char **argv)
std::vector< double > present_kinematic_position_
bool setJointSpacePathFromPresent(std::vector< std::string > joint_name, std::vector< double > joint_angle, double path_time)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
ros::ServiceClient goal_task_space_path_from_present_position_only_client_
ros::NodeHandle priv_node_handle_
void setGoal(const char *str)
ros::Subscriber joint_states_sub_
bool setToolControl(std::vector< double > joint_angle)
ros::Subscriber kinematics_pose_sub_
ros::NodeHandle node_handle_
ROSCPP_DECL void shutdown()
void disableWaitingForEnter(void)
ROSCPP_DECL void spinOnce()