joint_limits_interface Documentation

joint_limits_interface

Interface for enforcing joint limits.

joint_limits_interface contains data structures for representing joint limits, methods for populating them from common formats such as URDF and rosparam, and methods for enforcing limits on different kinds of joint commands.

The joint_limits_interface is not used by controllers themselves (it does not implement a HardwareInterface) but instead operates after the controllers have updated, in the write() method (or equivalent) of the robot abstraction. Enforcing limits will overwrite the commands set by the controllers, it does not operate on a separate raw data buffer.

Code API

There are two main elements involved in setting up a joint_limits_interface:

Joint limits representation

  • JointLimits Position, velocity, acceleration, jerk and effort.
  • SoftJointLimits Soft position limits, k_p, k_v (as described here ).
  • Convenience methods for loading joint limits information (only position, velocity, effort), as well as soft joint limits information from the URDF.
  • Convenience methods for loading joint limits from ROS parameter server (all values). Parameter specification is the same used in MoveIt, with the addition that we also parse jerk and effort limits.

Joint limits interface

For effort-controlled joints, position-controlled joints, and velocity-controlled joints, two types of interfaces have been created. The first is a saturation interface, used for joints that have normal limits but not soft limits. The second is an interface that implements soft limits, similar to the one used on the PR2.

Examples

Joint limits representation

The first example shows the different ways of populating joint limits data structures.

#include <ros/ros.h>
int main(int argc, char** argv)
{
// Init node handle and URDF model
std::shared_ptr<urdf::ModelInterface> urdf;
// ...initialize contents of urdf
// Data structures
// Manual value setting
limits.has_velocity_limits = true;
limits.max_velocity = 2.0;
// Populate (soft) joint limits from URDF
// Limits specified in URDF overwrite existing values in 'limits' and 'soft_limits'
// Limits not specified in URDF preserve their existing values
urdf::JointConstSharedPtr urdf_joint = urdf->getJoint("foo_joint");
const bool urdf_limits_ok = getJointLimits(urdf_joint, limits);
const bool urdf_soft_limits_ok = getSoftJointLimits(urdf_joint, soft_limits);
// Populate (soft) joint limits from the ros parameter server
// Limits specified in the parameter server overwrite existing values in 'limits' and 'soft_limits'
// Limits not specified in the parameter server preserve their existing values
const bool rosparam_limits_ok = getJointLimits("foo_joint", nh, limits);
}

A joint limits specification in YAML format that can be loaded to the ROS parameter server can be found here.

Joint limits interface

The second example integrates joint limits enforcing into an existing robot hardware implementation.

using namespace hardware_interface;
class MyRobot
{
public:
MyRobot() {}
bool init()
{
// Populate pos_cmd_interface_ with joint handles...
// Get joint handle of interest
JointHandle joint_handle = pos_cmd_interface_.getHandle("foo_joint");
JointLimits limits;
SoftJointLimits soft_limits;
// Populate with any of the methods presented in the previous example...
// Register handle in joint limits interface
PositionJointSoftLimitsHandle handle(joint_handle, // We read the state and read/write the command
limits, // Limits spec
soft_limits) // Soft limits spec
jnt_limits_interface_.registerHandle(handle);
}
void read(ros::Time time, ros::Duration period)
{
// Read actuator state from hardware...
// Propagate current actuator state to joints...
}
void write(ros::Time time, ros::Duration period)
{
// Enforce joint limits for all registered handles
// Note: one can also enforce limits on a per-handle basis: handle.enforceLimits(period)
jnt_limits_interface_.enforceLimits(period);
// Propagate joint commands to actuators...
// Send actuator command to hardware...
}
private:
PositionJointInterface pos_cmd_interface_;
PositionJointSoftLimitsInterface jnt_limits_interface_;
};
joint_limits_interface::JointLimits::max_velocity
double max_velocity
Definition: joint_limits.h:40
joint_limits_interface::JointLimits
Definition: joint_limits.h:36
joint_limits_interface.h
ros.h
joint_limits_interface::getJointLimits
bool getJointLimits(const std::string &joint_name, const ros::NodeHandle &nh, JointLimits &limits)
Populate a JointLimits instance from the ROS parameter server.
Definition: joint_limits_rosparam.h:75
joint_limits_urdf.h
joint_limits_interface::PositionJointSoftLimitsHandle
A handle used to enforce position and velocity limits of a position-controlled joint.
Definition: joint_limits_interface.h:160
main
int main(int argc, char **argv)
hardware_interface
joint_limits_rosparam.h
joint_limits.h
joint_limits_interface::JointLimits::has_velocity_limits
bool has_velocity_limits
Definition: joint_limits.h:46
hardware_interface::JointHandle
ros::Time
urdf
joint_limits_interface::PositionJointSoftLimitsInterface
Definition: joint_limits_interface.h:582
init
void init(const M_string &remappings)
hardware_interface::PositionJointInterface
joint_limits_interface::SoftJointLimits
Definition: joint_limits.h:53
joint_limits_interface::getSoftJointLimits
bool getSoftJointLimits(const std::string &joint_name, const ros::NodeHandle &nh, SoftJointLimits &soft_limits)
Populate a SoftJointLimits instance from the ROS parameter server.
Definition: joint_limits_rosparam.h:194
ros::Duration
ros::NodeHandle


joint_limits_interface
Author(s): Adolfo Rodriguez Tsouroukdissian
autogenerated on Mon Oct 12 2020 03:09:39