NTRT Simulator
Version: Master
|
#include <tgSensor.h>
Inherited by tgCompoundRigidSensor, tgRodSensor, and tgSpringCableActuatorSensor.
Public Member Functions | |
tgSensor (tgSenseable *pSens) | |
virtual | ~tgSensor () |
virtual std::vector< std::string > | getSensorDataHeadings ()=0 |
virtual std::vector< std::string > | getSensorData ()=0 |
Protected Attributes | |
tgSenseable * | m_pSens |
This class defines methods for use with sensors. Any individual sensor (ex., a tgRodSensor) will need to re-implement both of these methods. Note that we make everything pure virtual here to force re-definition. Sensing data from objects occurs in two places in the NTRTsim workflow. First, when setting up the simulation, a heading for the data is given. This describes the data that will be returned. Second, when the simulation is running, the data itself can be taken. Note that it's up to the caller (e.g., a tgDataLogger2) to match up the headings with the data.
Definition at line 49 of file tgSensor.h.
tgSensor::tgSensor | ( | tgSenseable * | pSens | ) |
This constructor takes a pointer to a sense-able object. Note that this creates complications with casting: in child classes, this pointer will need to be casted to the particular type of sense-able object that a sensor works on. The reason why we declare it here as a pointer to the parent class is for setup reasons: we want a tgDataLogger2 to be able to ask this class, "Can you sense a particular tgSenseable?". The way to do that is to pass in a pointer of the parent type, and attempt a cast to the child type via a call to tgCast.
This cpp file only implements the constructor for tgSensor. Note that tgSensor is an abstract class with two pure virtual member functions, so you cannot instantiate a tgSensor. However, a constructor is provided here for ease of managing pointers in child classes. The shorthand syntax for variable assignment is used here. "m_pSens" stands for "my pointer to a tgSenseable object."
Definition at line 43 of file tgSensor.cpp.
|
virtual |
A class with virtual member functions must have a virtual destructor.
Definition at line 51 of file tgSensor.cpp.
|
pure virtual |
Return the data from this class itself. Note that this MUST have the same number of elements as is returned by the getDataHeading function.
Implemented in tgCompoundRigidSensor, tgRodSensor, and tgSpringCableActuatorSensor.
|
pure virtual |
Create a descriptive heading for all the data that this class can return. This will be a vector of strings, with each string being a heading. Headings should have the following form: The type of sensor, then an open parenthesis "(" and the tags of the specific tgSenseable object, then a ")." and a label for the specific field that will be output in that row. For example, if sensor will be sensing a rod with tags "t4 t5", its label for the X position might be "rod(t4 t5).X"
Implemented in tgCompoundRigidSensor, tgRodSensor, and tgSpringCableActuatorSensor.
|
protected |
This class stores a pointer to its tgSenseable object. Note that it is protected so that subclasses can access it, but children will still need to cast it against their specific type of tgSenseable (e.g., rod, cable, etc.)
Definition at line 102 of file tgSensor.h.