Klamp't
0.9.0
|
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>
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 |
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.
|
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.
|
inlinevirtual |
Updates the internal measurement vector. Should be overridden to correctly restore state using ReadState(), or to visualize a physical robot's sensors.
Reimplemented in Klampt::IMUSensor, Klampt::CameraSensor, Klampt::TimeDelayedSensor, Klampt::GyroSensor, Klampt::ForceTorqueSensor, Klampt::FilteredSensor, Klampt::DriverTorqueSensor, Klampt::TiltSensor, Klampt::CorruptedSensor, Klampt::JointVelocitySensor, Klampt::ContactSensor, Klampt::LaserRangeSensor, Klampt::Accelerometer, Klampt::TransformedSensor, and Klampt::JointPositionSensor.
|
virtual |
Set a named setting. Returns false if the name is not supported, or the value is formatted incorrectly
Reimplemented in Klampt::IMUSensor, Klampt::CameraSensor, Klampt::TimeDelayedSensor, Klampt::GyroSensor, Klampt::ForceTorqueSensor, Klampt::FilteredSensor, Klampt::DriverTorqueSensor, Klampt::TiltSensor, Klampt::CorruptedSensor, Klampt::JointVelocitySensor, Klampt::ContactSensor, Klampt::LaserRangeSensor, Klampt::Accelerometer, Klampt::TransformedSensor, and Klampt::JointPositionSensor.