seed_r7_hand_controller.cpp
Go to the documentation of this file.
2 
3 
6  : right_number_(0),left_number_(0)
7 {
8  ROS_INFO("hand_control_server start");
9 
10  hw_ = _in_hw;
11  nh_ = _nh;
12  grasp_control_server_
13  = nh_.advertiseService("hand_control", &HandController::HandControlCallback,this);
14 
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_);
19 
20  // initialize script cancel on right_hand
21  if(right_number_ != 0) hw_->runHandScript(right_number_, SCRIPT_CANCEL,0);
22  // initialize script cancel on left_hand
23  if(left_number_ != 0) hw_->runHandScript(left_number_, SCRIPT_CANCEL,0);
24 
25  ROS_INFO("Initialized Handcontroller");
26 }
27 
29 {
30 }
31 
33 (seed_r7_ros_controller::HandControl::Request& _req,
34  seed_r7_ros_controller::HandControl::Response& _res)
35 {
36  uint8_t send_number;
37  uint16_t script_number;
38 
39  ROS_INFO("Grasp callback start");
40 
41  // position
42  // number depends on configuration, therefore if/else check
43  if (_req.position == seed_r7_ros_controller::HandControl::Request::POSITION_RIGHT)
44  send_number = right_number_;
45  else if (_req.position == seed_r7_ros_controller::HandControl::Request::POSITION_LEFT)
46  send_number = left_number_;
47  else {
48  ROS_ERROR("please input POSITION_RIGHT(0) or POSITION_LEFT(1). ");
49  _res.result = "service call failed";
50  return false;
51  }
52 
53  // script
54  if (_req.script == seed_r7_ros_controller::HandControl::Request::SCRIPT_GRASP)
55  script_number = SCRIPT_GRASP;
56  else if (_req.script == seed_r7_ros_controller::HandControl::Request::SCRIPT_RELEASE)
57  script_number = SCRIPT_UNGRASP;
58  else if (_req.script == seed_r7_ros_controller::HandControl::Request::SCRIPT_CANCEL)
59  script_number = SCRIPT_CANCEL;
60  else {
61  ROS_ERROR("please input \"grasp\", \"release\" or \"cancel\".");
62  _res.result = "service call failed";
63  return false;
64  }
65 
66  ROS_INFO("motion: %s", _req.script.c_str());
67  if(send_number != 0) hw_->runHandScript(send_number, script_number, _req.current);
68 
69  ROS_INFO("End Grasp");
70  return true;
71 }
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
#define ROS_INFO(...)
HandController(const ros::NodeHandle &_nh, robot_hardware::RobotHW *_in_hw)
bool HandControlCallback(seed_r7_ros_controller::HandControl::Request &_req, seed_r7_ros_controller::HandControl::Response &_res)
#define ROS_ERROR(...)
void runHandScript(uint8_t _number, uint16_t _script, uint8_t _current)


seed_r7_ros_controller
Author(s): Yohei Kakiuchi
autogenerated on Sun Apr 18 2021 02:40:34