#include <component.h>
Inherits OdeRobot.
Inherited by AtomComponent, PrimitiveComponent, RobotComponent, and SimpleComponent.
Inheritance diagram for Component:
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... |
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.
Component | ( | const OdeHandle & | odeHandle, | |
const OsgHandle & | osgHandle, | |||
const ComponentConf & | conf | |||
) |
~Component | ( | ) |
void addSubcomponent | ( | Component * | newsubcomponent, | |
Joint * | newconnectingjoint, | |||
bool | softlink | |||
) | [virtual] |
This method adds an existing Component as a subcomponent to this component.
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] |
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.
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 |
Component::componentConnection * getConnection | ( | Component * | targetcomponent | ) | [virtual] |
This returns the connection that connects to the target component.
the | reference to the component which is subcomponent in the searched connection |
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.
the | number of the connection |
static ComponentConf getDefaultConf | ( | ) | [inline, static] |
double getDistanceToComponent | ( | Component * | comp | ) | [virtual] |
Gets the distance between two components.
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.
Implements AbstractRobot.
Reimplemented in AtomComponent, and RobotComponent.
int getNumberSubcomponents | ( | ) | [virtual] |
Gets the Number of subcomponents of this component.
int getNumberSubcomponentsAll | ( | ) | [virtual] |
Gets the Number of all Subcomponents recursivly connected.
virtual Position getPosition | ( | ) | const [pure virtual] |
returns position of the object
Reimplemented from OdeRobot.
Implemented in AtomComponent, PrimitiveComponent, RobotComponent, and SimpleComponent.
This is only a simple function, calculating the coordinates of the point exactly between two directly connected components.
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.
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.
the | component, which could be a subcomponent of this component |
bool isComponentConnected | ( | Component * | connectedComp | ) | [virtual] |
This method looks if a special component somehow connected to this component.
the | component, which could be connected |
virtual void place | ( | const Pos & | pos | ) | [pure virtual] |
sets the vehicle to position pos
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.
This method removes an existing Component as a subcomponent of this component.
This also removes all Subcomponents of the subcomponent.
subcomponent | to remove |
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.
subcomponent | number to remove |
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.
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.
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.
the | component wich is the top of the tree structure, could also be this component itself |
std::vector<Component*> backwardreference |
std::vector<componentConnection> connection |