Robot Simulator of the Robotics Group for Self-Organization of Control: Component Class Reference

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Component Class Reference

This is the abstract base class of the component system. More...

`#include <component.h>`

Inherits OdeRobot.

Inherited by AtomComponent, PrimitiveComponent, RobotComponent, and SimpleComponent.

Inheritance diagram for Component:

[legend]
Collaboration diagram for Component:

[legend]
List of all members.

## Public Member Functions
| Component (const OdeHandle &odeHandle, const OsgHandle &osgHandle, const ComponentConf &conf)
| ~Component ()
virtual int | getSensorNumber ()
| Returns number of sensors; recursivly adding of the number of sensors all subcomponents and the robots of all Subcomponents.
virtual int | getMotorNumber ()
| returns number of motors; recursivly adding of the number of sensors all subcomponents; at the moment only counts Hinge-, Slider-, Hinge2 and Universal-Joints; The Motor-Numbers of the robots of the Components is not counted.
virtual int | getSensors (sensor *sensors, int sensornumber)
| Use this, to get all sensor values of all the joints of all subcomponents, and the sensors of all robots, belonging to all subcompionents.
virtual void | setMotors (const motor *motors, int motornumber)
| Sets the motor values for the joints connecting the component with its subcomponents, an recursivly the joints of all subComponents.
virtual void | resetMotorsRecursive ()
| This sets all motors in the component structure to zero, starting from this component.
virtual void | update ()=0
| update the OSG notes here
virtual void | place (const Pos &pos)=0
| sets the vehicle to position pos
virtual bool | collisionCallback (void *data, dGeomID o1, dGeomID o2)
virtual void | doInternalStuff (const GlobalData &globalData)
virtual Position | getPosition () const =0
| returns position of the object
virtual double | getDistanceToComponent (Component *comp)
| Gets the distance between two components.
virtual osg::Vec3 | getPositionbetweenComponents (Component *component)
| This is only a simple function, calculating the coordinates of the point exactly between two directly connected components.
virtual Primitive * | getMainPrimitive () const =0
| return reference to the simple Primitive, or to the main Primitive of the robot assigend to the component.
virtual int | getNumberSubcomponents ()
| Gets the Number of subcomponents of this component.
virtual int | getNumberSubcomponentsAll ()
| Gets the Number of all Subcomponents recursivly connected.
virtual void | addSubcomponent (Component *newsubcomponent, Joint *newconnectingjoint, bool softlink)
| This method adds an existing Component as a subcomponent to this component.
virtual Component * | removeSubcomponent (int removedsubcomponentnumber)
| This method removes an existing Component as a subcomponent of this component.
virtual Component * | removeSubcomponent (Component *removedsubcomponent)
| This method removes an existing Component as a subcomponent of this component.
virtual void | removeAllSubcomponentsRecursive ()
| This removes all subcomponents of THIS component, and all their subcomponents, till the whole structure is destroyed.
virtual void | updateOriginsRecursive (Component *parent)
| This updates the origin references within the component tree.
virtual void | removeSoftlinksRecursive ()
| This removes all softlinks of the structure that has THIS as his origin.
virtual bool | hasSubcomponent (Component *subcomp)
| This method looks if a special component is a subcomponent of this component.
virtual bool | isComponentConnected (Component *connectedComp)
| This method looks if a special component somehow connected to this component.
virtual componentConnection * | getConnection (unsigned int connectionnumber)
| This garants an direct access to the connections between the components.
virtual componentConnection * | getConnection (Component *targetcomponent)
| This returns the connection that connects to the target component.
virtual bool | setSoftlink (unsigned int position, bool state)
| Sets the connection between the component and one of its subcomponents to be a softlink.
virtual Component * | getBestDivideComponent (double targetrelation, int maxsize, Component *currentBestDivideComponent)
| This divides the component structure, following this component into two seperate component structures.
## Static Public Member Functions
static ComponentConf | getDefaultConf ()
## Public Attributes
ComponentConf | conf
std::vector< componentConnection > | connection
std::vector< Component * > | backwardreference
Component * | originComponent
Component * | directOriginComponent
## Classes
struct | componentConnection
| This is the structure of one connection between two components. More...

## Detailed Description

This is the abstract base class of the component system.

