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

This CameraSensor calculates the position of the visible object(s) that is essentially the center of gravity of the image. More...

#include <camerasensors.h>

Inheritance diagram for PositionCameraSensor:
Collaboration diagram for PositionCameraSensor:

Public Types

enum  ValueTypes { None = 0, Position = 1, Size = 2, SizeChange = 4 }
 additional sensor values. More...
 
- 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...
 

Public Member Functions

 PositionCameraSensor (PositionCameraSensorConf conf=getDefaultConf())
 The camera image should be black and white (e.g. More...
 
virtual void setNamesIntern (std::vector< std::string > &names)
 sets the names of the sensors and starts with the given names (for subclasses) More...
 
virtual ~PositionCameraSensor ()
 
virtual void intern_init ()
 overload this function to initialized you data structures. More...
 
virtual bool sense (const GlobalData &globaldata)
 Performs the calculations. More...
 
virtual int getSensorNumber () const
 overload this function and return the number of sensor values More...
 
virtual int get (sensor *sensors, int length) const
 overload this function and return the sensor values More...
 
- Public Member Functions inherited from CameraSensor
 CameraSensor ()
 Creates a camera sensor. More...
 
virtual ~CameraSensor ()
 
virtual void setInitData (Camera *camera, const OdeHandle &odeHandle, const OsgHandle &osgHandle, const osg::Matrix &pose)
 sets the initial data structures like the camera. More...
 
virtual void setPose (const osg::Matrix &pose)
 changes the relative pose of the camera More...
 
virtual osg::Matrix getPose ()
 relative pose of the camera More...
 
virtual void init (Primitive *own, Joint *joint=0)
 this function initialized the camera (no need to overload) (Sensor interface) More...
 
virtual void update ()
 we update the camera's visual appearance More...
 
virtual std::list< sensorgetList () const
 this is implemented based on get(sensor*,int) 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...
 

Static Public Member Functions

static PositionCameraSensorConf getDefaultConf ()
 
- 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...
 

Protected Member Functions

virtual bool processAndFillData (double &x, double &y, double &size, int &k)
 process sensor information and fills More...
 

Static Protected Member Functions

static bool calcImgCOG (const osg::Image *img, double &x, double &y, double &size, int threshold=1)
 calculates the Center of Gravity (normalized to -1 to 1) of an image. More...
 

Protected Attributes

PositionCameraSensorConf conf
 
int num
 
sensordata
 
double oldsize
 
- Protected Attributes inherited from CameraSensor
Cameracamera
 
OdeHandle odeHandle
 
OsgHandle osgHandle
 
osg::Matrix pose
 
bool isInitDataSet
 
- Protected Attributes inherited from SensorMotorInfoAble
NamingFunction func
 
SensorMotorInfo baseinfo
 

Detailed Description

This CameraSensor calculates the position of the visible object(s) that is essentially the center of gravity of the image.

The position in normalized to -1 to 1. Probably you want to use an image processor like ColorFilterImgProc before.

Member Enumeration Documentation

enum ValueTypes

additional sensor values.

Size is the size of the object (only one value, independent of the dimensions

Enumerator
None 
Position 
Size 
SizeChange 

Constructor & Destructor Documentation

The camera image should be black and white (e.g.

See Also
BWImageProcessor or ColorFilterImgProc)
CameraSensor for further parameter explanation.
Parameters
valuessensor values to compute (
See Also
PositionCameraSensor::ValueTypes)
Parameters
dimsdimensions to return the position (X means horizonal, Y vertical)
borderif >0 then the size and sizechange are zero if position is that far (border) away from image border
virtual ~PositionCameraSensor ( )
inlinevirtual

Member Function Documentation

static bool calcImgCOG ( const osg::Image *  img,
double &  x,
double &  y,
double &  size,
int  threshold = 1 
)
inlinestaticprotected

calculates the Center of Gravity (normalized to -1 to 1) of an image.

As a bonus it also calculates the sum of all pixels (normalizes to 0-2.5) in size

Returns
false if image is too dark
virtual int get ( sensor sensors,
int  length 
) const
inlinevirtual

overload this function and return the sensor values

Implements CameraSensor.

static PositionCameraSensorConf getDefaultConf ( )
inlinestatic
virtual int getSensorNumber ( ) const
inlinevirtual

overload this function and return the number of sensor values

Implements CameraSensor.

virtual void intern_init ( )
inlinevirtual

overload this function to initialized you data structures.

Use camera->getImage() to get the image from the camera

Implements CameraSensor.

virtual bool processAndFillData ( double &  x,
double &  y,
double &  size,
int &  k 
)
inlineprotectedvirtual

process sensor information and fills

virtual bool sense ( const GlobalData globaldata)
inlinevirtual

Performs the calculations.

Implements CameraSensor.

Reimplemented in MotionCameraSensor.

virtual void setNamesIntern ( std::vector< std::string > &  names)
inlinevirtual

sets the names of the sensors and starts with the given names (for subclasses)

Member Data Documentation

PositionCameraSensorConf conf
protected
sensor* data
protected
int num
protected
double oldsize
protected

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