23 priv_node_handle_(
"~")
42 ROS_INFO(
"OpenManipulator-P teleoperation using joystick start");
47 ROS_INFO(
"Terminate OpenManipulator Joystick");
67 std::vector<double> temp_angle;
69 for (std::vector<int>::size_type i = 0; i < msg->name.size(); i ++)
71 if (!msg->name.at(i).compare(
"joint1")) temp_angle.at(0) = (msg->position.at(i));
72 else if (!msg->name.at(i).compare(
"joint2")) temp_angle.at(1) = (msg->position.at(i));
73 else if (!msg->name.at(i).compare(
"joint3")) temp_angle.at(2) = (msg->position.at(i));
74 else if (!msg->name.at(i).compare(
"joint4")) temp_angle.at(3) = (msg->position.at(i));
75 else if (!msg->name.at(i).compare(
"joint5")) temp_angle.at(4) = (msg->position.at(i));
76 else if (!msg->name.at(i).compare(
"joint6")) temp_angle.at(5) = (msg->position.at(i));
83 std::vector<double> temp_position;
84 temp_position.push_back(msg->pose.position.x);
85 temp_position.push_back(msg->pose.position.y);
86 temp_position.push_back(msg->pose.position.z);
92 if (msg->axes.at(1) >= 0.9)
setGoal(
"x+");
93 else if (msg->axes.at(1) <= -0.9)
setGoal(
"x-");
94 else if (msg->axes.at(0) >= 0.9)
setGoal(
"y+");
95 else if (msg->axes.at(0) <= -0.9)
setGoal(
"y-");
96 else if (msg->buttons.at(3) == 1)
setGoal(
"z+");
97 else if (msg->buttons.at(0) == 1)
setGoal(
"z-");
98 else if (msg->buttons.at(5) == 1)
setGoal(
"home");
99 else if (msg->buttons.at(4) == 1)
setGoal(
"init");
103 if (msg->buttons.at(2) == 1)
setGoal(
"gripper close");
104 else if (msg->buttons.at(1) == 1)
setGoal(
"gripper open");
110 open_manipulator_msgs::SetJointPosition srv;
111 srv.request.joint_position.joint_name = joint_name;
112 srv.request.joint_position.position = joint_angle;
113 srv.request.path_time = path_time;
117 return srv.response.is_planned;
124 open_manipulator_msgs::SetJointPosition srv;
125 srv.request.joint_position.joint_name.push_back(
priv_node_handle_.
param<std::string>(
"end_effector_name",
"gripper"));
126 srv.request.joint_position.position = joint_angle;
130 return srv.response.is_planned;
137 open_manipulator_msgs::SetKinematicsPose srv;
139 srv.request.kinematics_pose.pose.position.x = kinematics_pose.at(0);
140 srv.request.kinematics_pose.pose.position.y = kinematics_pose.at(1);
141 srv.request.kinematics_pose.pose.position.z = kinematics_pose.at(2);
142 srv.request.path_time = path_time;
146 return srv.response.is_planned;
153 std::vector<double> goalPose; goalPose.resize(3, 0.0);
154 std::vector<double> goalJoint; goalJoint.resize(6, 0.0);
158 printf(
"increase(++) x axis in cartesian space\n");
159 goalPose.at(0) =
DELTA;
162 else if (str ==
"x-")
164 printf(
"decrease(--) x axis in cartesian space\n");
165 goalPose.at(0) = -
DELTA;
168 else if (str ==
"y+")
170 printf(
"increase(++) y axis in cartesian space\n");
171 goalPose.at(1) =
DELTA;
174 else if (str ==
"y-")
176 printf(
"decrease(--) y axis in cartesian space\n");
177 goalPose.at(1) = -
DELTA;
180 else if (str ==
"z+")
182 printf(
"increase(++) z axis in cartesian space\n");
183 goalPose.at(2) =
DELTA;
186 else if (str ==
"z-")
188 printf(
"decrease(--) z axis in cartesian space\n");
189 goalPose.at(2) = -
DELTA;
192 else if (str ==
"gripper open")
194 printf(
"open gripper\n");
195 std::vector<double> joint_angle;
196 joint_angle.push_back(0.0);
199 else if (str ==
"gripper close")
201 printf(
"close gripper\n");
202 std::vector<double> joint_angle;
203 joint_angle.push_back(1.1);
206 else if (str ==
"home")
208 printf(
"home pose\n");
209 std::vector<std::string> joint_name;
210 std::vector<double> joint_angle;
211 double path_time = 2.0;
213 joint_name.push_back(
"joint1"); joint_angle.push_back(0.0);
214 joint_name.push_back(
"joint2"); joint_angle.push_back(-
PI/4);
215 joint_name.push_back(
"joint3"); joint_angle.push_back(
PI/8);
216 joint_name.push_back(
"joint4"); joint_angle.push_back(0.0);
217 joint_name.push_back(
"joint5"); joint_angle.push_back(
PI/8);
218 joint_name.push_back(
"joint6"); joint_angle.push_back(0.0);
221 else if (str ==
"init")
223 printf(
"init pose\n");
225 std::vector<std::string> joint_name;
226 std::vector<double> joint_angle;
227 double path_time = 2.0;
228 joint_name.push_back(
"joint1"); joint_angle.push_back(0.0);
229 joint_name.push_back(
"joint2"); joint_angle.push_back(0.0);
230 joint_name.push_back(
"joint3"); joint_angle.push_back(0.0);
231 joint_name.push_back(
"joint4"); joint_angle.push_back(0.0);
232 joint_name.push_back(
"joint5"); joint_angle.push_back(0.0);
233 joint_name.push_back(
"joint6"); joint_angle.push_back(0.0);
238 int main(
int argc,
char **argv)
241 ros::init(argc, argv,
"open_manipulator_TELEOP");
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
ros::ServiceClient goal_joint_space_path_client_
void jointStatesCallback(const sensor_msgs::JointState::ConstPtr &msg)
ros::ServiceClient goal_tool_control_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)
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)
std::vector< double > present_kinematic_position_
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_
ros::Subscriber joy_command_sub_
int main(int argc, char **argv)
void joyCallback(const sensor_msgs::Joy::ConstPtr &msg)
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()