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
ContactSensor Class Reference

Class for a contact sensor. More...

#include <contactsensor.h>

Inheritance diagram for ContactSensor:
Collaboration diagram for ContactSensor:

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< sensorgetList () 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)
 
TransformgetTransformObject ()
 
- 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< 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...
 

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
 
Primitivereference
 primitive to which the sensor is bound More...
 
SpheresensorBody
 
Transformtransform
 
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< 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

ContactSensor ( bool  binary = true,
double  forcescale = 1,
double  radius = 0.05,
bool  createSphere = false,
bool  colorObject = true,
Color  contactColor = Color(-1,-1,-1) 
)
Parameters
binaryif true then the sensor is 0 or 1 (for contact), no force value returned
forcescalescale of the measured collision force (default: 1)
sizesize of little sphere representing the sensor (if it has an own body) (default: 0.05)
createSphereif true then a little sphere is created otherwise the reference body is directly used
colorObjectif true then the object (sphere or reference) is colored according to contact state
contactColorcolor 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)
~ContactSensor ( )
virtual

Member Function Documentation

double get ( )
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

See Also
characteritic()
int get ( sensor sensors,
int  length 
) const
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.

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

Reimplemented from Sensor.

std::list< sensor > getList ( ) const
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.

virtual int getSensorNumber ( ) const
inlinevirtual

returns the number of sensors values produced by this sensor

Implements Sensor.

Transform * getTransformObject ( )
void init ( Primitive own,
Joint joint = 0 
)
overridevirtual

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.

bool sense ( const GlobalData globaldata)
overridevirtual

performs sense action

Implements Sensor.

void setDepth ( float  depth,
long int  time 
)
virtual
void update ( )
overridevirtual

to update any visual appearance

Reimplemented from Sensor.

Member Data Documentation

bool binary
protected

if contact sensor is a switch

bool colorObject
protected
bool createSphere
protected
double detection
protected

currently detected value

double forcescale
protected
bool initialised
protected
long int lasttimeasked
protected
double lastvalue
protected

last value

Color origColor
protected
Primitive* reference
protected

primitive to which the sensor is bound

Sphere* sensorBody
protected
double size
protected

size of graphical sensor

Color touchColor
protected
Transform* transform
protected
double value
protected

actual sensor value


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