14 srv.request.data = enable ? 1 : 0;
17 ROS_INFO(
"%s\n", srv.response.message.c_str());
21 ROS_ERROR(
"Failed to call service motion_ctrl");
29 srv.request.data = mode;
30 if(set_mode_client.
call(srv))
32 ROS_INFO(
"%s\n", srv.response.message.c_str());
36 ROS_ERROR(
"Failed to call service set_mode");
41 if(set_state_client.
call(srv))
43 ROS_INFO(
"%s\n", srv.response.message.c_str());
47 ROS_ERROR(
"Failed to call service set_state");
57 ROS_INFO(
"%s\n", srv.response.message.c_str());
61 ROS_ERROR(
"Failed to call service velo move");
68 int main(
int argc,
char **argv)
79 xarm_msgs::SetAxis set_axis_srv_;
80 xarm_msgs::SetInt16 set_int16_srv_;
81 xarm_msgs::MoveVelo move_joint_velo_srv_;
82 xarm_msgs::MoveVelo move_line_velo_srv_;
84 if(
motion_enable(
true, set_axis_srv_, motion_ctrl_client_) == 1)
87 std::vector<float> jnt_v = { 1, 0, 0, 0, 0, 0, 0 };
88 std::vector<float> line_v = { 100, 0, 0, 0, 0, 0};
89 move_joint_velo_srv_.request.velocities = jnt_v;
90 move_joint_velo_srv_.request.jnt_sync = 1;
91 move_line_velo_srv_.request.velocities = line_v;
92 move_line_velo_srv_.request.coord = 0;
95 if(
switch_mode(4, set_int16_srv_, set_mode_client_, set_state_client_) == 1)
97 if(
velo_move_test(move_joint_velo_srv_, velo_move_joint_client_) == 1)
100 move_joint_velo_srv_.request.velocities[0] = -1;
101 if(
velo_move_test(move_joint_velo_srv_, velo_move_joint_client_) == 1)
104 move_joint_velo_srv_.request.velocities[0] = 0;
105 if(
velo_move_test(move_joint_velo_srv_, velo_move_joint_client_) == 1)
109 if(
switch_mode(5, set_int16_srv_, set_mode_client_, set_state_client_) == 1)
111 if(
velo_move_test(move_line_velo_srv_, velo_move_line_client_) == 1)
114 move_line_velo_srv_.request.velocities[0] = -100;
115 if(
velo_move_test(move_line_velo_srv_, velo_move_line_client_) == 1)
118 move_line_velo_srv_.request.velocities[0] = 0;
119 if(
velo_move_test(move_line_velo_srv_, velo_move_line_client_) == 1)
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
void sleep_milliseconds(unsigned long milliseconds)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
int main(int argc, char **argv)
int switch_mode(int mode, xarm_msgs::SetInt16 srv, ros::ServiceClient set_mode_client, ros::ServiceClient set_state_client)
int velo_move_test(xarm_msgs::MoveVelo srv, ros::ServiceClient client)
int motion_enable(bool enable, xarm_msgs::SetAxis srv, ros::ServiceClient client)