A component includes the routines for managing sensor and motor values from a controller. With a bunch of components it is possible to create a tree like structure. There is always a root structure. Components could be used as normal robot objects, so they can get motor and sensor values. These values are shared with all components in the tree structure of a component. Between the differnt objects of the component class could exist connections, which are physical represented by Ode-Joints. The components use the motor values they get, to control the joints between them. From these joints sensor values are read out, which where send with the getSensor () function like a normal robot does. But the arrray of sensor values comes from all components within the structure beneth the component, from which the function was called. You could say that each component is a non physical shell around a physical object like a primitive or a robot in classical meaning of this project. These shells build a connection between the physical parts and control these connections, which could be also physical existend.

## Constructor & Destructor Documentation

Component | ( | const OdeHandle & | odeHandle,
|  | const OsgHandle & | osgHandle,
|  | const ComponentConf & | conf |
| ) |  |  |

~Component | ( |  | ) |

## Member Function Documentation

void addSubcomponent | ( | Component * | newsubcomponent,
|  | Joint * | newconnectingjoint,
|  | bool | softlink |
| ) |  |  | `[virtual]`

This method adds an existing Component as a subcomponent to this component.

Parameters:

  | subcomponent | to add
  | reference | to external created joint, which connects both components
  | true | if connection should be a softlink, false else

bool collisionCallback | ( | void * | data,
|  | dGeomID | o1,
|  | dGeomID | o2 |
| ) |  |  | `[virtual]`

Deprecated:
  Do not use it anymore, collision control is done automatically. In case of a treatment return true (collision will be ignored by other objects and the default routine) else false (collision is passed to other objects and (if not treated) to the default routine).

Reimplemented from OdeRobot.

Reimplemented in AtomComponent, RobotComponent, and SimpleComponent.

void doInternalStuff | ( | const GlobalData & | globalData | ) | `[virtual]`

Component * getBestDivideComponent | ( | double | targetrelation,
|  | int | maxsize,
|  | Component * | currentBestDivideComponent |
| ) |  |  | `[virtual]`

This divides the component structure, following this component into two seperate component structures.

Parameters:

  | the | relation between the two new component structures, if it is 1/2 the structures would have the same number of components or only have a difference by one if the whole structures has an odd number of components
  | maximum | size of the whole Component structure of the first call of this function
  | the | best component for dividing at the moment of calling this function; it should be NULL for the first call of the function, so that no best component is set up till now

Returns:
  the best Componet for dividing at the moment the function is finished

Component::componentConnection * getConnection | ( | Component * | targetcomponent | ) | `[virtual]`

This returns the connection that connects to the target component.

Parameters:

  | the | reference to the component which is subcomponent in the searched connection

Returns:
  the reference of connection element

Component::componentConnection * getConnection | ( | unsigned int | connectionnumber | ) | `[virtual]`

This garants an direct access to the connections between the components.

Be carefull with using the given references.

Parameters:

  | the | number of the connection

Returns:
  the reference of connection element

static ComponentConf getDefaultConf | ( |  | ) | `[inline, static]`

double getDistanceToComponent | ( | Component * | comp | ) | `[virtual]`

Gets the distance between two components.

Returns:
  distance in space

virtual Primitive* getMainPrimitive | ( |  | ) | const`[pure virtual]`

return reference to the simple Primitive, or to the main Primitive of the robot assigend to the component.

If nothimng is assigned, NULL is returned.

Implements OdeRobot.

Implemented in AtomComponent, PrimitiveComponent, RobotComponent, and SimpleComponent.

int getMotorNumber | ( |  | ) | `[virtual]`

returns number of motors; recursivly adding of the number of sensors all subcomponents; at the moment only counts Hinge-, Slider-, Hinge2 and Universal-Joints; The Motor-Numbers of the robots of the Components is not counted.

Returns:
  number of motors of the component and all its subcomponents

Implements AbstractRobot.

Reimplemented in AtomComponent, and RobotComponent.

int getNumberSubcomponents | ( |  | ) | `[virtual]`

Gets the Number of subcomponents of this component.

Returns:
  Number of subcomponents

int getNumberSubcomponentsAll | ( |  | ) | `[virtual]`

Gets the Number of all Subcomponents recursivly connected.

Returns:
  Number of subcomponents

virtual Position getPosition | ( |  | ) | const`[pure virtual]`

returns position of the object

Returns:
  vector of position (x,y,z)

Reimplemented from OdeRobot.

Implemented in AtomComponent, PrimitiveComponent, RobotComponent, and SimpleComponent.

osg::Vec3 getPositionbetweenComponents | ( | Component * | component | ) | `[virtual]`

