Struct robot_interfaces::NJointAction¶
-
template<size_t N>
struct NJointAction : public robot_interfaces::Loggable, public robot_interfaces::Loggable Action of a generic n-joint robot.
This action type can be used for all n-joint robots that expect torque or position commands on joint-level.
- Template Parameters:
N – Number of joints.
Public Functions
-
template<class Archive>
inline void serialize(Archive &archive)
-
inline virtual std::vector<std::string> get_name() override
-
inline virtual std::vector<std::vector<double>> get_data() override
-
inline NJointAction(Vector torque = Vector::Zero(), Vector position = None(), Vector position_kp = None(), Vector position_kd = None())
Create action with desired torque and (optional) position.
The resulting torque command sent to the robot is
To disable the position controller, set the target position to NaN. The controller is executed joint-wise, so it is possible to run it only for some joints by setting a target position for these joints and setting the others to NaN.sent_torque = torque + PD(position)
The specified torque is always added to the result of the position controller, so if you only want to run the position controller, make sure to set
torque
to zero for all joints.For more explicit code, the static factory methods
Torque
,Position
,TorqueAndPosition
andZero
should be used instead directly creating actions through this constructor.- Parameters:
torque – Desired torque.
position – Desired position. Set values to NaN to disable position controller for the corresponding joints
position_kp – P-gains for the position controller. Set to NaN to use default values.
position_kd – D-gains for the position controller. Set to NaN to use default values.
-
template<class Archive>
inline void serialize(Archive &archive)
-
inline virtual std::vector<std::string> get_name() override
-
inline virtual std::vector<std::vector<double>> get_data() override
-
inline NJointAction(Vector torque = Vector::Zero(), Vector position = None(), Vector position_kp = None(), Vector position_kd = None())
Create action with desired torque and (optional) position.
The resulting torque command sent to the robot is
To disable the position controller, set the target position to NaN. The controller is executed joint-wise, so it is possible to run it only for some joints by setting a target position for these joints and setting the others to NaN.sent_torque = torque + PD(position)
The specified torque is always added to the result of the position controller, so if you only want to run the position controller, make sure to set
torque
to zero for all joints.For more explicit code, the static factory methods
Torque
,Position
,TorqueAndPosition
andZero
should be used instead directly creating actions through this constructor.- Parameters:
torque – Desired torque.
position – Desired position. Set values to NaN to disable position controller for the corresponding joints
position_kp – P-gains for the position controller. Set to NaN to use default values.
position_kd – D-gains for the position controller. Set to NaN to use default values.
Public Members
-
Vector torque
Desired torque command (in addition to position controller).
-
Vector position
Desired position. Set to NaN to disable position controller.
-
Vector position_kp
P-gain for position controller. If NaN, default is used.
-
Vector position_kd
D-gain for position controller. If NaN, default is used.
Public Static Functions
-
static inline NJointAction Torque(Vector torque)
Create an action that only contains a torque command.
- Parameters:
torque – Desired torque.
- Returns:
Pure “torque action”.
-
static inline NJointAction Position(Vector position, Vector kp = None(), Vector kd = None())
Create an action that only contains a position command.
- Parameters:
position – Desired position.
kp – P-gain for position controller. If not set, default is used. Set to NaN for specific joints to use default for this joint.
kd – D-gain for position controller. If not set, default is used. Set to NaN for specific joints to use default for this joint.
- Returns:
Pure “position action”.
-
static inline NJointAction TorqueAndPosition(Vector torque, Vector position, Vector position_kp = None(), Vector position_kd = None())
Create an action with both torque and position commands.
- Parameters:
torque – Desired torque.
position – Desired position. Set to NaN for specific joints to disable position control for this joint.
kp – P-gain for position controller. If not set, default is used. Set to NaN for specific joints to use default for this joint.
kd – D-gain for position controller. If not set, default is used. Set to NaN for specific joints to use default for this joint.
- Returns:
Action with both torque and position commands.
-
static inline NJointAction Zero()
Create a zero-torque action.
- Returns:
Zero-torque action with position control disabled.
-
static inline Vector None()
Create a NaN-Vector.
Helper function to set defaults for position.
- Returns:
Vector with all elements set to NaN.
-
static inline NJointAction Torque(Vector torque)
Create an action that only contains a torque command.
- Parameters:
torque – Desired torque.
- Returns:
Pure “torque action”.
-
static inline NJointAction Position(Vector position, Vector kp = None(), Vector kd = None())
Create an action that only contains a position command.
- Parameters:
position – Desired position.
kp – P-gain for position controller. If not set, default is used. Set to NaN for specific joints to use default for this joint.
kd – D-gain for position controller. If not set, default is used. Set to NaN for specific joints to use default for this joint.
- Returns:
Pure “position action”.
-
static inline NJointAction TorqueAndPosition(Vector torque, Vector position, Vector position_kp = None(), Vector position_kd = None())
Create an action with both torque and position commands.
- Parameters:
torque – Desired torque.
position – Desired position. Set to NaN for specific joints to disable position control for this joint.
kp – P-gain for position controller. If not set, default is used. Set to NaN for specific joints to use default for this joint.
kd – D-gain for position controller. If not set, default is used. Set to NaN for specific joints to use default for this joint.
- Returns:
Action with both torque and position commands.
-
static inline NJointAction Zero()
Create a zero-torque action.
- Returns:
Zero-torque action with position control disabled.
-
static inline Vector None()
Create a NaN-Vector.
Helper function to set defaults for position.
- Returns:
Vector with all elements set to NaN.
Public Static Attributes
-
static constexpr size_t num_joints = N
Number of joints.