NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgSensor Class Referenceabstract

#include <tgSensor.h>

Inherited by tgCompoundRigidSensor, tgRodSensor, and tgSpringCableActuatorSensor.

Collaboration diagram for tgSensor:

Public Member Functions

 tgSensor (tgSenseable *pSens)
 
virtual ~tgSensor ()
 
virtual std::vector< std::string > getSensorDataHeadings ()=0
 
virtual std::vector< std::string > getSensorData ()=0
 

Protected Attributes

tgSenseablem_pSens
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

tgSensor::~tgSensor ( )
virtual

A class with virtual member functions must have a virtual destructor.

Definition at line 51 of file tgSensor.cpp.

Member Function Documentation

virtual std::vector<std::string> tgSensor::getSensorData ( )
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.

Returns
a list of strings, each being a piece of sensor data, in the same order as the headings.

Implemented in tgCompoundRigidSensor, tgRodSensor, and tgSpringCableActuatorSensor.

virtual std::vector<std::string> tgSensor::getSensorDataHeadings ( )
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"

Returns
a list of strings, each being a descriptive heading for a specific piece of data that will be returned.

Implemented in tgCompoundRigidSensor, tgRodSensor, and tgSpringCableActuatorSensor.

Member Data Documentation

tgSenseable* tgSensor::m_pSens
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.


The documentation for this class was generated from the following files: