Robot Simulator of the Robotics Group for Self-Organization of Control
0.8.0
|
Class for a contact sensor. More...
#include <contactsensor.h>
Public Member Functions | |
ContactSensor (bool binary=true, double forcescale=1, double radius=0.05, bool createSphere=false, bool colorObject=true, Color contactColor=Color(-1,-1,-1)) | |
virtual | ~ContactSensor () |
virtual double | get () |
returns the sensor value in the range >=0; 0 means nothing no contact >0 means contact with another object: size is the force in arbitrary unit More... | |
virtual void | init (Primitive *own, Joint *joint=0) override |
initialises sensor with a body of robot and optionally with a joint. More... | |
virtual int | getSensorNumber () const |
returns the number of sensors values produced by this sensor More... | |
virtual bool | sense (const GlobalData &globaldata) override |
performs sense action More... | |
virtual int | get (sensor *sensors, int length) const override |
writes the sensor values (usually in the range [-1,1] ) into the given sensor array and returns the number of sensors written. More... | |
virtual std::list< sensor > | getList () const override |
returns a list of sensor values (usually in the range [-1,1] ) This function should be overloaded. More... | |
virtual void | update () override |
to update any visual appearance More... | |
virtual void | setDepth (float depth, long int time) |
Transform * | getTransformObject () |
Public Member Functions inherited from PhysicalSensor | |
PhysicalSensor () | |
virtual | ~PhysicalSensor () |
virtual void | setInitData (const OdeHandle &odeHandle, const OsgHandle &osgHandle, const osg::Matrix &pose) |
sets the initial data structures More... | |
virtual void | setPose (const osg::Matrix &pose) |
changes the relative pose of the sensor More... | |
virtual osg::Matrix | getPose () |
relative pose of the sensor More... | |
Public Member Functions inherited from Sensor | |
Sensor () | |
virtual | ~Sensor () |
virtual std::list < SensorMotorInfo > | getSensorInfos () const |
returns a list of sensor infos ( More... | |
std::list< sensor > | getListOfArray () 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< SensorMotorInfo > | getInfos (int number) const |
get all infos. More... | |
Protected Attributes | |
bool | binary |
if contact sensor is a switch More... | |
double | forcescale |
double | detection |
currently detected value More... | |
double | value |
actual sensor value More... | |
double | lastvalue |
last value More... | |
double | size |
size of graphical sensor More... | |
long int | lasttimeasked |
Primitive * | reference |
primitive to which the sensor is bound More... | |
Sphere * | sensorBody |
Transform * | transform |
bool | createSphere |
bool | colorObject |
Color | origColor |
Color | touchColor |
bool | initialised |
Protected Attributes inherited from PhysicalSensor | |
OdeHandle | odeHandle |
OsgHandle | osgHandle |
osg::Matrix | pose |
bool | isInitDataSet |
Protected Attributes inherited from SensorMotorInfoAble | |
NamingFunction | func |
SensorMotorInfo | baseinfo |
Additional Inherited Members | |
Public Types inherited from Sensor | |
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... | |
Static Public Member Functions inherited from Sensor | |
static std::list< sensor > | selectrows (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... | |
Class for a contact sensor.
The sensor is on if a collision occurs and stores the penetration depth (as a crude measure for the colission force). It can be either attached to an existing primitive (e.g. a leg) or create its own sensor object. The latter is recommended if you want very localized force sensors. The information of a collision comes to the sensor via the collision callback of the substance used for the primitive. The sensor returns the maximum forces since the last sense() call.
ContactSensor | ( | bool | binary = true , |
double | forcescale = 1 , |
||
double | radius = 0.05 , |
||
bool | createSphere = false , |
||
bool | colorObject = true , |
||
Color | contactColor = Color(-1,-1,-1) |
||
) |
binary | if true then the sensor is 0 or 1 (for contact), no force value returned |
forcescale | scale of the measured collision force (default: 1) |
size | size of little sphere representing the sensor (if it has an own body) (default: 0.05) |
createSphere | if true then a little sphere is created otherwise the reference body is directly used |
colorObject | if true then the object (sphere or reference) is colored according to contact state |
contactColor | color if contact sensor values is 1. In between it is blend with original color. If a channel is negative: use original color and invert those channels that are negative. (default: (-1,-1,-1) : invert all channels) |
|
virtual |
|
virtual |
returns the sensor value in the range >=0; 0 means nothing no contact >0 means contact with another object: size is the force in arbitrary unit
|
overridevirtual |
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.
sensors | call by refernce array which received the values |
length | capacity of sensors array |
Reimplemented from Sensor.
|
overridevirtual |
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.
Implements Sensor.
|
inlinevirtual |
returns the number of sensors values produced by this sensor
Implements Sensor.
Transform * getTransformObject | ( | ) |
initialises sensor with a body of robot and optionally with a joint.
This is usually done by the robot itself (or using the Attachment())
Implements Sensor.
|
overridevirtual |
performs sense action
Implements Sensor.
|
virtual |
|
overridevirtual |
to update any visual appearance
Reimplemented from Sensor.
|
protected |
if contact sensor is a switch
|
protected |
|
protected |
|
protected |
currently detected value
|
protected |
|
protected |
|
protected |
|
protected |
last value
|
protected |
|
protected |
primitive to which the sensor is bound
|
protected |
|
protected |
size of graphical sensor
|
protected |
|
protected |
|
protected |
actual sensor value