Klamp't  0.9.0
Public Member Functions | Public Attributes | List of all members
Klampt::SensorBase Class Reference

A sensor base class. A SensorBase should allow a Controller to both connect to a simulation as well as a real sensor. More...

#include <Sensor.h>

Inheritance diagram for Klampt::SensorBase:
Klampt::Accelerometer Klampt::CameraSensor Klampt::ContactSensor Klampt::CorruptedSensor Klampt::DriverTorqueSensor Klampt::FilteredSensor Klampt::ForceTorqueSensor Klampt::GyroSensor Klampt::IMUSensor Klampt::JointPositionSensor Klampt::JointVelocitySensor Klampt::LaserRangeSensor Klampt::TiltSensor Klampt::TimeDelayedSensor Klampt::TransformedSensor

Public Member Functions

virtual const char * Type () const
 
virtual void Simulate (SimRobotController *robot, Simulator *sim)
 Called whenever the sensor is updated from the simulaton.
 
virtual void SimulateKinematic (RobotModel &robot, WorldModel &world)
 Updates the sensor for a kinematic world. Useful for non-simulation debugging.
 
virtual void Advance (double dt)
 Advances to the next time step with duration dt elapsed.
 
virtual void Reset ()
 Should be overridden if the sensor is stateful to reset to an initial state.
 
virtual bool ReadState (File &f)
 
virtual bool WriteState (File &f) const
 
virtual void MeasurementNames (vector< string > &names) const
 Must be overridden to produce a list of names of each measurement.
 
virtual void GetMeasurements (vector< double > &values) const
 Must be overridden to returns a list of all measurements.
 
virtual void SetMeasurements (const vector< double > &values)
 
virtual void GetInternalState (vector< double > &state) const
 Any other state besides measurements/settings that you might want to store. Used in ReadState.
 
virtual void SetInternalState (const vector< double > &state)
 Any other state besides measurements/settings that you might want to store. Used in WriteState.
 
virtual map< string, string > Settings () const
 Returns a map of all current name-value pairs of the sensor's settings.
 
virtual bool GetSetting (const string &name, string &str) const
 Get a named setting. Returns false if the name is not supported.
 
virtual bool SetSetting (const string &name, const string &str)
 
virtual void DrawGL (const RobotModel &robot, const vector< double > &measurements)
 

Public Attributes

string name
 
double rate
 
bool enabled
 

Detailed Description

A sensor base class. A SensorBase should allow a Controller to both connect to a simulation as well as a real sensor.

The mapping from simulation -> SensorBase is given by the Simulate and Advance calls which are called immediately in succession.

The mapping from a sensor to this structure can be given by the SetMeasurements function.

Default settings:

FOR IMPLEMENTERS: at a minimum, you must overload the Type(), MeasurementNames and Get/SetMeasurements methods. (Note: it is important that GetMeasurements is idempotent and does not change internal state.)

If the sensor simulator manages any internal state, such as a state estimate, then you will also need to override Get/SetInternalState in order for the simulator state to be properly saved and loaded during rewind/replay. If you want the simulator to be resettable, you will need to overload Reset() to reset the state when necessary.

If your sensor is reconfigurable, you will want to also override the Settings and Get/SetSetting methods. The macros FILL_SENSOR_SETTING, GET_SENSOR_SETTING, and SET_SENSOR_SETTING are helpful for doing this.

Member Function Documentation

virtual void Klampt::SensorBase::DrawGL ( const RobotModel robot,
const vector< double > &  measurements 
)
inlinevirtual

If the sensor can be drawn, draw the sensor on the robot's current configuration, using these measurements, using OpenGL calls.

Reimplemented in Klampt::CameraSensor, Klampt::TimeDelayedSensor, Klampt::ForceTorqueSensor, Klampt::FilteredSensor, Klampt::CorruptedSensor, Klampt::ContactSensor, Klampt::LaserRangeSensor, and Klampt::TransformedSensor.

virtual void Klampt::SensorBase::SetMeasurements ( const vector< double > &  values)
inlinevirtual
virtual bool Klampt::SensorBase::SetSetting ( const string &  name,
const string &  str 
)
virtual

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