Module: MJActuator
-
class MJActuatorObject : public MJObject<mjsActuator>
- #include <MJActuator.h>
A class representing a MuJoCo actuator object.
MuJoCo actuators, and thus also
MJActuatorObject
, are single-input single-output. This means that the force/torque produced by the actuator is determined by a single degree of freedom. However, in simulation we usually want to control force and torque along multiple dimensions. Thus, we useMJActuator
, which is a collection ofMJActuatorObject
.This class wraps a MuJoCo actuator object and provides functionality to update its control value.
Public Functions
-
void updateCtrl(mjData *data, double value)
Updates the control value of the actuator in the simulation data.
- Parameters:
data – Pointer to the MuJoCo simulation data.
value – The control value to set.
-
void updateCtrl(mjData *data, double value)
-
class MJActuator
- #include <MJActuator.h>
Base class representing a MuJoCo actuator.
This class represents a general actuator composed of one or more
MJActuatorObject
instances. It provides methods for configuring the actuator and updating its control values.MJActuatorObject
and MuJoCo actuators are single-input single-output, which means that they can be controlled with only one degree of freedom. For convenience, subclasses ofMJActuator
represent a useful collection of these 1-dof actuators. SeeMJSingleActuator
,MJForceActuator
,MJTorqueActuator
, andMJForceTorqueActuator
.Subclassed by MJForceActuator, MJForceTorqueActuator, MJSingleActuator, MJTorqueActuator
Public Functions
-
inline MJActuator(std::string name, std::vector<MJActuatorObject> &&subActuators)
Constructs an MJActuator with a specified name and actuator objects.
- Parameters:
name – The name of the actuator.
subActuators – A vector of
MJActuatorObject
representing the individual actuator parts.
-
MJActuator(const MJActuator&) = delete
-
MJActuator(MJActuator&&) = delete
-
MJActuator &operator=(const MJActuator&) = delete
-
MJActuator &operator=(MJActuator&&) = delete
-
inline virtual ~MJActuator()
Virtual destructor for MJActuator.
-
inline const std::string &getName()
Gets the name of the actuator.
- Returns:
The name of the actuator.
-
void configure(const mjModel *model)
Configures the actuator within a given MuJoCo model.
- Parameters:
model – Pointer to the MuJoCo model used for configuration.
-
void updateCtrl(mjData *data)
Updates the control value of the actuator(s) in the MuJoCo data.
- Parameters:
data – Pointer to the MuJoCo simulation data.
-
virtual std::vector<double> readControlMessages() = 0
Reads control messages for the actuator.
This pure virtual function must be implemented by derived classes to read specific control messages.
- Returns:
A vector of control values.
Protected Attributes
-
std::string name
The name of the actuator.
-
std::vector<MJActuatorObject> subActuators
The individual actuator objects.
-
inline MJActuator(std::string name, std::vector<MJActuatorObject> &&subActuators)
-
class MJSingleActuator : public MJActuator
- #include <MJActuator.h>
Class representing a 1-degree-of-freedom actuator.
This actuator type has 1 control degree of freedom. This can be useful to represent forces applied to linear joints, torques applied to revolute joints, or forces/torques applied along a fixed direction.
This class is designed to handle one
SingleActuatorMsgPayload
message to control the force / torque magnitude applied.Public Functions
-
virtual std::vector<double> readControlMessages() override
Reads control messages for a single actuator.
- Returns:
A vector containing the control value.
-
inline MJActuator(std::string name, std::vector<MJActuatorObject> &&subActuators)
Use the same constructor as MJActuator
-
MJActuator(const MJActuator&) = delete
Use the same constructor as MJActuator
-
MJActuator(MJActuator&&) = delete
Use the same constructor as MJActuator
Public Members
-
ReadFunctor<SingleActuatorMsgPayload> actuatorInMsg
Functor to read actuator control messages.
-
virtual std::vector<double> readControlMessages() override
-
class MJForceActuator : public MJActuator
- #include <MJActuator.h>
Class representing an actuator that can exert an arbitrary force vector.
This actuator has 3 degrees of freedom. To achieve this, it’s composed of three 1-degree-of-freedom
MJActuatorObject
, each applying a force along perpendicular directions.This class is designed to handle one
ForceAtSiteMsgPayload
message to control the force vector applied.Public Functions
-
virtual std::vector<double> readControlMessages() override
Reads force control messages for the actuator.
- Returns:
A vector containing the force control values.
-
inline MJActuator(std::string name, std::vector<MJActuatorObject> &&subActuators)
Use the same constructor as MJActuator
-
MJActuator(const MJActuator&) = delete
Use the same constructor as MJActuator
-
MJActuator(MJActuator&&) = delete
Use the same constructor as MJActuator
Public Members
-
ReadFunctor<ForceAtSiteMsgPayload> forceInMsg
Functor to read force control messages.
-
virtual std::vector<double> readControlMessages() override
-
class MJTorqueActuator : public MJActuator
- #include <MJActuator.h>
Class representing an actuator that can exert an arbitrary torque vector.
This actuator has 3 degrees of freedom. To achieve this, it’s composed of three 1-degree-of-freedom
MJActuatorObject
, each applying a torque along perpendicular directions.This class is designed to handle one
TorqueAtSiteMsgPayload
message to control the torque vector applied.Public Functions
-
virtual std::vector<double> readControlMessages() override
Reads torque control messages for the actuator.
- Returns:
A vector containing the torque control values.
-
inline MJActuator(std::string name, std::vector<MJActuatorObject> &&subActuators)
Use the same constructor as MJActuator
-
MJActuator(const MJActuator&) = delete
Use the same constructor as MJActuator
-
MJActuator(MJActuator&&) = delete
Use the same constructor as MJActuator
Public Members
-
ReadFunctor<TorqueAtSiteMsgPayload> torqueInMsg
Functor to read torque control messages.
-
virtual std::vector<double> readControlMessages() override
-
class MJForceTorqueActuator : public MJActuator
- #include <MJActuator.h>
Class representing an actuator that can exert an arbitrary force and torque vectors.
This actuator has 6 degrees of freedom. To achieve this, it’s composed of size 1-degree-of-freedom
MJActuatorObject
, each applying a force and torque along perpendicular directions.This class is designed to handle one
ForceAtSiteMsgPayload
and oneTorqueAtSiteMsgPayload
messages to control the force and torque vectors applied.Public Functions
-
virtual std::vector<double> readControlMessages() override
Reads force and torque control messages for the actuator.
- Returns:
A vector containing the force and torque control values.
-
inline MJActuator(std::string name, std::vector<MJActuatorObject> &&subActuators)
Use the same constructor as MJActuator
-
MJActuator(const MJActuator&) = delete
Use the same constructor as MJActuator
-
MJActuator(MJActuator&&) = delete
Use the same constructor as MJActuator
Public Members
-
ReadFunctor<ForceAtSiteMsgPayload> forceInMsg
Functor to read force control messages.
-
ReadFunctor<TorqueAtSiteMsgPayload> torqueInMsg
Functor to read torque control messages.
-
virtual std::vector<double> readControlMessages() override