#include <dynamixel_interface_controller.h>
Public Member Functions | |
DynamixelInterfaceController () | |
double | getLoopRate (void) |
bool | initialise () |
void | loop (void) |
bool | parseParameters (void) |
~DynamixelInterfaceController () | |
Destructor, deletes the objects holding the serial ports and disables the motors if required. More... | |
Private Member Functions | |
bool | initialiseDynamixel (PortInfo &port, DynamixelInfo &dynamixel) |
bool | initialisePort (PortInfo &port) |
void | jointStateCallback (const sensor_msgs::JointState::ConstPtr &joint_commands) |
void | multiThreadedIO (PortInfo &port, sensor_msgs::JointState &read_msg, dynamixel_interface::DataPorts &dataport_msg, dynamixel_interface::ServoDiags &status_msg, bool perform_write) const |
void | multiThreadedRead (PortInfo &port, sensor_msgs::JointState &read_msg, dynamixel_interface::DataPorts &dataports_msg, dynamixel_interface::ServoDiags &diags_msg) const |
void | multiThreadedWrite (PortInfo &port, sensor_msgs::JointState joint_commands) const |
bool | parsePortInformation (XmlRpc::XmlRpcValue ports) |
bool | parseServoInformation (PortInfo &port, XmlRpc::XmlRpcValue servos) |
Private Attributes | |
ros::Timer | broadcast_timer_ |
Timer that controls the rate of the IO callback. More... | |
DynamixelControlMode | control_type_ |
uint | dataport_counter_ = 0 |
counter for tracking dataport rate More... | |
uint | dataport_iters_ = 0 |
publish when dataport_counter_ == this More... | |
ros::Publisher | dataport_publisher_ |
Publishes the data from the external ports on dynamixel_pros. More... | |
double | dataport_rate_ |
Rate at which the pro external dataport is read. More... | |
ros::Publisher | debug_publisher_ |
Debug message publisher. More... | |
uint | diagnostics_counter_ = 0 |
Counter for tracking diagnostics rate. More... | |
uint | diagnostics_iters_ = 0 |
publish when diagnostic_counter_ == this More... | |
ros::Publisher | diagnostics_publisher_ |
Publishes joint states from reads. More... | |
double | diagnostics_rate_ |
Desired rate at which servo diagnostic information is published. More... | |
std::vector< PortInfo > | dynamixel_ports_ |
method of control (position/velocity/torque) More... | |
double | global_max_vel_ |
global joint speed limit More... | |
double | global_torque_limit_ |
global joint torque limit More... | |
bool | ignore_input_velocity_ |
can set driver to ignore profile velocity commands in position mode More... | |
bool | initialised_ = false |
Bool indicating if we are ready for operation. More... | |
ros::Publisher | joint_state_publisher_ |
Publishes joint states from reads. More... | |
ros::Subscriber | joint_state_subscriber_ |
Gets joint states for writes. More... | |
double | loop_rate_ |
Desired loop rate (joint states are published at this rate) More... | |
std::unique_ptr< ros::NodeHandle > | nh_ |
Handler for the ROS Node. More... | |
bool | parameters_parsed_ = false |
method of control (position/velocity/torque) More... | |
bool | read_dataport_ |
Bool for telling threads to read dataport data. More... | |
bool | read_diagnostics_ |
Bool for telling threads to read diagnostics data. More... | |
int | recv_queue_size_ = 1 |
Receive queue size for desired_joint_states topic. More... | |
bool | stop_motors_on_shutdown_ |
Indicates if the motors should be turned off when the controller stops. More... | |
sensor_msgs::JointState | write_msg_ |
Stores the last message received from the write command topic. More... | |
std::mutex | write_mutex_ |
Mutex for write_msg, as there are potentially multiple threads. More... | |
bool | write_ready_ = false |
Booleans indicating if we have received commands. More... | |
This class forms a ROS Node that provides an interface with the dynamixel series of servos. The controller functions on a timer based callback for updating the motor states. Commands are Continuously sent to the motor and updated via callback once new messages are published to the command Topic. This class also provides a threaded interface for controlling multiple sets of dynamixels simultaneously and synchronously through different serial ports. This allows robots with many motors to reduce the overall IO time required for control.
Definition at line 148 of file dynamixel_interface_controller.h.
dynamixel_interface::DynamixelInterfaceController::DynamixelInterfaceController | ( | ) |
Constructor, loads the motor configuration information from the specified yaml file and intialises The motor states.
Definition at line 104 of file dynamixel_interface_controller.cpp.
dynamixel_interface::DynamixelInterfaceController::~DynamixelInterfaceController | ( | ) |
Destructor, deletes the objects holding the serial ports and disables the motors if required.
Definition at line 111 of file dynamixel_interface_controller.cpp.
|
inline |
Gets the target loop rate for the controller
Definition at line 174 of file dynamixel_interface_controller.h.
bool dynamixel_interface::DynamixelInterfaceController::initialise | ( | ) |
Initialises the controller, performing the following steps:
Definition at line 571 of file dynamixel_interface_controller.cpp.
|
private |
Initialises the dynamixel. Pings the given id to make sure it exists, then loads it's model information and sets up the relevant registers
[in] | port | the port for this dynamixel |
[in] | dynamixel | the dynamixel to intialise |
Initialises the dynamixel. Pings the given id to make sure it exists, then loads it's model information and sets up the relevant registers
Definition at line 711 of file dynamixel_interface_controller.cpp.
|
private |
Initialises the port, opening the driver, and validating all dynamixels
[in] | port | the port object to initialise |
Initialises the port, opening the driver, and validating all dynamixels
Definition at line 607 of file dynamixel_interface_controller.cpp.
|
private |
Callback for recieving a command from the /desired_joint_state topic. The function atomically updates the class member variable containing the latest message and sets a flag indicating a new message has been received
[in] | joint_commands | the command received from the topic |
Definition at line 883 of file dynamixel_interface_controller.cpp.
void dynamixel_interface::DynamixelInterfaceController::loop | ( | void | ) |
main loop for performing IO, handles the creation and joining of IO threads for each port, so that IO for multiple usb devices can be threaded.
Definition at line 958 of file dynamixel_interface_controller.cpp.
|
private |
Top level control function for each port's IO thread.
[in] | port | the port for this thread to perform IO on |
[out] | read_msg | the JointState this threads joint data is read into |
[out] | dataport_msg | the DataPorts msg this thread reads dataport data into |
[out] | status_msgs | the ServoDiags msg this thread reads diagnostic data into |
[in] | perform_write | whether we are writing data this iteration |
Definition at line 1105 of file dynamixel_interface_controller.cpp.
|
private |
Function in thread to perform read on a port.
[in] | port | the port for this thread to perform IO on |
[out] | read_msg | the JointState this threads joint data is read into |
[out] | dataport_msg | the DataPorts msg this thread reads dataport data into |
[out] | status_msgs | the ServoDiags msg this thread reads diagnostic data into |
Definition at line 1374 of file dynamixel_interface_controller.cpp.
|
private |
Function called in each thread to perform a write on a port
[in] | port_num | index used to retrieve port information from port list |
[in] | joint_commands | message cointaining the commands for each joint |
Definition at line 1123 of file dynamixel_interface_controller.cpp.
bool dynamixel_interface::DynamixelInterfaceController::parseParameters | ( | void | ) |
Parses param information from the rosparam server
don't parse parameters during operation
Definition at line 131 of file dynamixel_interface_controller.cpp.
|
private |
Parses the information in the yaml file for each port
[in] | ports | the xml structure to be parsed |
Parses the information in the yaml file for each port
[in] | ports | the xml structure to be parsed |
don't parse parameters during operation
Definition at line 267 of file dynamixel_interface_controller.cpp.
|
private |
Parses the information in the yaml file for each servo
[out] | port | the port object to parse the servo info into |
[out] | servos | the xml structure to be parsed |
Parses the information in the yaml file for each servo
[in] | port | the port object to parse the servo info into |
[in] | servos | the xml structure to be parsed |
don't parse parameters during operation
Definition at line 420 of file dynamixel_interface_controller.cpp.
|
private |
Timer that controls the rate of the IO callback.
Definition at line 248 of file dynamixel_interface_controller.h.
|
private |
Definition at line 260 of file dynamixel_interface_controller.h.
|
private |
counter for tracking dataport rate
Definition at line 257 of file dynamixel_interface_controller.h.
|
private |
publish when dataport_counter_ == this
Definition at line 258 of file dynamixel_interface_controller.h.
|
private |
Publishes the data from the external ports on dynamixel_pros.
Definition at line 245 of file dynamixel_interface_controller.h.
|
private |
Rate at which the pro external dataport is read.
Definition at line 273 of file dynamixel_interface_controller.h.
|
private |
Debug message publisher.
Definition at line 246 of file dynamixel_interface_controller.h.
|
private |
Counter for tracking diagnostics rate.
Definition at line 252 of file dynamixel_interface_controller.h.
|
private |
publish when diagnostic_counter_ == this
Definition at line 253 of file dynamixel_interface_controller.h.
|
private |
Publishes joint states from reads.
Definition at line 244 of file dynamixel_interface_controller.h.
|
private |
Desired rate at which servo diagnostic information is published.
Definition at line 272 of file dynamixel_interface_controller.h.
|
private |
method of control (position/velocity/torque)
Definition at line 234 of file dynamixel_interface_controller.h.
|
private |
global joint speed limit
Definition at line 268 of file dynamixel_interface_controller.h.
|
private |
global joint torque limit
Definition at line 269 of file dynamixel_interface_controller.h.
|
private |
can set driver to ignore profile velocity commands in position mode
Definition at line 266 of file dynamixel_interface_controller.h.
|
private |
Bool indicating if we are ready for operation.
Definition at line 263 of file dynamixel_interface_controller.h.
|
private |
Publishes joint states from reads.
Definition at line 243 of file dynamixel_interface_controller.h.
|
private |
Gets joint states for writes.
Definition at line 241 of file dynamixel_interface_controller.h.
|
private |
Desired loop rate (joint states are published at this rate)
Definition at line 271 of file dynamixel_interface_controller.h.
|
private |
Handler for the ROS Node.
Definition at line 232 of file dynamixel_interface_controller.h.
|
private |
method of control (position/velocity/torque)
Bool indicating if we have parsed parameters
Definition at line 262 of file dynamixel_interface_controller.h.
|
private |
Bool for telling threads to read dataport data.
Definition at line 256 of file dynamixel_interface_controller.h.
|
private |
Bool for telling threads to read diagnostics data.
Definition at line 251 of file dynamixel_interface_controller.h.
|
private |
Receive queue size for desired_joint_states topic.
Definition at line 274 of file dynamixel_interface_controller.h.
|
private |
Indicates if the motors should be turned off when the controller stops.
Definition at line 265 of file dynamixel_interface_controller.h.
|
private |
Stores the last message received from the write command topic.
Definition at line 236 of file dynamixel_interface_controller.h.
|
private |
Mutex for write_msg, as there are potentially multiple threads.
Definition at line 238 of file dynamixel_interface_controller.h.
|
private |
Booleans indicating if we have received commands.
Definition at line 239 of file dynamixel_interface_controller.h.