dynamixel_hardware_interface.cpp
Go to the documentation of this file.
2 
3 #include <stdexcept>
4 #include <limits>
5 
6 #include <math.h>
7 
8 /* Written by: Dorian Goepp (https://github.com/resibots/dynamixel_control_hw/) */
9 /* Edited by: Max Svetlik (https://github.com/svenzvarobotics/) */
10 
11 namespace dynamixel {
13  {}
14 
16  {
17  }
18 
20  {
21  _prev_commands.resize(6, 0.0);
22  _joint_commands.resize(6, 0.0);
23  _joint_angles.resize(6, 0.0);
24  _joint_velocities.resize(6, 0.0);
25  _joint_efforts.resize(6, 0.0);
26  try {
27 
28  for (unsigned i = 0; i < 6; i++) {
29 
30  std::string j_name = "joint_" + std::to_string(i+1);
31  // tell ros_control the in-memory address where to read the
32  // information on joint angle, velocity and effort
34  j_name,
35  &_joint_angles[i],
37  &_joint_efforts[i]);
39  // tell ros_control the in-memory address to change to set new
40  // position goal for the actuator
43  &_joint_commands[i]);
45 
46  }
47 
48  // register the hardware interfaces
51 
52  }
53  catch (const ros::Exception& e) {
54  ROS_ERROR_STREAM("Could not initialize hardware interface:\n\tTrace: " << e.what());
55  throw e;
56  }
57 
58  // At startup robot should keep the pose it has
59  ros::spinOnce();
60 
61  for (unsigned i = 0; i < 6; i++) {
63  }
64  }
65 
73  void DynamixelHardwareInterface::read_joints(sensor_msgs::JointState js)
74  {
75  for (unsigned i=0; i < 6; i++){
76  _joint_angles[i] = js.position[i];
77  _joint_efforts[i] = js.effort[i];
78  _joint_velocities[i] = js.velocity[i];
79  }
80 
81  }
82 
89  {
91  return _joint_commands;
92  }
93 }
hardware_interface::JointStateInterface _jnt_state_interface
void registerHandle(const JointStateHandle &handle)
JointStateHandle getHandle(const std::string &name)
#define ROS_ERROR_STREAM(args)
hardware_interface::EffortJointInterface _jnt_effort_interface
ROSCPP_DECL void spinOnce()


svenzva_drivers
Author(s): Max Svetlik
autogenerated on Wed Oct 28 2020 03:31:27