Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Sensor Class Referenceabstract

Abstract class for sensors that can be plugged into a robot. More...

#include <sensor.h>

Inheritance diagram for Sensor:
Collaboration diagram for Sensor:

Public Types

enum  Dimensions {
  X = 1, Y = 2, Z = 4, XY = X | Y,
  XZ = X | Z, YZ = Y | Z, XYZ = X | Y | Z
}
 defines which dimensions should be sensed. The meaning is sensor specific. More...
 
- Public Types inherited from SensorMotorInfoAble
typedef std::function
< std::string(int)> 
NamingFunction
 function that returns the name given the index More...
 

Public Member Functions

 Sensor ()
 
virtual ~Sensor ()
 
virtual void init (Primitive *own, Joint *joint=0)=0
 initialises sensor with a body of robot and optionally with a joint. More...
 
virtual bool sense (const GlobalData &globaldata)=0
 performs sense action More...
 
virtual int getSensorNumber () const =0
 returns the number of sensors values produced by this sensor More...
 
virtual std::list< sensorgetList () const =0
 returns a list of sensor values (usually in the range [-1,1] ) This function should be overloaded. More...
 
virtual std::list
< SensorMotorInfo
getSensorInfos () const
 returns a list of sensor infos ( More...
 
virtual void update ()
 to update any visual appearance More...
 
virtual int get (sensor *sensors, int length) const
 writes the sensor values (usually in the range [-1,1] ) into the given sensor array and returns the number of sensors written. More...
 
std::list< sensorgetListOfArray () const
 helper function for performance implementation of list<> get() based on array-get More...
 
- Public Member Functions inherited from SensorMotorInfoAble
 SensorMotorInfoAble ()
 
void setBaseName (const std::string &basename)
 
void setBaseInfo (const SensorMotorInfo &baseinfo)
 
SensorMotorInfo getBaseInfo ()
 
void setNamingFunc (const NamingFunction &func)
 
NamingFunction getNamingFunc () const
 
void setNames (const std::vector< std::string > &names)
 set names explicitly (basename is anyway suffixed) More...
 
std::string getName (int index) const
 returns the name of a single item. Typically called from within Sensor and Motor class. More...
 
std::list< SensorMotorInfogetInfos (int number) const
 get all infos. More...
 

Static Public Member Functions

static std::list< sensorselectrows (const matrix::Matrix &m, short dimensions)
 selects the rows specified by dimensions (X->0, Y->1, Z->2) More...
 
static int selectrows (sensor *sensors, int length, const matrix::Matrix &m, short dimensions)
 selects the rows specified by dimensions (X->0, Y->1, Z->2) More...
 
static Dimensions parseSensorDimension (char *str)
 
static std::string dimensions2String (short dimensions)
 
- Static Public Member Functions inherited from SensorMotorInfoAble
static std::string defaultNameing (int index)
 the default implementation is for index==0: basename, otherwise basename + (index+1) More...
 

Additional Inherited Members

- Protected Attributes inherited from SensorMotorInfoAble
NamingFunction func
 
SensorMotorInfo baseinfo
 

Detailed Description

Abstract class for sensors that can be plugged into a robot.

Member Enumeration Documentation

enum Dimensions

defines which dimensions should be sensed. The meaning is sensor specific.

Enumerator
X 
Y 
Z 
XY 
XZ 
YZ 
XYZ 

Constructor & Destructor Documentation

Sensor ( )
inline
virtual ~Sensor ( )
inlinevirtual

Member Function Documentation

static std::string dimensions2String ( short  dimensions)
inlinestatic
virtual int get ( sensor sensors,
int  length 
) const
inlinevirtual

writes the sensor values (usually in the range [-1,1] ) into the given sensor array and returns the number of sensors written.

A default implementation based on get() is provided. Only if performance matters overwrite this function.

Parameters
sensorscall by refernce array which received the values
lengthcapacity of sensors array
Returns
number of sensor values written

Reimplemented in PositionCameraSensor, OpticalFlow, TwoAxisServo, DirectCameraSensor, OneAxisServo, RaySensor, ContactSensor, CameraSensor, SoundSensor, AxisOrientationSensor, SpeedSensor, AngularMotor, TorqueSensor, IRSensor, and RaySensorBank.

virtual std::list<sensor> getList ( ) const
pure virtual

returns a list of sensor values (usually in the range [-1,1] ) This function should be overloaded.

If performance matters, implement get(double*, int) and use getListOfArray to implement this.

Implemented in TwoAxisServo, CameraSensor, RaySensor, ContactSensor, OneAxisServo, SoundSensor, AxisOrientationSensor, SpeedSensor, IRSensor, AngularMotor, RaySensorBank, TorqueSensor, RelativePositionSensor, and DerivativeSensor.

std::list<sensor> getListOfArray ( ) const
inline

helper function for performance implementation of list<> get() based on array-get

virtual std::list<SensorMotorInfo> getSensorInfos ( ) const
inlinevirtual

returns a list of sensor infos (

See Also
SensorMotorInfoAble how to change the names etc)
virtual int getSensorNumber ( ) const
pure virtual
virtual void init ( Primitive own,
Joint joint = 0 
)
pure virtual

initialises sensor with a body of robot and optionally with a joint.

This is usually done by the robot itself (or using the Attachment())

Implemented in TwoAxisServoVel, AngularMotorNAxis, OneAxisServoVel, AngularMotor3AxisEuler, AngularMotor2Axis, AngularMotor1Axis, TwoAxisServo, RaySensor, ContactSensor, CameraSensor, OneAxisServo, SoundSensor, AxisOrientationSensor, SpeedSensor, TorqueSensor, AngularMotor, RaySensorBank, RelativePositionSensor, RangeFinder, and DerivativeSensor.

static Dimensions parseSensorDimension ( char *  str)
inlinestatic
static std::list<sensor> selectrows ( const matrix::Matrix m,
short  dimensions 
)
inlinestatic

selects the rows specified by dimensions (X->0, Y->1, Z->2)

static int selectrows ( sensor sensors,
int  length,
const matrix::Matrix m,
short  dimensions 
)
inlinestatic

selects the rows specified by dimensions (X->0, Y->1, Z->2)

virtual void update ( )
inlinevirtual

to update any visual appearance

Reimplemented in RaySensor, ContactSensor, CameraSensor, and RaySensorBank.


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