6 : right_number_(0),left_number_(0)
8 ROS_INFO(
"hand_control_server start");
13 = nh_.
advertiseService(
"hand_control", &HandController::HandControlCallback,
this);
15 if (nh_.hasParam(
"/joint_settings/hand/right_number"))
16 nh_.getParam(
"/joint_settings/hand/right_number", right_number_);
17 if (nh_.hasParam(
"/joint_settings/hand/left_number"))
18 nh_.getParam(
"/joint_settings/hand/left_number", left_number_);
21 if(right_number_ != 0) hw_->runHandScript(right_number_, SCRIPT_CANCEL,0);
23 if(left_number_ != 0) hw_->runHandScript(left_number_, SCRIPT_CANCEL,0);
25 ROS_INFO(
"Initialized Handcontroller");
33 (seed_r7_ros_controller::HandControl::Request& _req,
34 seed_r7_ros_controller::HandControl::Response& _res)
37 uint16_t script_number;
43 if (_req.position == seed_r7_ros_controller::HandControl::Request::POSITION_RIGHT)
45 else if (_req.position == seed_r7_ros_controller::HandControl::Request::POSITION_LEFT)
48 ROS_ERROR(
"please input POSITION_RIGHT(0) or POSITION_LEFT(1). ");
49 _res.result =
"service call failed";
54 if (_req.script == seed_r7_ros_controller::HandControl::Request::SCRIPT_GRASP)
56 else if (_req.script == seed_r7_ros_controller::HandControl::Request::SCRIPT_RELEASE)
58 else if (_req.script == seed_r7_ros_controller::HandControl::Request::SCRIPT_CANCEL)
61 ROS_ERROR(
"please input \"grasp\", \"release\" or \"cancel\".");
62 _res.result =
"service call failed";
66 ROS_INFO(
"motion: %s", _req.script.c_str());
67 if(send_number != 0)
hw_->
runHandScript(send_number, script_number, _req.current);
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
const uint16_t SCRIPT_UNGRASP
HandController(const ros::NodeHandle &_nh, robot_hardware::RobotHW *_in_hw)
robot_hardware::RobotHW * hw_
bool HandControlCallback(seed_r7_ros_controller::HandControl::Request &_req, seed_r7_ros_controller::HandControl::Response &_res)
const uint16_t SCRIPT_CANCEL
void runHandScript(uint8_t _number, uint16_t _script, uint8_t _current)
const uint16_t SCRIPT_GRASP