mia_hand_driver  rel 1.0.0
ros_driver.cpp
Go to the documentation of this file.
2 #include <iostream>
3 
4 namespace mia_hand
5 {
6 ROSDriver::ROSDriver(ros::NodeHandle& nh, ros::NodeHandle& nh_priv):
7  nh_(nh),
8  nh_priv_(nh_priv),
9  is_connected_(false),
10  was_connected_(false)
11 {
12  uint16_t port_num;
13 
14  ROS_INFO("Please specify Mia Hand port number: ");
15  std::cin >> port_num;
16 
17  bool port_opened = mia_.connectToPort(port_num);
18 
19  if (port_opened)
20  {
21  std::string info_msg = "/dev/ttyUSB successfully opened.";
22  info_msg.insert(11, std::to_string(port_num));
23 
24  ROS_INFO("%s\n", info_msg.c_str());
25 
31  initServices();
32 
33  publish_data_tmr_ = nh_.createWallTimer(ros::WallDuration(0.1),
35  this);
36 
37  check_connection_tmr_ = nh_.createWallTimer(ros::WallDuration(1),
39  this);
40  }
41  else
42  {
43  ROS_ERROR("Could not open specified serial port.");
44  }
45 }
46 
47 void ROSDriver::publishDataTmrCallback(const ros::WallTimerEvent& event)
48 {
49  mia_hand_msgs::FingersData msg;
50 
51  msg.thu = mia_.getMotorPos(0);
52  msg.ind = mia_.getMotorPos(2);
53  msg.mrl = mia_.getMotorPos(1);
54 
55  mot_pos_info_.publish(msg);
56 
57  msg.thu = mia_.getMotorSpe(0);
58  msg.ind = mia_.getMotorSpe(2);
59  msg.mrl = mia_.getMotorSpe(1);
60 
61  mot_spe_info_.publish(msg);
62 
63  msg.thu = mia_.getMotorCur(0);
64  msg.ind = mia_.getMotorCur(2);
65  msg.mrl = mia_.getMotorCur(1);
66 
67  mot_cur_info_.publish(msg);
68 
69  mia_hand_msgs::FingersStrainGauges msg_sg;
70 
71  mia_.getFingerSgRaw(0, msg_sg.thu[0], msg_sg.thu[1]);
72  mia_.getFingerSgRaw(2, msg_sg.ind[0], msg_sg.ind[1]);
73  mia_.getFingerSgRaw(1, msg_sg.mrl[0], msg_sg.mrl[1]);
74 
75  fin_for_info_.publish(msg_sg);
76 
77  return;
78 }
79 
80 void ROSDriver::checkConnectionTmrCallback(const ros::WallTimerEvent& event)
81 {
83 
85  {
86  was_connected_ = true;
87  ROS_INFO("Mia Hand connected.");
88  }
89  else if (!is_connected_ && was_connected_)
90  {
91  was_connected_ = false;
92  ROS_INFO("Mia Hand disconnected.");
93  }
94  else
95  {
96  // Default case: keep program running.
97  }
98 
99  return;
100 }
101 
103 {
104  thu_mot_trgt_pos_ = nh_.subscribe("thumb_mot_trgt_pos", 1000,
106 
107  thu_mot_trgt_spe_ = nh_.subscribe("thumb_mot_trgt_spe", 1000,
109 
110  thu_fin_trgt_for_ = nh_.subscribe("thumb_fin_trgt_for", 1000,
112 
113  thu_cyl_grasp_ref_ = nh_.subscribe("thumb_cyl_grasp_ref", 1000,
115 
116  thu_pin_grasp_ref_ = nh_.subscribe("thumb_pin_grasp_ref", 1000,
118 
119  thu_lat_grasp_ref_ = nh_.subscribe("thumb_lat_grasp_ref", 1000,
121 
122  thu_sph_grasp_ref_ = nh_.subscribe("thumb_sph_grasp_ref", 1000,
124 
125  thu_tri_grasp_ref_ = nh_.subscribe("thumb_tri_grasp_ref", 1000,
127 
128  return;
129 }
130 
132 {
133  ind_mot_trgt_pos_ = nh_.subscribe("index_mot_trgt_pos", 1000,
135 
136  ind_mot_trgt_spe_ = nh_.subscribe("index_mot_trgt_spe", 1000,
138 
139  ind_fin_trgt_for_ = nh_.subscribe("index_fin_trgt_for", 1000,
141 
142  ind_cyl_grasp_ref_ = nh_.subscribe("index_cyl_grasp_ref", 1000,
144 
145  ind_pin_grasp_ref_ = nh_.subscribe("index_pin_grasp_ref", 1000,
147 
148  ind_lat_grasp_ref_ = nh_.subscribe("index_lat_grasp_ref", 1000,
150 
151  ind_sph_grasp_ref_ = nh_.subscribe("index_sph_grasp_ref", 1000,
153 
154  ind_tri_grasp_ref_ = nh_.subscribe("index_tri_grasp_ref", 1000,
156 
157  return;
158 }
159 
161 {
162  mrl_mot_trgt_pos_ = nh_.subscribe("mrl_mot_trgt_pos", 1000,
164 
165  mrl_mot_trgt_spe_ = nh_.subscribe("mrl_mot_trgt_spe", 1000,
167 
168  mrl_fin_trgt_for_ = nh_.subscribe("mrl_fin_trgt_for", 1000,
170 
171  mrl_cyl_grasp_ref_ = nh_.subscribe("mrl_cyl_grasp_ref", 1000,
173 
174  mrl_pin_grasp_ref_ = nh_.subscribe("mrl_pin_grasp_ref", 1000,
176 
177  mrl_lat_grasp_ref_ = nh_.subscribe("mrl_lat_grasp_ref", 1000,
179 
180  mrl_sph_grasp_ref_ = nh_.subscribe("mrl_sph_grasp_ref", 1000,
182 
183  mrl_tri_grasp_ref_ = nh_.subscribe("mrl_tri_grasp_ref", 1000,
185 
186  return;
187 }
188 
190 {
191  cyl_grasp_percent_ = nh_.subscribe("cyl_grasp_percent", 1000,
193 
194  pin_grasp_percent_ = nh_.subscribe("pin_grasp_percent", 1000,
196 
197  lat_grasp_percent_ = nh_.subscribe("lat_grasp_percent", 1000,
199 
200  sph_grasp_percent_ = nh_.subscribe("sph_grasp_percent", 1000,
202 
203  tri_grasp_percent_ = nh_.subscribe("tri_grasp_percent", 1000,
205 
206  return;
207 }
208 
210 {
211  connect_to_port_ = nh_.advertiseService("connect_to_port",
213  this);
214 
215  disconnect_ = nh_.advertiseService("disconnect",
217 
218  switch_pos_stream_ = nh_.advertiseService("switch_pos_stream",
220  this);
221 
222  switch_spe_stream_ = nh_.advertiseService("switch_spe_stream",
224  this);
225 
226  switch_ana_stream_ = nh_.advertiseService("switch_ana_stream",
228  this);
229 
230  switch_cur_stream_ = nh_.advertiseService("switch_cur_stream",
232  this);
233 
234  open_cyl_grasp_ = nh_.advertiseService("open_cyl_grasp",
236  this);
237 
238  open_pin_grasp_ = nh_.advertiseService("open_pin_grasp",
240  this);
241 
242  open_lat_grasp_ = nh_.advertiseService("open_lat_grasp",
244  this);
245 
246  open_sph_grasp_ = nh_.advertiseService("open_sph_grasp",
248  this);
249 
250  open_tri_grasp_ = nh_.advertiseService("open_tri_grasp",
252  this);
253 
254  close_cyl_grasp_ = nh_.advertiseService("close_cyl_grasp",
256  this);
257 
258  close_pin_grasp_ = nh_.advertiseService("close_pin_grasp",
260  this);
261 
262  close_lat_grasp_ = nh_.advertiseService("close_lat_grasp",
264  this);
265 
266  close_sph_grasp_ = nh_.advertiseService("close_sph_grasp",
268  this);
269 
270  close_tri_grasp_ = nh_.advertiseService("close_tri_grasp",
272  this);
273 
274  return;
275 }
276 
278 {
279  mot_pos_info_ = nh_.advertise<mia_hand_msgs::FingersData>("mot_pos", 1000);
280  mot_spe_info_ = nh_.advertise<mia_hand_msgs::FingersData>("mot_spe", 1000);
281  mot_cur_info_ = nh_.advertise<mia_hand_msgs::FingersData>("mot_cur", 1000);
282  fin_for_info_ = nh_.advertise<mia_hand_msgs::FingersStrainGauges>("fin_sg",
283  1000);
284 
285  return;
286 }
287 
288 void ROSDriver::thuMotTrgtPosCallback(const std_msgs::Int16::ConstPtr& msg)
289 {
290  mia_.setMotorPos(0, msg->data);
291 
292  return;
293 }
294 
295 void ROSDriver::thuMotTrgtSpeCallback(const std_msgs::Int16::ConstPtr& msg)
296 {
297  mia_.setMotorSpe(0, msg->data);
298 
299  return;
300 }
301 
302 void ROSDriver::thuFinTrgtForCallback(const std_msgs::Int16::ConstPtr& msg)
303 {
304  mia_.setFingerFor(0, msg->data);
305 
306  return;
307 }
308 
309 void ROSDriver::thuCylGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
310  msg)
311 {
312  mia_.setThuGraspRef('C', msg->rest, msg->pos, msg->delay);
313 
314  return;
315 }
316 
317 void ROSDriver::thuPinGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
318  msg)
319 {
320  mia_.setThuGraspRef('P', msg->rest, msg->pos, msg->delay);
321 
322  return;
323 }
324 
325 void ROSDriver::thuLatGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
326  msg)
327 {
328  mia_.setThuGraspRef('L', msg->rest, msg->pos, msg->delay);
329 
330  return;
331 }
332 
333 void ROSDriver::thuSphGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
334  msg)
335 {
336  mia_.setThuGraspRef('S', msg->rest, msg->pos, msg->delay);
337 
338  return;
339 }
340 
341 void ROSDriver::thuTriGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
342  msg)
343 {
344  mia_.setThuGraspRef('T', msg->rest, msg->pos, msg->delay);
345 
346  return;
347 }
348 
349 void ROSDriver::indCylGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
350  msg)
351 {
352  mia_.setIndGraspRef('C', msg->rest, msg->pos, msg->delay);
353 
354  return;
355 }
356 
357 void ROSDriver::indPinGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
358  msg)
359 {
360  mia_.setIndGraspRef('P', msg->rest, msg->pos, msg->delay);
361 
362  return;
363 }
364 
365 void ROSDriver::indLatGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
366  msg)
367 {
368  mia_.setIndGraspRef('L', msg->rest, msg->pos, msg->delay);
369 
370  return;
371 }
372 
373 void ROSDriver::indSphGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
374  msg)
375 {
376  mia_.setIndGraspRef('S', msg->rest, msg->pos, msg->delay);
377 
378  return;
379 }
380 
381 void ROSDriver::indTriGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
382  msg)
383 {
384  mia_.setIndGraspRef('T', msg->rest, msg->pos, msg->delay);
385 
386  return;
387 }
388 
389 void ROSDriver::mrlCylGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
390  msg)
391 {
392  mia_.setMrlGraspRef('C', msg->rest, msg->pos, msg->delay);
393 
394  return;
395 }
396 
397 void ROSDriver::mrlPinGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
398  msg)
399 {
400  mia_.setMrlGraspRef('P', msg->rest, msg->pos, msg->delay);
401 
402  return;
403 }
404 
405 void ROSDriver::mrlLatGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
406  msg)
407 {
408  mia_.setMrlGraspRef('L', msg->rest, msg->pos, msg->delay);
409 
410  return;
411 }
412 
413 void ROSDriver::mrlSphGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
414  msg)
415 {
416  mia_.setMrlGraspRef('S', msg->rest, msg->pos, msg->delay);
417 
418  return;
419 }
420 
421 void ROSDriver::mrlTriGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr&
422  msg)
423 {
424  mia_.setMrlGraspRef('T', msg->rest, msg->pos, msg->delay);
425 
426  return;
427 }
428 
429 void ROSDriver::indMotTrgtPosCallback(const std_msgs::Int16::ConstPtr& msg)
430 {
431  mia_.setMotorPos(2, msg->data);
432 
433  return;
434 }
435 
436 void ROSDriver::indMotTrgtSpeCallback(const std_msgs::Int16::ConstPtr& msg)
437 {
438  mia_.setMotorSpe(2, msg->data);
439 
440  return;
441 }
442 
443 void ROSDriver::indFinTrgtForCallback(const std_msgs::Int16::ConstPtr& msg)
444 {
445  mia_.setFingerFor(2, msg->data);
446 
447  return;
448 }
449 
450 void ROSDriver::mrlMotTrgtPosCallback(const std_msgs::Int16::ConstPtr& msg)
451 {
452  mia_.setMotorPos(1, msg->data);
453 
454  return;
455 }
456 
457 void ROSDriver::mrlMotTrgtSpeCallback(const std_msgs::Int16::ConstPtr& msg)
458 {
459  mia_.setMotorSpe(1, msg->data);
460 
461  return;
462 }
463 
464 void ROSDriver::mrlFinTrgtForCallback(const std_msgs::Int16::ConstPtr& msg)
465 {
466  mia_.setFingerFor(1, msg->data);
467 
468  return;
469 }
470 
471 void ROSDriver::cylGraspPercentCallback(const std_msgs::Int16::ConstPtr& msg)
472 {
473  mia_.closeGrasp('C', msg->data);
474 
475  return;
476 }
477 
478 void ROSDriver::pinGraspPercentCallback(const std_msgs::Int16::ConstPtr& msg)
479 {
480  mia_.closeGrasp('P', msg->data);
481 
482  return;
483 }
484 
485 
486 void ROSDriver::latGraspPercentCallback(const std_msgs::Int16::ConstPtr& msg)
487 {
488  mia_.closeGrasp('L', msg->data);
489 
490  return;
491 }
492 
493 void ROSDriver::sphGraspPercentCallback(const std_msgs::Int16::ConstPtr& msg)
494 {
495  mia_.closeGrasp('S', msg->data);
496 
497  return;
498 }
499 
500 void ROSDriver::triGraspPercentCallback(const std_msgs::Int16::ConstPtr& msg)
501 {
502  mia_.closeGrasp('T', msg->data);
503 
504  return;
505 }
506 
508  mia_hand_msgs::ConnectSerial::Request& req,
509  mia_hand_msgs::ConnectSerial::Response& resp)
510 {
511  bool is_port_open = mia_.connectToPort(req.port);
512 
513  if (is_port_open)
514  {
515  resp.success = true;
516  resp.message = "/dev/ttyUSB" + std::to_string(req.port)
517  + " succesfully opened.";
518  }
519  else
520  {
521  resp.success = false;
522  resp.message = "Could not open /dev/ttyUSB" + std::to_string(req.port)
523  + ".";
524  }
525 
526  return true;
527 }
528 
529 bool ROSDriver::disconnectCallback(std_srvs::Trigger::Request& req,
530  std_srvs::Trigger::Response& resp)
531 {
532  bool is_port_closed = mia_.disconnect();
533 
534  if (is_port_closed)
535  {
536  resp.success = true;
537  resp.message = "Mia Hand serial port closed.";
538  }
539  else
540  {
541  resp.success = false;
542  resp.message = "Could not close Mia Hand serial port.";
543  }
544 
545  return true;
546 }
547 
548 bool ROSDriver::switchPosStreamCallback(std_srvs::SetBool::Request& req,
549  std_srvs::SetBool::Response& resp)
550 {
551  mia_.switchPosStream(req.data);
552 
553  return true;
554 }
555 
556 bool ROSDriver::switchSpeStreamCallback(std_srvs::SetBool::Request& req,
557  std_srvs::SetBool::Response& resp)
558 {
559  mia_.switchSpeStream(req.data);
560 
561  return true;
562 }
563 
564 bool ROSDriver::switchAnaStreamCallback(std_srvs::SetBool::Request& req,
565  std_srvs::SetBool::Response& resp)
566 {
567  mia_.switchAnaStream(req.data);
568 
569  return true;
570 }
571 
572 bool ROSDriver::switchCurStreamCallback(std_srvs::SetBool::Request& req,
573  std_srvs::SetBool::Response& resp)
574 {
575  mia_.switchCurStream(req.data);
576 
577  return true;
578 }
579 
580 bool ROSDriver::openCylGraspCallback(std_srvs::Empty::Request& req,
581  std_srvs::Empty::Response& resp)
582 {
583  mia_.openGrasp('C');
584 
585  return true;
586 }
587 
588 bool ROSDriver::openPinGraspCallback(std_srvs::Empty::Request& req,
589  std_srvs::Empty::Response& resp)
590 {
591  mia_.openGrasp('P');
592 
593  return true;
594 }
595 
596 bool ROSDriver::openLatGraspCallback(std_srvs::Empty::Request& req,
597  std_srvs::Empty::Response& resp)
598 {
599  mia_.openGrasp('L');
600 
601  return true;
602 }
603 
604 bool ROSDriver::openSphGraspCallback(std_srvs::Empty::Request& req,
605  std_srvs::Empty::Response& resp)
606 {
607  mia_.openGrasp('S');
608 
609  return true;
610 }
611 
612 bool ROSDriver::openTriGraspCallback(std_srvs::Empty::Request& req,
613  std_srvs::Empty::Response& resp)
614 {
615  mia_.openGrasp('T');
616 
617  return true;
618 }
619 
620 bool ROSDriver::closeCylGraspCallback(std_srvs::Empty::Request& req,
621  std_srvs::Empty::Response& resp)
622 {
623  mia_.closeGrasp('C');
624 
625  return true;
626 }
627 
628 bool ROSDriver::closePinGraspCallback(std_srvs::Empty::Request& req,
629  std_srvs::Empty::Response& resp)
630 {
631  mia_.closeGrasp('P');
632 
633  return true;
634 }
635 
636 bool ROSDriver::closeLatGraspCallback(std_srvs::Empty::Request& req,
637  std_srvs::Empty::Response& resp)
638 {
639  mia_.closeGrasp('L');
640 
641  return true;
642 }
643 
644 bool ROSDriver::closeSphGraspCallback(std_srvs::Empty::Request& req,
645  std_srvs::Empty::Response& resp)
646 {
647  mia_.closeGrasp('S');
648 
649  return true;
650 }
651 
652 bool ROSDriver::closeTriGraspCallback(std_srvs::Empty::Request& req,
653  std_srvs::Empty::Response& resp)
654 {
655  mia_.closeGrasp('T');
656 
657  return true;
658 }
659 } // namespace
mia_hand::ROSDriver::thu_cyl_grasp_ref_
ros::Subscriber thu_cyl_grasp_ref_
Subscriber to receive the parametrs for cylindrical grasp for the thumb flexion motor.
Definition: ros_driver.h:84
mia_hand::CppDriver::getFingerSgRaw
void getFingerSgRaw(uint8_t fin_id, int16_t &nor_for, int16_t &tan_for)
Get the current output of the force sensor of a specific finger of the Mia hand.
Definition: cpp_driver.cpp:238
mia_hand::ROSDriver::switchPosStreamCallback
bool switchPosStreamCallback(std_srvs::SetBool::Request &req, std_srvs::SetBool::Response &resp)
Callback of the service switch_pos_stream_.
Definition: ros_driver.cpp:548
mia_hand::CppDriver::switchSpeStream
void switchSpeStream(bool b_on_off)
Manage the streaming of the motors velocity data.
Definition: cpp_driver.cpp:423
mia_hand::ROSDriver::ind_mot_trgt_spe_
ros::Subscriber ind_mot_trgt_spe_
Subscriber to receive the target velocity of the index flexion motor.
Definition: ros_driver.h:77
mia_hand::ROSDriver::indFinTrgtForCallback
void indFinTrgtForCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber ind_fin_trgt_for_.
Definition: ros_driver.cpp:443
mia_hand::ROSDriver::openTriGraspCallback
bool openTriGraspCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
Callback of the service open_tri_grasp_.
Definition: ros_driver.cpp:612
mia_hand::ROSDriver::lat_grasp_percent_
ros::Subscriber lat_grasp_percent_
Subscriber to receive the closure percentage for lateral grasp.
Definition: ros_driver.h:106
mia_hand::ROSDriver::mrlFinTrgtForCallback
void mrlFinTrgtForCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber mrl_fin_trgt_for_.
Definition: ros_driver.cpp:464
mia_hand::ROSDriver::was_connected_
bool was_connected_
True if the Mia hand was connected, False otherwise.
Definition: ros_driver.h:60
mia_hand::ROSDriver::mrlMotTrgtSpeCallback
void mrlMotTrgtSpeCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber mrl_mot_trgt_spe_.
Definition: ros_driver.cpp:457
mia_hand::ROSDriver::thuMotTrgtPosCallback
void thuMotTrgtPosCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber thu_mot_trgt_pos_.
Definition: ros_driver.cpp:288
mia_hand::ROSDriver::ROSDriver
ROSDriver(ros::NodeHandle &nh, ros::NodeHandle &nh_priv)
Class constructor.
Definition: ros_driver.cpp:6
mia_hand::ROSDriver::initServices
void initServices()
Initialize services.
Definition: ros_driver.cpp:209
mia_hand::ROSDriver::checkConnectionTmrCallback
void checkConnectionTmrCallback(const ros::WallTimerEvent &event)
Callback of the check_connection_tmr_ timer.
Definition: ros_driver.cpp:80
mia_hand::ROSDriver::ind_fin_trgt_for_
ros::Subscriber ind_fin_trgt_for_
Subscriber to receive the target force of the index flexion motor.
Definition: ros_driver.h:81
mia_hand::ROSDriver::indLatGraspRefCallback
void indLatGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber ind_lat_grasp_ref_.
Definition: ros_driver.cpp:365
mia_hand::ROSDriver::pin_grasp_percent_
ros::Subscriber pin_grasp_percent_
Subscriber to receive the closure percentage for pinch grasp.
Definition: ros_driver.h:105
mia_hand::ROSDriver::pinGraspPercentCallback
void pinGraspPercentCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber pin_grasp_percent_.
Definition: ros_driver.cpp:478
mia_hand::ROSDriver::closeSphGraspCallback
bool closeSphGraspCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
Callback of the service close_sph_grasp_.
Definition: ros_driver.cpp:644
mia_hand::CppDriver::openGrasp
void openGrasp(char grasp_id)
Go to rest pose of a grasp type Move all the Mia hand fingers to the rest pose of a specific grasp ty...
Definition: cpp_driver.cpp:276
mia_hand::ROSDriver::is_connected_
bool is_connected_
True if the Mia hand is connected, False otherwise.
Definition: ros_driver.h:59
mia_hand::ROSDriver::openSphGraspCallback
bool openSphGraspCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
Callback of the service open_sph_grasp_.
Definition: ros_driver.cpp:604
mia_hand::ROSDriver::thu_fin_trgt_for_
ros::Subscriber thu_fin_trgt_for_
Subscriber to receive the target force of the tumb flexion motor.
Definition: ros_driver.h:80
mia_hand::ROSDriver::thu_pin_grasp_ref_
ros::Subscriber thu_pin_grasp_ref_
Subscriber to receive the parametrs for pinch grasp for the thumb flexion motor.
Definition: ros_driver.h:88
mia_hand::CppDriver::setThuGraspRef
void setThuGraspRef(char grasp_id, int16_t rest, int16_t pos, int16_t delay)
Set grasp parameter for thumb flexion motor.
Definition: cpp_driver.cpp:314
mia_hand::ROSDriver::mrlLatGraspRefCallback
void mrlLatGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber #mrl_lat_grasp_ref.
Definition: ros_driver.cpp:405
mia_hand::ROSDriver::thu_sph_grasp_ref_
ros::Subscriber thu_sph_grasp_ref_
Subscriber to receive the parametrs for spherical grasp for the thumb flexion motor.
Definition: ros_driver.h:96
mia_hand::ROSDriver::tri_grasp_percent_
ros::Subscriber tri_grasp_percent_
Subscriber to receive the closure percentage for tridigital grasp.
Definition: ros_driver.h:108
mia_hand::CppDriver::setMotorSpe
void setMotorSpe(uint8_t fin_id, int16_t mot_spe)
Set the target velocity of a specific motor of the Mia hand.
Definition: cpp_driver.cpp:84
mia_hand::ROSDriver::mrl_sph_grasp_ref_
ros::Subscriber mrl_sph_grasp_ref_
Subscriber to receive the parametrs for spherical grasp for the mrl flexion motor.
Definition: ros_driver.h:98
mia_hand::ROSDriver::ind_lat_grasp_ref_
ros::Subscriber ind_lat_grasp_ref_
Subscriber to receive the parametrs for lateral grasp for the index flexion motor.
Definition: ros_driver.h:93
mia_hand::ROSDriver::ind_mot_trgt_pos_
ros::Subscriber ind_mot_trgt_pos_
Subscriber to receive the target pose of the index flexion motor.
Definition: ros_driver.h:73
mia_hand::ROSDriver::indMotTrgtPosCallback
void indMotTrgtPosCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber ind_mot_trgt_pos_.
Definition: ros_driver.cpp:429
mia_hand::ROSDriver::mrlPinGraspRefCallback
void mrlPinGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber #mrl_pin_grasp_ref.
Definition: ros_driver.cpp:397
mia_hand::ROSDriver::switchAnaStreamCallback
bool switchAnaStreamCallback(std_srvs::SetBool::Request &req, std_srvs::SetBool::Response &resp)
Callback of the service switch_ana_stream_.
Definition: ros_driver.cpp:564
mia_hand::ROSDriver::indCylGraspRefCallback
void indCylGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber ind_cyl_grasp_ref_.
Definition: ros_driver.cpp:349
mia_hand::ROSDriver::openPinGraspCallback
bool openPinGraspCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
Callback of the service open_pin_grasp_.
Definition: ros_driver.cpp:588
mia_hand::ROSDriver::thu_tri_grasp_ref_
ros::Subscriber thu_tri_grasp_ref_
Subscriber to receive the parametrs for tridigital grasp for the thumb flexion motor.
Definition: ros_driver.h:100
mia_hand::ROSDriver::sph_grasp_percent_
ros::Subscriber sph_grasp_percent_
Subscriber to receive the closure percentage for sherical grasp.
Definition: ros_driver.h:107
mia_hand::ROSDriver::mrl_mot_trgt_spe_
ros::Subscriber mrl_mot_trgt_spe_
Subscriber to receive the target velocity of the mrl flexion motor.
Definition: ros_driver.h:78
mia_hand::ROSDriver::mrlCylGraspRefCallback
void mrlCylGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber #mrl_cyl_grasp_ref.
Definition: ros_driver.cpp:389
mia_hand::ROSDriver::thuCylGraspRefCallback
void thuCylGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber thu_cyl_grasp_ref_.
Definition: ros_driver.cpp:309
mia_hand::ROSDriver::indMotTrgtSpeCallback
void indMotTrgtSpeCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber ind_mot_trgt_spe_.
Definition: ros_driver.cpp:436
mia_hand::ROSDriver::mrl_tri_grasp_ref_
ros::Subscriber mrl_tri_grasp_ref_
Subscriber to receive the parametrs for tridigital grasp for the mrl flexion motor.
Definition: ros_driver.h:102
mia_hand::CppDriver::getMotorPos
int16_t getMotorPos(uint8_t fin_id)
Get the current position of a specific motor of the Mia hand.
Definition: cpp_driver.cpp:130
mia_hand::ROSDriver::open_lat_grasp_
ros::ServiceServer open_lat_grasp_
Service to move the Mia hand motors to the rest position of the lateral grasp.
Definition: ros_driver.h:129
mia_hand::ROSDriver::mrl_lat_grasp_ref_
ros::Subscriber mrl_lat_grasp_ref_
Subscriber to receive the parametrs for lateral grasp for the mrl flexion motor.
Definition: ros_driver.h:94
mia_hand::CppDriver::disconnect
bool disconnect()
Disconnect the Mia hand closing the serial port.
Definition: cpp_driver.cpp:37
mia_hand::ROSDriver::ind_cyl_grasp_ref_
ros::Subscriber ind_cyl_grasp_ref_
Subscriber to receive the parametrs for cylindrical grasp for the index flexion motor.
Definition: ros_driver.h:85
mia_hand::ROSDriver::fin_for_info_
ros::Publisher fin_for_info_
Publisher of the force data read by the sensors embedded in the Mia hand fingers.
Definition: ros_driver.h:115
mia_hand::ROSDriver::mrlSphGraspRefCallback
void mrlSphGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber #mrl_sph_grasp_ref.
Definition: ros_driver.cpp:413
mia_hand::ROSDriver::mot_pos_info_
ros::Publisher mot_pos_info_
Publisher of the positions data of the Mia hand motors.
Definition: ros_driver.h:112
mia_hand::ROSDriver::thuLatGraspRefCallback
void thuLatGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber thu_lat_grasp_ref_.
Definition: ros_driver.cpp:325
mia_hand::CppDriver::switchAnaStream
void switchAnaStream(bool b_on_off)
Manage the streaming of analog input data (as the straing gauge force sensors).
Definition: cpp_driver.cpp:433
mia_hand::ROSDriver::switch_spe_stream_
ros::ServiceServer switch_spe_stream_
Service to manage a the streaming of motor velocity data sent by the Mia hand.
Definition: ros_driver.h:123
mia_hand::ROSDriver::nh_
ros::NodeHandle & nh_
Reference to public node handle (for topics and services)
Definition: ros_driver.h:65
mia_hand::ROSDriver::triGraspPercentCallback
void triGraspPercentCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber tri_grasp_percent_.
Definition: ros_driver.cpp:500
mia_hand::CppDriver::getMotorSpe
int16_t getMotorSpe(uint8_t fin_id)
Get the current velocity of a specific motor of the Mia hand.
Definition: cpp_driver.cpp:166
mia_hand::ROSDriver::mrl_pin_grasp_ref_
ros::Subscriber mrl_pin_grasp_ref_
Subscriber to receive the parametrs for pinch grasp for the mrl flexion motor.
Definition: ros_driver.h:90
mia_hand::ROSDriver::indTriGraspRefCallback
void indTriGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber ind_tri_grasp_ref_.
Definition: ros_driver.cpp:381
mia_hand::ROSDriver::indSphGraspRefCallback
void indSphGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber ind_sph_grasp_ref_.
Definition: ros_driver.cpp:373
mia_hand::ROSDriver::mrl_fin_trgt_for_
ros::Subscriber mrl_fin_trgt_for_
Subscriber to receive the target force of the mrl flexion motor.
Definition: ros_driver.h:82
mia_hand::ROSDriver::cylGraspPercentCallback
void cylGraspPercentCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber cyl_grasp_percent_.
Definition: ros_driver.cpp:471
mia_hand::ROSDriver::mia_
CppDriver mia_
Cpp driver of the Mia hand.
Definition: ros_driver.h:57
mia_hand::ROSDriver::thu_mot_trgt_spe_
ros::Subscriber thu_mot_trgt_spe_
Subscriber to receive the target velocity of the tumb flexion motor.
Definition: ros_driver.h:76
mia_hand::ROSDriver::mrl_cyl_grasp_ref_
ros::Subscriber mrl_cyl_grasp_ref_
Subscriber to receive the parametrs for cylindrical grasp for the mrl flexion motor.
Definition: ros_driver.h:86
mia_hand::ROSDriver::ind_pin_grasp_ref_
ros::Subscriber ind_pin_grasp_ref_
Subscriber to receive the parametrs for pinch grasp for the index flexion motor.
Definition: ros_driver.h:89
mia_hand::ROSDriver::mot_spe_info_
ros::Publisher mot_spe_info_
Publisher of the velocity data of the Mia hand motors.
Definition: ros_driver.h:113
mia_hand::ROSDriver::switch_cur_stream_
ros::ServiceServer switch_cur_stream_
Service to manage a the streaming of the current data (i.e. force sensor outputs) sent by the Mia han...
Definition: ros_driver.h:125
mia_hand::ROSDriver::initSubscribersMrl
void initSubscribersMrl()
Initialize subscribers of the index mrl motor info.
Definition: ros_driver.cpp:160
mia_hand
Definition: cpp_driver.h:16
mia_hand::CppDriver::switchPosStream
void switchPosStream(bool b_on_off)
Manage the streaming of the motors position data.
Definition: cpp_driver.cpp:413
mia_hand::ROSDriver::closeTriGraspCallback
bool closeTriGraspCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
Callback of the service close_tri_grasp_.
Definition: ros_driver.cpp:652
mia_hand::ROSDriver::thuTriGraspRefCallback
void thuTriGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber thu_sph_grasp_ref_.
Definition: ros_driver.cpp:341
mia_hand::CppDriver::isConnected
bool isConnected()
Function returning the connection status of the Mia hand.
Definition: cpp_driver.cpp:51
mia_hand::ROSDriver::ind_sph_grasp_ref_
ros::Subscriber ind_sph_grasp_ref_
Subscriber to receive the parametrs for spherical grasp for the index flexion motor.
Definition: ros_driver.h:97
mia_hand::ROSDriver::thuPinGraspRefCallback
void thuPinGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber thu_pin_grasp_ref_.
Definition: ros_driver.cpp:317
mia_hand::ROSDriver::close_cyl_grasp_
ros::ServiceServer close_cyl_grasp_
Service to move the Mia hand motors to the closed position of the cylindrical grasp.
Definition: ros_driver.h:133
mia_hand::CppDriver::setMrlGraspRef
void setMrlGraspRef(char grasp_id, int16_t rest, int16_t pos, int16_t delay)
Set grasp parameter for MRL flexion motor.
Definition: cpp_driver.cpp:380
mia_hand::ROSDriver::close_lat_grasp_
ros::ServiceServer close_lat_grasp_
Service to move the Mia hand motors to the closed position of the lateral grasp.
Definition: ros_driver.h:135
mia_hand::ROSDriver::check_connection_tmr_
ros::WallTimer check_connection_tmr_
Timer to handle the check of the Mia hand connection status.
Definition: ros_driver.h:63
mia_hand::ROSDriver::sphGraspPercentCallback
void sphGraspPercentCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber sph_grasp_percent_.
Definition: ros_driver.cpp:493
mia_hand::ROSDriver::initSubscribersGrasp
void initSubscribersGrasp()
Initialize subscribers of the automatic grasp info.
Definition: ros_driver.cpp:189
mia_hand::CppDriver::getMotorCur
int16_t getMotorCur(uint8_t fin_id)
Get the current currently absorbed by a specific motor of the Mia hand.
Definition: cpp_driver.cpp:202
mia_hand::ROSDriver::mrl_mot_trgt_pos_
ros::Subscriber mrl_mot_trgt_pos_
Subscriber to receive the target pose of the mrl flexion motor.
Definition: ros_driver.h:74
mia_hand::ROSDriver::thuMotTrgtSpeCallback
void thuMotTrgtSpeCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber thu_mot_trgt_spe_.
Definition: ros_driver.cpp:295
mia_hand::ROSDriver::initSubscribersInd
void initSubscribersInd()
Initialize subscribers of the index flexion motor info.
Definition: ros_driver.cpp:131
mia_hand::ROSDriver::close_sph_grasp_
ros::ServiceServer close_sph_grasp_
Service to move the Mia hand motors to the closed position of the spherical grasp.
Definition: ros_driver.h:136
mia_hand::ROSDriver::open_sph_grasp_
ros::ServiceServer open_sph_grasp_
Service to move the Mia hand motors to the rest position of the spherical grasp.
Definition: ros_driver.h:130
mia_hand::ROSDriver::publish_data_tmr_
ros::WallTimer publish_data_tmr_
Timer to handle the Mia hand data publishing.
Definition: ros_driver.h:62
mia_hand::ROSDriver::mrlMotTrgtPosCallback
void mrlMotTrgtPosCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber mrl_mot_trgt_pos_.
Definition: ros_driver.cpp:450
mia_hand::ROSDriver::latGraspPercentCallback
void latGraspPercentCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber lat_grasp_percent_.
Definition: ros_driver.cpp:486
mia_hand::ROSDriver::disconnectCallback
bool disconnectCallback(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &resp)
Callback of the service disconnect_.
Definition: ros_driver.cpp:529
mia_hand::ROSDriver::openCylGraspCallback
bool openCylGraspCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
Callback of the service open_cyl_grasp_.
Definition: ros_driver.cpp:580
mia_hand::ROSDriver::publishDataTmrCallback
void publishDataTmrCallback(const ros::WallTimerEvent &event)
Callback of the publish_data_tmr_ timer.
Definition: ros_driver.cpp:47
mia_hand::CppDriver::connectToPort
bool connectToPort(uint16_t port_num)
Open serial port used to plug Mia hand.
Definition: cpp_driver.cpp:30
mia_hand::CppDriver::closeGrasp
void closeGrasp(char grasp_id)
Go to closed pose of a grasp type Move all the Mia hand fingers to the closed pose of a specific gras...
Definition: cpp_driver.cpp:284
mia_hand::ROSDriver::thuSphGraspRefCallback
void thuSphGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber thu_sph_grasp_ref_.
Definition: ros_driver.cpp:333
mia_hand::ROSDriver::connectToPortCallback
bool connectToPortCallback(mia_hand_msgs::ConnectSerial::Request &req, mia_hand_msgs::ConnectSerial::Response &resp)
Callback of the service connect_to_port_.
Definition: ros_driver.cpp:507
mia_hand::ROSDriver::disconnect_
ros::ServiceServer disconnect_
Service to disconnect the Mia hand and close the serial port.
Definition: ros_driver.h:120
mia_hand::ROSDriver::switchCurStreamCallback
bool switchCurStreamCallback(std_srvs::SetBool::Request &req, std_srvs::SetBool::Response &resp)
Callback of the service switch_cur_stream_.
Definition: ros_driver.cpp:572
mia_hand::CppDriver::setMotorPos
void setMotorPos(uint8_t fin_id, int16_t mot_pos)
Set the target position of a specific motor of the Mia hand.
Definition: cpp_driver.cpp:60
mia_hand::ROSDriver::mrlTriGraspRefCallback
void mrlTriGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber #mrl_tri_grasp_ref.
Definition: ros_driver.cpp:421
mia_hand::ROSDriver::cyl_grasp_percent_
ros::Subscriber cyl_grasp_percent_
Subscriber to receive the closure percentage for cylindical grasp.
Definition: ros_driver.h:104
mia_hand::CppDriver::setIndGraspRef
void setIndGraspRef(char grasp_id, int16_t rest, int16_t pos, int16_t delay)
Set grasp parameter for Index flexion + thumb abduction motor.
Definition: cpp_driver.cpp:347
mia_hand::ROSDriver::thu_lat_grasp_ref_
ros::Subscriber thu_lat_grasp_ref_
Subscriber to receive the parametrs for lateral grasp for the thumb flexion motor.
Definition: ros_driver.h:92
mia_hand::ROSDriver::ind_tri_grasp_ref_
ros::Subscriber ind_tri_grasp_ref_
Subscriber to receive the parametrs for tridigital grasp for the index flexion motor.
Definition: ros_driver.h:101
mia_hand::ROSDriver::switch_pos_stream_
ros::ServiceServer switch_pos_stream_
Service to manage a the streaming of motor position data sent by the Mia hand.
Definition: ros_driver.h:122
mia_hand::ROSDriver::open_cyl_grasp_
ros::ServiceServer open_cyl_grasp_
Service to move the Mia hand motors to the rest position of the cylindrical grasp.
Definition: ros_driver.h:127
mia_hand::ROSDriver::initSubscribersThu
void initSubscribersThu()
Initialize subscribers of the thumb flexion motor info.
Definition: ros_driver.cpp:102
mia_hand::ROSDriver::open_tri_grasp_
ros::ServiceServer open_tri_grasp_
Service to move the Mia hand motors to the rest position of the tridigital grasp.
Definition: ros_driver.h:131
mia_hand::ROSDriver::initPublishers
void initPublishers()
Initialize publishers.
Definition: ros_driver.cpp:277
mia_hand::ROSDriver::closeCylGraspCallback
bool closeCylGraspCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
Callback of the service close_cyl_grasp_.
Definition: ros_driver.cpp:620
ros_driver.h
mia_hand::ROSDriver::closePinGraspCallback
bool closePinGraspCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
Callback of the service close_pin_grasp_.
Definition: ros_driver.cpp:628
mia_hand::CppDriver::switchCurStream
void switchCurStream(bool b_on_off)
Manage the streaming of the current absorbed by Mi hand motors.
Definition: cpp_driver.cpp:443
mia_hand::ROSDriver::closeLatGraspCallback
bool closeLatGraspCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
Callback of the service close_lat_grasp_.
Definition: ros_driver.cpp:636
mia_hand::ROSDriver::switch_ana_stream_
ros::ServiceServer switch_ana_stream_
Service to manage a the streaming of the analog input data (i.e. force sensor outputs) sent by the Mi...
Definition: ros_driver.h:124
mia_hand::ROSDriver::close_pin_grasp_
ros::ServiceServer close_pin_grasp_
Service to move the Mia hand motors to the closed position of the pinch grasp.
Definition: ros_driver.h:134
mia_hand::ROSDriver::indPinGraspRefCallback
void indPinGraspRefCallback(const mia_hand_msgs::GraspRef::ConstPtr &msg)
Callback of the subscriber ind_pin_grasp_ref_.
Definition: ros_driver.cpp:357
mia_hand::ROSDriver::mot_cur_info_
ros::Publisher mot_cur_info_
Publisher of the current absorbed by the Mia hand motors.
Definition: ros_driver.h:114
mia_hand::CppDriver::setFingerFor
void setFingerFor(uint8_t fin_id, int16_t fin_for)
Set the target force of a specific motor of the Mia hand.
Definition: cpp_driver.cpp:108
mia_hand::ROSDriver::openLatGraspCallback
bool openLatGraspCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
Callback of the service open_lat_grasp_.
Definition: ros_driver.cpp:596
mia_hand::ROSDriver::close_tri_grasp_
ros::ServiceServer close_tri_grasp_
Service to move the Mia hand motors to the closed position of the tridigital grasp.
Definition: ros_driver.h:137
mia_hand::ROSDriver::switchSpeStreamCallback
bool switchSpeStreamCallback(std_srvs::SetBool::Request &req, std_srvs::SetBool::Response &resp)
Callback of the service switch_spe_stream_.
Definition: ros_driver.cpp:556
mia_hand::ROSDriver::thuFinTrgtForCallback
void thuFinTrgtForCallback(const std_msgs::Int16::ConstPtr &msg)
Callback of the subscriber thu_fin_trgt_for_.
Definition: ros_driver.cpp:302
mia_hand::ROSDriver::thu_mot_trgt_pos_
ros::Subscriber thu_mot_trgt_pos_
Subscriber to receive the target pose of the tumb flexion motor.
Definition: ros_driver.h:72
mia_hand::ROSDriver::open_pin_grasp_
ros::ServiceServer open_pin_grasp_
Service to move the Mia hand motors to the rest position of the pinch grasp.
Definition: ros_driver.h:128
mia_hand::ROSDriver::connect_to_port_
ros::ServiceServer connect_to_port_
Service to open a serial port and connect the Mia hand.
Definition: ros_driver.h:119