- 1 Control Overview
- 2 Control Modes
- 2.1 Message Definition
- 2.2 Joint Control Fundamentals
- 2.3 Joint Position Control
- 2.4 "Raw" Joint Position Control
- 2.5 Joint Velocity Control
- 2.6 Joint Torque Control
- 2.7 Collision Model
- 2.8 Gravity Compensation Torques
- 2.9 Zero-G mode
- 2.10 JTAS Overview
- 2.11 JTAS Modes
- 2.12 Trajectory Splining
Joint Command Overview
Baxter's arm controls flows through on four layers of operation:
1) User Code running via workstation or SSH (Python Joint Control or Joint Trajectory Action Server or your custom interface)
2) Joint Control Listeners via ROS topic (on Baxter's internal Gentoo Linux PC)
3) RealTime Motor Control Loop (the highest priority process on Baxter's internal Gentoo Linux PC)
4) Joint Control Boards (microcontrollers attached to each arm joint)
The bottom three layers (2-4) are not accessible for user modification because they run on the robot itself and its microcontrollers. Baxter does have three joint control modes for the user to choose from at the top level: position, velocity, and torque control. Each controller has a subset of Motor Controller Plugins associated with them.
By default, all the joint control publishers and subscribers provided by the Baxter SDK run at
100Hz, but can be run up to a rate of
800Hz reliably. See the links for more detailed explanations.
Joint Command Timing
Start to finish, a joint is commanded from the user's python code. This message flows over the ROS network and is picked up by the Joint Control Listeners which store the command for it to be retrieved asynchronously by the RealTime Motor Control Loop once per
1KHz). The command is then sent to the Joint Control Boards (JCB) and executed within the same
1ms timeslot. On the next 1ms cycle, the joint position and spring deflection sensor are read and transferred back to the Joint Control Publisher. The result is read over the ROS network by the user's code. The total timing looks approximately as follows:
1.6ms for the Command to publish over ROS to the Joint Controller over rostopic (via network)
1ms for the Joint Controller Listener to command the Motor Controller (MC), running an async real time loop of 1KHz
1ms for the MC to transfer to the Joint Control Board (JCB) and evaluate the command
1ms for the JCB to read the updated status and give a response to the MC
1ms for the MC to report back to the Joint Controller Publisher
1.6ms for the Joint Controller to publishing the State back over rostopic (via network)
~ 7.2ms total round trip ROS User Publisher to ROS user Subscriber
RealTime Motor Controller
The RealTime Motor Control loop on the robot executes over the course of
1ms, and approximately
700us of this loop is used on average. Occasionally you may find an overrun of the RealTime loop around
100us. This overrun usually does not propagate forward to other cycles because the next loop will likely take
700us. To verify this you can look at the diagnostics messages via "rostopic echo /diagnostics", and look for the "Realtime Control Loop".
The RealTime Motor Controller has plugins that run simultaneously with joint commands. These are Collision Avoidance and Detection, Gravity Compensation and Spring Hysteresis/Crosstalk Compensation. On top of these plugins, when Baxter's cuff pressure sensor is activated, Zero-G enables, allowing the arm to be passively back driven. Upon releasing the cuff, the motor controller returns to the controller it was using previously.
Fundamental to the operation of Baxter via the SDK is a familiarity with the available joint control modes. The joint control modes define the 'modes' in which we can control Baxter's limbs in joint space. These are provided via a ROS message API:(baxter_core_msgs/JointCommand.msg)
To control the limb, we must publish the JointCommand message on the topic:
at a rate > 5hz (by default). The rate at which you must publish your messages is defined on the topic:
of message type std_msgs/Float64
The JointCommand message is defined:
int32 mode float64 command string names int32 POSITION_MODE=1 int32 VELOCITY_MODE=2 int32 TORQUE_MODE=3 int32 RAW_POSITION_MODE=4
This message is subscribed to by the
mode is an integer defining the mode in which the commands will be parsed and commanded to the Joint Controller Boards (JCBs). Available modes are contained with the message [
command is the ordered (corresponding to the
names field) command values.
names is a list of strings containing the joints to command.
Joint Control Fundamentals
When a joint position command is published from the development PC, the '
realtime_loop' process which represents a motor control plugin subscribes to this message. This message is then parsed, and represented in memory based on control mode.
Depending on the control mode, modifications are made to the input commands. These modifications are typically due to the safety controllers (e.g. arm-to-arm collision avoidance, collision detection, etc.)
A control rate timeout is also enforced at this motor controller layer. This states that if a new '
JointCommand' message is not received within the specified timeout (0.2 seconds, or 5Hz), the robot will 'Timeout'. When the robot 'Times out', the current control mode is exited, reverting back to position control mode where the robot will command (hold) it's current joint angles. The reason for this is safety. For example, if controlling in velocity control mode where you are commanding 1.0 Rad/s to joint S0, and you lose network connectivity (someone kicks your router), the robot could result in dangerous motions. By 'timing out', the robot will be safer, reacting to network timeouts, or incorrect control behavior.
This control rate timeout is configurable:
of message type std_msgs/Float64
Joint Position Control
Joint position control mode is the fundamental, basic control mode for Baxter arm motion. In position control mode, we specify joint angles at which we want the joints to achieve. Typically this will be consist of seven values, a commanded position for each of the seven joints, resulting in a full description of the arm configuration.
This joint command is then subscribed to by Baxter's Motor Controller. The motor controller processes this joint command ensuring safety (collision avoidance and detection) and expected behavior by making the following modifications:
"Raw" Joint Position Control
Raw Joint position control mode was introduced to provide a much more direct position control method. The same basic idea as the standard joint position control mode still holds. However, the joint commands are largely left to the JCBs for execution.
The 'raw' joint position commands only perform the following modification (typically these additions are none):
Warning: Advanced Control Mode. As we no longer apply collision avoidance offsets, and allow for very fast motions at the joints velocity limits, this mode can be dangerous. Please use with caution.
Joint Velocity Control
Joint velocity control mode is an advanced control mode. In velocity control mode, we specify joint velocities at which we want the joints to simultaneously achieve. Typically this will be consist of seven values, a commanded velocity for each of the seven joints.
This joint command is then subscribed to by Baxter's Motor Controller. The motor controller processes this joint velocity command (applying collision avoidance and detection) and expected behavior by making the following modifications:
Note: When commanding joint velocities, if a commanded velocity to one of the joints will result in a joint position that is beyond the joints limits, no joints will be commanded, as all of the command is considered invalid. Reason we do this; an example of a common control method, using the Jacobian for Cartesian control resulting in joint velocity commands. If a single joint hits its limit, the rest of the joints will still be commanded, resulting in obscure and potentially dangerous motions. We recommend either implementing a joint space potential field or joint limit check before submitting the joint velocity commands.
Warning: Advanced Control Mode. As we allow for very fast joint velocity up to the joint velocity limits, this mode can be dangerous. Please use with caution.
Joint Torque Control
Joint torque control mode is an advanced control mode. In torque control mode, we specify joint torques at which we want the joints to simultaneously achieve. Typically this will be consist of seven values, a commanded torque for each of the seven joints.
This joint command is then subscribed to by Baxter's Motor Controller. The motor controller processes this joint torque command and expected behavior by making the following modifications, taking special note of the absence of collision avoidance and detection modules:
Note: As shown in the above image, joint torque commands are applied in addition to gravity and spring compensation torques. This default can be disabled by publishing an std_msgs/Empty message on the topic:
/robot/limb/right/suppress_gravity_compensation at a rate > 5Hz.
Warning: Advanced Control Mode. When commanding in torque control mode, access is granted to the lowest control levels. This puts much responsibility on the control program and can be dangerous. Please use with caution.
There are a total of three levels of collision models in baxter.
As in the figure above, each of Baxter's link has its own collision block which is slightly bigger than the size of that link. When these block comes into contact with each other, collision avoidance model is triggered. The collision blocks can be visualized in RVIZ by setting the Robot Description field under RobotModel as "/robot/armnav_robot_description" and enabling the field Collision Enabled.
The next collision model involves the detection of two types of collisions - impact and squish. Impact is detected when a sudden change in torque is sensed across any of the joint. This can be related to a scenario in which a moving hand collides with a human. Here, the sudden change in torque is sensed during the impact and the robot comes to a stop for 2 seconds before attempting to move again. Squish is detected when joint tries to press against a stationary object. For instance, when a robot arm tries to push a wall, the torque applied across the joint increases and it immediately stops when the applied torque is greater than a threshold. It resumes its motion after 2 seconds.
The rethink log records these information.
2014-05-14T14:45:37.883-0400 INFO (/collision/right/joint_collision_estimator_right,JointCollisionEstimator.cpp:374) impact: 1.380773 > 0.850000, largest contributor: right_w0, with value: 0.651761
This log information indicates that an impact was detected when the torque applied across the right_w0 joint is greater than 0.85 Nm. Similarly the corresponding message logged for squish is
2014-05-14T14:48:31.723-0400 INFO (/collision/right/joint_collision_estimator_right,JointCollisionEstimator.cpp:395) squish on Cartesian dimension 0 - 16.177, 16.000
The final collision model is high speed scaling. This is to avoid the collisions between two limbs moving at higher speeds. The collision blocks for this purpose is higher than the orginal collision blocks. The collision detection happens when the speed of the limb in cartesian space is higher than 0.2 m/s. In order to avoid the collision, the corresponding velocities are scaled down and converted back as position commands.
To disable the collision avoidance on a given arm, you need to publish an empty message at greater than 5hz to thhe topic,
For eg, the command to suppress collision avoidance on the left arm would be:
$ rostopic pub /robot/limb/left/suppress_collision_avoidance std_msgs/Empty -r 10
The collision avoidance will stay suppressed as long as this is being published
Gravity Compensation Torques
In order to oppose the effect of gravitational force acting across Baxter's arm, gravity compensation torques have to be applied across that arm. This is a basic mode that is active from the time the robot is enabled. The built-in gravity compensating model uses KDL for calculating the gravity compensation torques. The springs attached to the S1 joint also require compensation torques, these are found using an internal spring model and applied in conjunction with the torques from KDL. These gravity compensation torques are passed directly to the JCB through a separate channel and are applied irrespective of the controller being active.
The gravity compensation torques are available via the topic
robot/limb/<side>/gravity_compensation_torques of message type
$ rostopic echo robot/limb/<left/right>/gravity_compensation_torques' of message type baxter_core_msgs/SEAJointState
In order to disable the gravity compensation torques, an empty message should be published to the topic
/robot/limb/<side>/suppress_gravity_compensation at greater than 5 Hz.
$ rostopic pub -r 10 /robot/limb/<side>/suppress_gravity_compensation std_msgs/Empty
The fields of the Gravity Compensation Torques message:
commanded_position: Commanded Position from RealTime Loop commanded_velocity: Commanded Velocity from RealTime Loop commanded_effort: Commanded Effort from RealTime Loop. In torque control mode this will be the torques you commanded. In position control mode this is the integral effort applied achieving the goal positions. actual_position: Measured Position from RealTime Loop actual_velocity: Measured Velocity from RealTime Loop actual_effort: Measured Effort from RealTime Loop via the Spring Deflection Sensors in each Series Elastic Actuator gravity_model_effort: Gravity Compensation Torques Commanded hysteresis_model_effort: Spring Compensation Torques Commanded. This is the hysterisis effort applied to account for spring joint s1 crosstalk_model_effort: Joint Crosstalk Compensation. Present here is minimal compensation for joint s1 crosstalk caused by the arm's downstream joints hystState: A variable used in calculating the hysteresis model.
Zero-G mode can often be confused with the mode obtained by disabling the gravity compensation torques. By default, the gravity compensation torques will always be applied when the robot is enabled. In Zero-G mode, the controllers are disabled and so the arm can be freely moved across. In this case, the effect of gravity would be compensated by the gravity compensation model applying gravity compensation torques across the joints, there would be no torques from the controllers since they would not be active, and so the arm can be moved freely around, hence the name.
The Zero-G mode can be enabled by grasping the cuff over its groove as below,
Unlike the gravity compensation model, the Zero-G mode cannot be directly disabled. The cuff interaction has to be disabled in order to disable the Zero-G. Publishing an empty message to the topic
/robot/limb/<side>/suppress_cuff_interaction at greater than 5Hz, disabled the cuff interaction.
rostopic pub -r 10 /robot/limb/<side>/suppress_cuff_interaction std_msgs/Empty
Baxter's SDK comes equipped with Joint Trajectory Action Server (JTAS) to facilitate users needing to command either (or both) of Baxter's arms through multiple waypoints. These waypoints are supplied as positions, velocities, and/or accelerations for every joint in Baxter's arms. These waypoints are accompanied by a desired timeframe within which the trajectory must complete. The main benefit of this server is its ability to interpolate between supplied waypoints, command Baxter's joints accordingly, and ensure the trajectory is being followed within a specified tolerance. To read more about JTA Servers in general, please see the ROS Wiki page on Joint Trajectory Action. To jump straight to the source code, see the baxter_interface JTAS page on GitHub.
The JTAS has three modes: Velocity, Position, and Raw Position, which are invoked as arguments when calling the action server:
rosrun baxter_interface joint_trajectory_action_server.py
- Velocity Mode (
- Position Mode (
- Inverse Dynamics Feed Forward Position Mode (default mode)
This mode executes direct control of trajectories by calculating and commanding the velocities required to move the arm through a set of joint positions at a specified time. The end result is fast, but less accurate movement.
This mode allows for simple trajectory execution of position-only trajectories. This mode is significantly more accurate than velocity mode, at a cost of a speed reduction.
Inverse Dynamics Feed Forward Position Mode (using Raw Position Mode)
This mode can allow for the highest speed movement with the most accuracy. By supplying desired Positions, Velocities, and Accelerations for each joint, you give Baxter to anticipate and correct for the dynamics of its movement by "feeding forward" Velocities and Accelerations to the Motor Controller. This enables Baxter to use both feedback from its spring deflection sensors, and feed forward from dynamics of the anticipated trajectory to accurately execute trajectories.
This mode accepts trajectories with Position, Velocity, and/or Acceleration supplied for each joint. Position is required, but Velocity and Acceleration are optional. Supplying Position alone will give you movement very similar to regular Position mode. If the optional Velocities and Accelerations are supplied, they are splined together with Position, and then commanded over the /robot/inverse_dynamics topic. MoveIt! supplies these three dimensions by default, so it is highly recommended that you use this mode when using that motion planner.
In all three modes, sparse points are supplied for each joint, and it is the JTAS' responsibility to interpolate these points in their supplied dimension space into an executable trajectory. This is accomplished through the Bezier Library. Cubic Bezier Splines are calculated for each segment of two points in the trajectory for Position and Velocity and Acceleration (if the latter are supplied). The the tangents of the trajectories must match between segments in all supplied dimensions. Please see this project description by Professor Jean Gallier for an in depth explanation of these Bezier Curves in 2D. Keep in mind, this work was extended to accommodate three dimensions in case Position, Velocity and Acceleration are all supplied.