This is only a simple function, calculating the coordinates of the point exactly between two directly connected components.

Returns:
  Vector containing the Position

Parameters:

  | index | number of the position

Reimplemented in AtomComponent, RobotComponent, and SimpleComponent.

int getSensorNumber | ( |  | ) | `[virtual]`

Returns number of sensors; recursivly adding of the number of sensors all subcomponents and the robots of all Subcomponents.

Returns:
  number of sensors of the component and all its subcomponents

Implements AbstractRobot.

Reimplemented in AtomComponent, and RobotComponent.

int getSensors | ( | sensor * | sensors,
|  | int | sensornumber |
| ) |  |  | `[virtual]`

Use this, to get all sensor values of all the joints of all subcomponents, and the sensors of all robots, belonging to all subcompionents.

The sensor values have the following sequence: values of the component connecting joints, values of the robot of the component, values of component connecting joints of the first subcomponent, values of the robot of the first subcomponent, ... sensor values of the connecting joints of this component and all subcomponents

Implements AbstractRobot.

Reimplemented in AtomComponent, and RobotComponent.

bool hasSubcomponent | ( | Component * | subcomp | ) | `[virtual]`

This method looks if a special component is a subcomponent of this component.

Only direct subcomponents are registrated. Components which are only connected by softlink are a connection here as well.

Parameters:

  | the | component, which could be a subcomponent of this component

Returns:
  true if it is a subcomponent, false if not

bool isComponentConnected | ( | Component * | connectedComp | ) | `[virtual]`

This method looks if a special component somehow connected to this component.

Parameters:

  | the | component, which could be connected

Returns:
  true if it is connected, false if not

virtual void place | ( | const Pos & | pos | ) | `[pure virtual]`

sets the vehicle to position pos

Parameters:

  | pos | desired position of the robot

Reimplemented from OdeRobot.

Implemented in AtomComponent, PrimitiveComponent, RobotComponent, and SimpleComponent.

void removeAllSubcomponentsRecursive | ( |  | ) | `[virtual]`

This removes all subcomponents of THIS component, and all their subcomponents, till the whole structure is destroyed.

void removeSoftlinksRecursive | ( |  | ) | `[virtual]`

This removes all softlinks of the structure that has THIS as his origin.

Component * removeSubcomponent | ( | Component * | removedsubcomponent | ) | `[virtual]`

This method removes an existing Component as a subcomponent of this component.

This also removes all Subcomponents of the subcomponent.

Parameters:

  | subcomponent | to remove

Returns:
  reference to the removed subcomponent, so that it could be used to do other things

Component * removeSubcomponent | ( | int | removedsubcomponentnumber | ) | `[virtual]`

This method removes an existing Component as a subcomponent of this component.

This also removes all Subcomponents of the subcomponent.

Parameters:

  | subcomponent | number to remove

Returns:
  reference to the removed subcomponent, so that it could be used to do other things

void resetMotorsRecursive | ( |  | ) | `[virtual]`

This sets all motors in the component structure to zero, starting from this component.

void setMotors | ( | const motor * | motors,
|  | int | motornumber |
| ) |  |  | `[virtual]`

Sets the motor values for the joints connecting the component with its subcomponents, an recursivly the joints of all subComponents.

The motors of all robots of the subcomponents is not set.

Parameters:

Implements AbstractRobot.

Reimplemented in AtomComponent, and RobotComponent.

bool setSoftlink | ( | unsigned int | position,
|  | bool | state |
| ) |  |  | `[virtual]`

Sets the connection between the component and one of its subcomponents to be a softlink.

That means that the recusion for this branch stops here.

Parameters:

  | number | of the subcomponent in the subcomponent list of the component
  | true | = connection becomes a softlink

virtual void update | ( |  | ) | `[pure virtual]`

update the OSG notes here

Implements OdeRobot.

Implemented in AtomComponent, PrimitiveComponent, RobotComponent, and SimpleComponent.

void updateOriginsRecursive | ( | Component * | parent | ) | `[virtual]`

This updates the origin references within the component tree.

If this is a removed subcomponent for examble, then parent should be this itself, so it is the top of the tree.

Parameters:

  | the | component wich is the top of the tree structure, could also be this component itself

## Member Data Documentation

std::vector<Component*> backwardreference

ComponentConf conf

std::vector<componentConnection> connection

Component* directOriginComponent

Component* originComponent

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

- component.h
- component.cpp