![]() |
NimbRo ROS Soccer Package
|
Implements a single actuator of a given data type. More...
#include <behaviour_actuators.h>
Public Member Functions | |
Actuator (ActuatorManager *AMBase, const std::string &signalName=nullString, bool aggregatable=AGGREGATABLE) | |
Default constructor. More... | |
virtual | ~Actuator () |
Actuator object destructor. | |
virtual const std::type_info * | getTypeInfo () const |
Update callback for the ActuatorBase object. Refer to the default override defined in Actuator::update() . More... | |
virtual bool | isCompatibleWith (const SensorBase *SBase) const |
Abstract callback that should evaluate whether the current actuator is compatible the sensor SBase (can be bound to it). Refer to the default override Actuator::isCompatibleWith() . | |
const T & | read () const |
Get function for the current data contained in the actuator. | |
void | write (const T &newdata, const Behaviour *BBase) |
General purpose write function to be used by behaviours to write to non-aggregatable actuators. Do not use this function on aggregatable actuators. | |
void | writeAgg (const T &newdata, const Behaviour *BBase) |
General purpose write function to be used by behaviours to write to aggregatable actuators. Do not use this function on non-aggregatable actuators. | |
void | writeHard (const T &newdata) |
Special write function that can be used during initialisation to set up the value of an actuator. This is the only write function that can be used by an interface layer, as the other two variants require the passing of a pointer to the source behaviour (and interface layers can't have child behaviours). | |
bool | wasWrittenTo () const |
Returns whether the actuator has been written to since the last update (update() is called at the beginning of each step). | |
![]() | |
ActuatorBase (ActuatorManager *AMBase, const std::string &signalName=nullString) | |
Default constructor. More... | |
virtual | ~ActuatorBase () |
ActuatorBase object destructor. | |
std::string | getUniqueName (const ActuatorManager *AMBase) const |
Returns a unique actuator name. More... | |
ActuatorBase * | getBasePtr () |
Return a pointer to the underlying ActuatorBase object in the case of a derived actuator class. | |
Public Attributes | |
const bool | aggregatable |
Flag that specifies whether the actuator is aggregatable. | |
const std::type_info *const | typeInfo |
The type information of the actuator data type. | |
![]() | |
BehaviourManager *const | MBase |
Pointer to the parent behaviour manager. | |
BehaviourLayer *const | LBase |
Pointer to the parent behaviour layer. | |
ActuatorManager *const | AMBase |
Pointer to the parent actuator manager. | |
const std::string | signalName |
The name of the actuator, used as the lookup key for the BehaviourManager::findActuator() function. | |
Additional Inherited Members | |
![]() | |
static const std::string | DEF_ACTUATOR_SIGNAL_NAME = "Actuator" |
Default actuator signal name used to generate a unique one, in the case that no name is provided by a derived actuator class. | |
Implements a single actuator of a given data type.
This class is used to define the actuators of an ActuatorManager. The template parameter specifies the desired data type of the actuator.
The template type T must have a default constructor that initialises the data to an equivalent of 'zero', and it must have a well-defined operator=
that performs a deep copy of the data. Both of these criteria are satisfied for native types. Note that if an actuator is not written to within a cycle, it retains its value from the previous iteration.
In order for an actuator to be able to be aggregatable, the template type T must satisfy two additional properties. Firstly, there must be a multiplication operator defined between it and a level_t (a floating point type, generally float
), and secondly there must be an addition operator defined between two objects of type T. To make an actuator aggregatable, simply pass AGGREGATABLE as the third parameter of the Actuator constructor.
|
explicit |
Default constructor.
Note that although the default value for the signalName
parameter is nullString
, this will not actually become the actuator's name if the parameter is omitted. This is just used to signal to the class's internals that it should generate a default name.
AMBase | A pointer to the actuator manager that the actuator belongs to. |
signalName | The unique human-friendly name to give the actuator (null means auto-generate). This name is used by the sensor classes to look up and bind to the correct actuators. The name can be completely arbitrary, with the only restriction being that it can't be the null string, but recommended sample names include "ThisLayer/ActuatorName" and "Layer1/TargetX" , where ThisLayer and Layer1 are sample names of the layer that owns the actuator being constructed, and ActuatorName and TargetX are sample actuator-specific names. |
aggregatable | A boolean flag specifying whether the actuator values are intended to be aggregatable or not. Aggregatable actuators automatically calculate a running weighted average during a step if they are written to multiple times by different behaviours. Non-aggregatable actuators just use the last value that was written to them. Multiple writes to a non-aggregatable actuator during a single step should always be avoided, as it is then not clear which value ends up being used (although this is a deterministic selection of course). |
|
inlinevirtual |
Update callback for the ActuatorBase object. Refer to the default override defined in Actuator::update()
.
Abstract callback that should be overridden to return the type information of the actuator (i.e. a std::type_info
object). Refer to the default override Actuator::getTypeInfo()
.
Implements behaviourcontrol::ActuatorBase.