Privacy
An open-source, flexible 3D physical simulation framework
mars::sim::NodeManager Class Reference

The declaration of the NodeManager class. More...

#include <NodeManager.h>

Classes

struct  MoveParams
 
struct  Params
 
struct  RotationParams
 

Public Member Functions

 NodeManager (interfaces::ControlCenter *c, lib_manager::LibManager *theManager)
 Initialization of a new NodeManager. More...
 
virtual ~NodeManager ()
 
virtual interfaces::NodeId createPrimitiveNode (const std::string &name, interfaces::NodeType type, bool movable=false, const utils::Vector &pos=utils::Vector::Zero(), const utils::Vector &extension=utils::Vector::Identity(), double mass=0, const utils::Quaternion &orientation=utils::Quaternion::Identity(), bool disablePhysics=false)
 
virtual interfaces::NodeId addNode (interfaces::NodeData *nodeS, bool reload=false, bool loadGraphics=true)
 Add a node to the node pool of the simulation. More...
 
virtual interfaces::NodeId addTerrain (interfaces::terrainStruct *terrainS)
 This function maps a terrainStruct to a node struct and adds that node to the simulation. More...
 
virtual std::vector< interfaces::NodeIdaddNode (std::vector< interfaces::NodeData > v_NodeData)
 This function adds an vector of nodes to the factory. More...
 
virtual interfaces::NodeId addPrimitive (interfaces::NodeData *snode)
 This function adds an primitive to the simulation. More...
 
virtual bool exists (interfaces::NodeId id) const
 returns true if the node with the given id exists More...
 
virtual int getNodeCount () const
 returns the number of nodes added to the simulation More...
 
virtual interfaces::NodeId getNextNodeID () const
 Returns the ID for the next node which will be added to the simulation. More...
 
virtual void editNode (interfaces::NodeData *nodeS, int changes)
 Change a node. More...
 
virtual void changeGroup (interfaces::NodeId id, int group)
 This function is not implemented yet. More...
 
virtual void getListNodes (std::vector< interfaces::core_objects_exchange > *nodeList) const
 Fills a list of core_object_exchange objects with node iformations. More...
 
virtual void getNodeExchange (interfaces::NodeId id, interfaces::core_objects_exchange *obj) const
 Fills one core_object_exchange object with node information of the node with the given id. More...
 
virtual const interfaces::NodeData getFullNode (interfaces::NodeId id) const
 get the full struct of a Node for editing purposes More...
 
virtual void removeNode (interfaces::NodeId id, bool clearGraphics=true)
 removes the node with the corresponding id. More...
 
virtual void setNodeState (interfaces::NodeId id, const interfaces::nodeState &state)
 Set physical dynamic values for the node with the given id. More...
 
virtual void getNodeState (interfaces::NodeId id, interfaces::nodeState *state) const
 Get physical dynamic values for the node with the given id. More...
 
virtual const utils::Vector getCenterOfMass (const std::vector< interfaces::NodeId > &ids) const
 Return the center of mass for the nodes corresponding to the id's from the given vector. More...
 
virtual void setPosition (interfaces::NodeId id, const utils::Vector &pos)
 Sets the position of the node with the given id. More...
 
virtual const utils::Vector getPosition (interfaces::NodeId id) const
 Returns the current position of a node. More...
 
virtual void setRotation (interfaces::NodeId id, const utils::Quaternion &rot)
 Sets the rotation of the node with the given id. More...
 
virtual const utils::Quaternion getRotation (interfaces::NodeId id) const
 Returns the current orientation of a node. More...
 
virtual const utils::Vector getLinearVelocity (interfaces::NodeId id) const
 Gets the current linear velocity of a node. More...
 
virtual const utils::Vector getAngularVelocity (interfaces::NodeId id) const
 Gets the current angular velocity of a node. More...
 
virtual const utils::Vector getLinearAcceleration (interfaces::NodeId id) const
 Gets the current linear acceleration of a node. More...
 
virtual const utils::Vector getAngularAcceleration (interfaces::NodeId id) const
 Gets the current angular/rotational acceleration of a node. More...
 
virtual void applyForce (interfaces::NodeId id, const utils::Vector &force, const utils::Vector &pos)
 Adds a off-center Force to the node with the given id. More...
 
virtual void applyForce (interfaces::NodeId id, const utils::Vector &force)
 Adds a Force to the node with the given id. More...
 
virtual void applyTorque (interfaces::NodeId id, const utils::Vector &torque)
 Adds a Torque to the node with the given id. More...
 
virtual void setContactParamMotion1 (interfaces::NodeId id, interfaces::sReal motion)
 Sets the contact parameter motion1 for the node with the given id. More...
 
virtual void addNodeSensor (interfaces::BaseNodeSensor *sensor)
 Adds a physical sensor to the node with the given id. More...
 
virtual void reloadNodeSensor (interfaces::BaseNodeSensor *sensor)
 This function resets a added sensor by removing it and add a new defined by the sensor config struct. More...
 
virtual SimNodegetSimNode (interfaces::NodeId id)
 Returns a pointer to the SimNode Object. More...
 
virtual const SimNodegetSimNode (interfaces::NodeId id) const
 
virtual void reloadNodes (bool reloadGraphics)
 Reloads all nodes in the simulation. More...
 
virtual const utils::Vector setReloadExtent (interfaces::NodeId id, const utils::Vector &ext)
 set the size for the node with the given id. More...
 
virtual void setReloadPosition (interfaces::NodeId id, const utils::Vector &pos)
 set the position for the node with the given id. More...
 
virtual void setReloadFriction (interfaces::NodeId id, interfaces::sReal friction1, interfaces::sReal friction2)
 Sets the new contact friction of a node after a reset of the simulation. More...
 
virtual void updateDynamicNodes (interfaces::sReal calc_ms, bool physics_thread=true)
 Updates the Node values of dynamical nodes from the physics. More...
 
virtual void clearAllNodes (bool clear_all=false, bool clearGraphics=true)
 Removes all nodes from the simulation to clear the world. More...
 
virtual void setReloadAngle (interfaces::NodeId id, const utils::sRotation &angle)
 Set the reload orientation of a node. More...
 
virtual void setContactParams (interfaces::NodeId id, const interfaces::contact_params &cp)
 Set the contact parameter of a node. More...
 
virtual const interfaces::contact_params getContactParams (interfaces::NodeId id) const
 Returns the contact properties of a certain node. More...
 
virtual void setVelocity (interfaces::NodeId id, const utils::Vector &vel)
 Sets the linear velocity of a node. More...
 
virtual void setAngularVelocity (interfaces::NodeId id, const utils::Vector &vel)
 Sets the angular velocity of a node. More...
 
virtual void scaleReloadNodes (interfaces::sReal x, interfaces::sReal y, interfaces::sReal z)
 Scales the nodes to reload. More...
 
virtual void getNodeMass (interfaces::NodeId id, interfaces::sReal *mass, interfaces::sReal *inertia=0) const
 Returns the mass and inertia of a certain node. More...
 
virtual void setAngularDamping (interfaces::NodeId id, interfaces::sReal damping)
 Sets a angular damping factor to the node dynamics. More...
 
virtual void addRotation (interfaces::NodeId id, const utils::Quaternion &q)
 Adds a additional rotation to the orientation of a node. More...
 
virtual void setReloadQuaternion (interfaces::NodeId id, const utils::Quaternion &q)
 Set the reload orientation of a node by using a quaternion. More...
 
virtual void preGraphicsUpdate (void)
 
virtual void exportGraphicNodesByID (const std::string &folder) const
 If a graphicsManager is loaded, exports the graphical models of all nodes. More...
 
virtual void getContactPoints (std::vector< interfaces::NodeId > *ids, std::vector< utils::Vector > *contact_points) const
 
virtual void getContactIDs (const interfaces::NodeId &id, std::list< interfaces::NodeId > *ids) const
 
virtual void updateRay (interfaces::NodeId id)
 
virtual interfaces::NodeId getDrawID (interfaces::NodeId id) const
 
virtual void setVisualRep (interfaces::NodeId id, int val)
 
virtual const utils::Vector getContactForce (interfaces::NodeId id) const
 
virtual void setVisualQOffset (interfaces::NodeId id, const utils::Quaternion &q)
 
virtual void updatePR (interfaces::NodeId id, const utils::Vector &pos, const utils::Quaternion &rot, const utils::Vector &visOffsetPos, const utils::Quaternion &visOffsetRot, bool doLock=true)
 
virtual interfaces::NodeId getID (const std::string &node_name) const
 Retrieve the id of a node by name. More...
 
virtual double getCollisionDepth (interfaces::NodeId id) const
 
virtual bool getDataBrokerNames (interfaces::NodeId id, std::string *groupName, std::string *dataName) const
 Retrieves the groupName and dataName under which the node with the specified id publishes its data in the DataBroker. More...
 
virtual std::vector< interfaces::NodeIdgetConnectedNodes (interfaces::NodeId id)
 
virtual bool getIsMovable (interfaces::NodeId id) const
 
virtual void setIsMovable (interfaces::NodeId id, bool isMovable)
 
virtual void lock ()
 
virtual void unlock ()
 
virtual void rotateNode (interfaces::NodeId id, utils::Vector pivot, utils::Quaternion q, unsigned long excludeJointId, bool includeConnected=true)
 Rotates the specified node according to the provided quaternion. More...
 
virtual void positionNode (interfaces::NodeId id, utils::Vector pos, unsigned long excludeJointId)
 Positions the node according to the provided vector. More...
 
virtual unsigned long getMaxGroupID ()
 
virtual void edit (interfaces::NodeId id, const std::string &key, const std::string &value)
 Edit a node property by giving a key and value. More...
 
- Public Member Functions inherited from mars::interfaces::NodeManagerInterface
virtual ~NodeManagerInterface ()
 
- Public Member Functions inherited from mars::interfaces::GraphicsUpdateInterface
 GraphicsUpdateInterface (void)
 
virtual ~GraphicsUpdateInterface (void)
 
virtual void postGraphicsUpdate (void)
 

Private Member Functions

std::list< interfaces::NodeData >::iterator getReloadNode (interfaces::NodeId id)
 
void recursiveHelper (interfaces::NodeId id, const Params *params, std::vector< SimJoint *> *joints, std::vector< int > *gids, NodeMap *nodes, void(*applyFunc)(SimNode *node, const Params *params))
 
void moveNodeRecursive (interfaces::NodeId id, const utils::Vector &offset, std::vector< SimJoint *> *joints, std::vector< int > *gids, NodeMap *nodes)
 
void rotateNodeRecursive (interfaces::NodeId id, const utils::Vector &rotation_point, const utils::Quaternion &rotation, std::vector< SimJoint *> *joints, std::vector< int > *gids, NodeMap *nodes)
 
void moveRelativeNodes (const SimNode &node, NodeMap *nodes, utils::Vector v)
 
void rotateRelativeNodes (const SimNode &node, NodeMap *nodes, utils::Vector pivot, utils::Quaternion rot)
 
void resetRelativeNodes (const SimNode &node, NodeMap *nodes, const utils::Quaternion *rotate=0)
 
void resetRelativeJoints (const SimNode &node, NodeMap *nodes, std::vector< SimJoint *> *joints, const utils::Quaternion *rotate=0)
 
void setNodeStructPositionFromRelative (interfaces::NodeData *node) const
 
void clearRelativePosition (interfaces::NodeId id, bool lock)
 
void removeNode (interfaces::NodeId id, bool lock, bool clearGraphics=true)
 
void pushToUpdate (SimNode *node)
 
void printNodeMasses (bool onlysum)
 
void changeNode (SimNode *editedNode, interfaces::NodeData *nodeS)
 

Static Private Member Functions

static void applyMove (SimNode *node, const Params *params)
 
static void applyRotation (SimNode *node, const Params *params)
 

Private Attributes

interfaces::NodeId next_node_id
 
bool update_all_nodes
 
int visual_rep
 
NodeMap simNodes
 
NodeMap simNodesDyn
 
NodeMap nodesToUpdate
 
NodeMap vizNodes
 
std::list< interfaces::NodeDatasimNodesReload
 
unsigned long maxGroupID
 
lib_manager::LibManagerlibManager
 
utils::Mutex iMutex
 
interfaces::ControlCentercontrol
 

Detailed Description

The declaration of the NodeManager class.

Definition at line 52 of file NodeManager.h.

Constructor & Destructor Documentation

◆ NodeManager()

mars::sim::NodeManager::NodeManager ( interfaces::ControlCenter c,
lib_manager::LibManager theManager 
)

Initialization of a new NodeManager.

pre:

  • a pointer to a ControlCenter is needed post:
  • next_node_id should be initialized to one

Definition at line 65 of file NodeManager.cpp.

◆ ~NodeManager()

virtual mars::sim::NodeManager::~NodeManager ( )
inlinevirtual

Definition at line 57 of file NodeManager.h.

Member Function Documentation

◆ addNode() [1/2]

NodeId mars::sim::NodeManager::addNode ( interfaces::NodeData nodeS,
bool  reload = false,
bool  loadGraphics = true 
)
virtual

Add a node to the node pool of the simulation.

It is very important to assure the serialization between the threads to have the desired results.

pre:

  • nodeS->groupID >= 0

Implements mars::interfaces::NodeManagerInterface.

Definition at line 108 of file NodeManager.cpp.

◆ addNode() [2/2]

vector< NodeId > mars::sim::NodeManager::addNode ( std::vector< interfaces::NodeData v_NodeData)
virtual

This function adds an vector of nodes to the factory.

The functionality is implemented in the GUI, but should move to the node factory soon.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 386 of file NodeManager.cpp.

◆ addNodeSensor()

void mars::sim::NodeManager::addNodeSensor ( interfaces::BaseNodeSensor sensor)
virtual

Adds a physical sensor to the node with the given id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 875 of file NodeManager.cpp.

◆ addPrimitive()

NodeId mars::sim::NodeManager::addPrimitive ( interfaces::NodeData snode)
virtual

This function adds an primitive to the simulation.

The functionality is implemented in the GUI, but should move to the node factory soon.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 402 of file NodeManager.cpp.

◆ addRotation()

void mars::sim::NodeManager::addRotation ( interfaces::NodeId  id,
const utils::Quaternion q 
)
virtual

Adds a additional rotation to the orientation of a node.

It is very important to assure the serialization between the threads to have the desired results. Currently the verified use of this function is only guaranteed by calling it within the main thread (update callback from gui_thread).

Parameters
idThe id of the node to add the rotation.
qThe rotation to be added (see Quaternion).

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1426 of file NodeManager.cpp.

◆ addTerrain()

NodeId mars::sim::NodeManager::addTerrain ( interfaces::terrainStruct terrainS)
virtual

This function maps a terrainStruct to a node struct and adds that node to the simulation.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 357 of file NodeManager.cpp.

◆ applyForce() [1/2]

void mars::sim::NodeManager::applyForce ( interfaces::NodeId  id,
const utils::Vector force,
const utils::Vector pos 
)
virtual

Adds a off-center Force to the node with the given id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 834 of file NodeManager.cpp.

◆ applyForce() [2/2]

void mars::sim::NodeManager::applyForce ( interfaces::NodeId  id,
const utils::Vector force 
)
virtual

Adds a Force to the node with the given id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 843 of file NodeManager.cpp.

◆ applyMove()

void mars::sim::NodeManager::applyMove ( SimNode node,
const Params params 
)
staticprivate

Definition at line 1063 of file NodeManager.cpp.

◆ applyRotation()

void mars::sim::NodeManager::applyRotation ( SimNode node,
const Params params 
)
staticprivate

Definition at line 1069 of file NodeManager.cpp.

◆ applyTorque()

void mars::sim::NodeManager::applyTorque ( interfaces::NodeId  id,
const utils::Vector torque 
)
virtual

Adds a Torque to the node with the given id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 853 of file NodeManager.cpp.

◆ changeGroup()

void mars::sim::NodeManager::changeGroup ( interfaces::NodeId  id,
int  group 
)
virtual

This function is not implemented yet.

To change a group of a node it has to be removed and added again with a new group_id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 589 of file NodeManager.cpp.

◆ changeNode()

void mars::sim::NodeManager::changeNode ( SimNode editedNode,
interfaces::NodeData nodeS 
)
private

Definition at line 1867 of file NodeManager.cpp.

◆ clearAllNodes()

void mars::sim::NodeManager::clearAllNodes ( bool  clear_all = false,
bool  clearGraphics = true 
)
virtual

Removes all nodes from the simulation to clear the world.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1322 of file NodeManager.cpp.

◆ clearRelativePosition()

void mars::sim::NodeManager::clearRelativePosition ( interfaces::NodeId  id,
bool  lock 
)
private

Definition at line 1167 of file NodeManager.cpp.

◆ createPrimitiveNode()

NodeId mars::sim::NodeManager::createPrimitiveNode ( const std::string &  name,
interfaces::NodeType  type,
bool  movable = false,
const utils::Vector pos = utils::Vector::Zero(),
const utils::Vector extension = utils::Vector::Identity(),
double  mass = 0,
const utils::Quaternion orientation = utils::Quaternion::Identity(),
bool  disablePhysics = false 
)
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 81 of file NodeManager.cpp.

◆ edit()

void mars::sim::NodeManager::edit ( interfaces::NodeId  id,
const std::string &  key,
const std::string &  value 
)
virtual

Edit a node property by giving a key and value.

Parameters
idThe id of the node to be edit.
keyDefines the key in the ConfigMap. Could also include the path, in the end pattern matching is used.
valueString containing the value.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1715 of file NodeManager.cpp.

◆ editNode()

void mars::sim::NodeManager::editNode ( interfaces::NodeData nodeS,
int  changes 
)
virtual

Change a node.

The simulation must be updated in here. doc has to be written

Implements mars::interfaces::NodeManagerInterface.

Definition at line 436 of file NodeManager.cpp.

◆ exists()

bool mars::sim::NodeManager::exists ( interfaces::NodeId  id) const
virtual

returns true if the node with the given id exists

Implements mars::interfaces::NodeManagerInterface.

Definition at line 411 of file NodeManager.cpp.

◆ exportGraphicNodesByID()

void mars::sim::NodeManager::exportGraphicNodesByID ( const std::string &  folder) const
virtual

If a graphicsManager is loaded, exports the graphical models of all nodes.

Every node is exported by its id to a seperated file into the given folder.

It is very important to assure the serialization between the threads to have the desired results. Currently the verified use of this function is only guaranteed by calling it within the main thread (update callback from gui_thread).

Parameters
folderThe folder where to exort the models.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1446 of file NodeManager.cpp.

◆ getAngularAcceleration()

const Vector mars::sim::NodeManager::getAngularAcceleration ( interfaces::NodeId  id) const
virtual

Gets the current angular/rotational acceleration of a node.

Parameters
idThe id of the node to get the angular/rotational acceleration from.
Returns
The angular/rotational acceleration of the node.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 809 of file NodeManager.cpp.

◆ getAngularVelocity()

const Vector mars::sim::NodeManager::getAngularVelocity ( interfaces::NodeId  id) const
virtual

Gets the current angular velocity of a node.

Parameters
idThe id of the node to get the angular/rotational velocity from.
Returns
The angular/rotational velocity of the node.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 790 of file NodeManager.cpp.

◆ getCenterOfMass()

const Vector mars::sim::NodeManager::getCenterOfMass ( const std::vector< interfaces::NodeId > &  ids) const
virtual

Return the center of mass for the nodes corresponding to the id's from the given vector.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 732 of file NodeManager.cpp.

◆ getCollisionDepth()

double mars::sim::NodeManager::getCollisionDepth ( interfaces::NodeId  id) const
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1520 of file NodeManager.cpp.

◆ getConnectedNodes()

std::vector< NodeId > mars::sim::NodeManager::getConnectedNodes ( interfaces::NodeId  id)
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1580 of file NodeManager.cpp.

◆ getContactForce()

const Vector mars::sim::NodeManager::getContactForce ( interfaces::NodeId  id) const
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1510 of file NodeManager.cpp.

◆ getContactIDs()

void mars::sim::NodeManager::getContactIDs ( const interfaces::NodeId id,
std::list< interfaces::NodeId > *  ids 
) const
virtual

Definition at line 1482 of file NodeManager.cpp.

◆ getContactParams()

const contact_params mars::sim::NodeManager::getContactParams ( interfaces::NodeId  id) const
virtual

Returns the contact properties of a certain node.

It is very important to assure the serialization between the threads to have the desired results. Currently the verified use of this function is only guaranteed by calling it within the main thread (update callback from gui_thread).

Parameters
idThe id of the node to get the contact properties from.
Returns
A contact parameter struct which stores the contact properties.
See also
contact_params

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1434 of file NodeManager.cpp.

◆ getContactPoints()

void mars::sim::NodeManager::getContactPoints ( std::vector< interfaces::NodeId > *  ids,
std::vector< utils::Vector > *  contact_points 
) const
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1465 of file NodeManager.cpp.

◆ getDataBrokerNames()

bool mars::sim::NodeManager::getDataBrokerNames ( interfaces::NodeId  id,
std::string *  groupName,
std::string *  dataName 
) const
virtual

Retrieves the groupName and dataName under which the node with the specified id publishes its data in the DataBroker.

Returns
true if the names were successfully retrieved. false if no node with the given id exists.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1624 of file NodeManager.cpp.

◆ getDrawID()

NodeId mars::sim::NodeManager::getDrawID ( interfaces::NodeId  id) const
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1500 of file NodeManager.cpp.

◆ getFullNode()

const NodeData mars::sim::NodeManager::getFullNode ( interfaces::NodeId  id) const
virtual

get the full struct of a Node for editing purposes

Exceptions
std::runtime_errorif the node cannot be found

Implements mars::interfaces::NodeManagerInterface.

Definition at line 626 of file NodeManager.cpp.

◆ getID()

NodeId mars::sim::NodeManager::getID ( const std::string &  node_name) const
virtual

Retrieve the id of a node by name.

Parameters
node_nameName of the node to get the id for
Returns
Id of the node if it exists, otherwise 0

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1557 of file NodeManager.cpp.

◆ getIsMovable()

bool mars::sim::NodeManager::getIsMovable ( interfaces::NodeId  id) const
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1654 of file NodeManager.cpp.

◆ getLinearAcceleration()

const Vector mars::sim::NodeManager::getLinearAcceleration ( interfaces::NodeId  id) const
virtual

Gets the current linear acceleration of a node.

Parameters
idThe id of the node to get the acceleration from.
Returns
The linear acceleration of the node.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 800 of file NodeManager.cpp.

◆ getLinearVelocity()

const Vector mars::sim::NodeManager::getLinearVelocity ( interfaces::NodeId  id) const
virtual

Gets the current linear velocity of a node.

Parameters
idThe id of the node to get the velocity from.
Returns
The linear velocity of the node.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 781 of file NodeManager.cpp.

◆ getListNodes()

void mars::sim::NodeManager::getListNodes ( std::vector< interfaces::core_objects_exchange > *  nodeList) const
virtual

Fills a list of core_object_exchange objects with node iformations.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 598 of file NodeManager.cpp.

◆ getMaxGroupID()

virtual unsigned long mars::sim::NodeManager::getMaxGroupID ( )
inlinevirtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 159 of file NodeManager.h.

◆ getNextNodeID()

NodeId mars::sim::NodeManager::getNextNodeID ( ) const
virtual

Returns the ID for the next node which will be added to the simulation.

It is very important to assure the serializaion between the threads to have the desired results. This function should be thread save.

Returns
The ID for the next inserted node is returned.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 428 of file NodeManager.cpp.

◆ getNodeCount()

int mars::sim::NodeManager::getNodeCount ( ) const
virtual

returns the number of nodes added to the simulation

Implements mars::interfaces::NodeManagerInterface.

Definition at line 423 of file NodeManager.cpp.

◆ getNodeExchange()

void mars::sim::NodeManager::getNodeExchange ( interfaces::NodeId  id,
interfaces::core_objects_exchange obj 
) const
virtual

Fills one core_object_exchange object with node information of the node with the given id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 613 of file NodeManager.cpp.

◆ getNodeMass()

void mars::sim::NodeManager::getNodeMass ( interfaces::NodeId  id,
interfaces::sReal mass,
interfaces::sReal inertia = 0 
) const
virtual

Returns the mass and inertia of a certain node.

It is very important to assure the serialization between the threads to have the desired results. Currently the verified use of this function is only guaranteed by calling it within the main thread (update callback from gui_thread).

Parameters
idThe id of the node to get the mass information from.
massA pointer to the sReal variable, where the mass will be stored.
inertiaA pointer to a sReal array with a dimension of 9. If the pointer is unequal 0, the inertia information will be stored in this array.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1409 of file NodeManager.cpp.

◆ getNodeState()

void mars::sim::NodeManager::getNodeState ( interfaces::NodeId  id,
interfaces::nodeState state 
) const
virtual

Get physical dynamic values for the node with the given id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 721 of file NodeManager.cpp.

◆ getPosition()

const Vector mars::sim::NodeManager::getPosition ( interfaces::NodeId  id) const
virtual

Returns the current position of a node.

It is very important to assure the serialization between the threads to have the desired results. Currently the verified use of this function is only guaranteed by calling it within the main thread (update callback from gui_thread).

Parameters
idThe id of the node to get the position from.
Returns
The position of the node is returned.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 761 of file NodeManager.cpp.

◆ getReloadNode()

std::list< NodeData >::iterator mars::sim::NodeManager::getReloadNode ( interfaces::NodeId  id)
private

Definition at line 1212 of file NodeManager.cpp.

◆ getRotation()

const Quaternion mars::sim::NodeManager::getRotation ( interfaces::NodeId  id) const
virtual

Returns the current orientation of a node.

It is very important to assure the serialization between the threads to have the desired results. Currently the verified use of this function is only guaranteed by calling it within the main thread (update callback from gui_thread).

Parameters
idThe id of the node to get the orientation from.
Returns
The orientation of the node is returned.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 771 of file NodeManager.cpp.

◆ getSimNode() [1/2]

SimNode * mars::sim::NodeManager::getSimNode ( interfaces::NodeId  id)
virtual

Returns a pointer to the SimNode Object.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 900 of file NodeManager.cpp.

◆ getSimNode() [2/2]

const SimNode * mars::sim::NodeManager::getSimNode ( interfaces::NodeId  id) const
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 904 of file NodeManager.cpp.

◆ lock()

virtual void mars::sim::NodeManager::lock ( )
inlinevirtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 152 of file NodeManager.h.

◆ moveNodeRecursive()

void mars::sim::NodeManager::moveNodeRecursive ( interfaces::NodeId  id,
const utils::Vector offset,
std::vector< SimJoint *> *  joints,
std::vector< int > *  gids,
NodeMap nodes 
)
private

Definition at line 1075 of file NodeManager.cpp.

◆ moveRelativeNodes()

void mars::sim::NodeManager::moveRelativeNodes ( const SimNode node,
NodeMap nodes,
utils::Vector  v 
)
private

Definition at line 1667 of file NodeManager.cpp.

◆ positionNode()

void mars::sim::NodeManager::positionNode ( interfaces::NodeId  id,
utils::Vector  pos,
unsigned long  excludeJointId 
)
virtual

Positions the node according to the provided vector.

Parameters
idThe id of the node to be moved.
posThe utils::Vector defining the new position of the node.
excludeJointId?

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1120 of file NodeManager.cpp.

◆ preGraphicsUpdate()

void mars::sim::NodeManager::preGraphicsUpdate ( void  )
virtual

Reimplemented from mars::interfaces::GraphicsUpdateInterface.

Definition at line 1274 of file NodeManager.cpp.

◆ printNodeMasses()

void mars::sim::NodeManager::printNodeMasses ( bool  onlysum)
privatevirtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1704 of file NodeManager.cpp.

◆ pushToUpdate()

void mars::sim::NodeManager::pushToUpdate ( SimNode node)
private

Definition at line 1571 of file NodeManager.cpp.

◆ recursiveHelper()

void mars::sim::NodeManager::recursiveHelper ( interfaces::NodeId  id,
const Params params,
std::vector< SimJoint *> *  joints,
std::vector< int > *  gids,
NodeMap nodes,
void(*)(SimNode *node, const Params *params)  applyFunc 
)
private

Definition at line 987 of file NodeManager.cpp.

◆ reloadNodes()

void mars::sim::NodeManager::reloadNodes ( bool  reloadGraphics)
virtual

Reloads all nodes in the simulation.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1182 of file NodeManager.cpp.

◆ reloadNodeSensor()

void mars::sim::NodeManager::reloadNodeSensor ( interfaces::BaseNodeSensor sensor)
virtual

This function resets a added sensor by removing it and add a new defined by the sensor config struct.

It is very important to assure the serialization between the threads to have the desired results. Currently the verified use of this function is only guaranteed by calling it within the main thread (update callback from gui_thread).

This method is implemented for a special case where the distance sensors have to be reconfigured. Don't know if it's used right now (maybe in the A3 project).

Parameters
idThe id of the node to reload a sensor.
s_cfgThe sensor configuration struct.
See also
sensor_config

Implements mars::interfaces::NodeManagerInterface.

Definition at line 890 of file NodeManager.cpp.

◆ removeNode() [1/2]

void mars::sim::NodeManager::removeNode ( interfaces::NodeId  id,
bool  clearGraphics = true 
)
virtual

removes the node with the corresponding id.

Ok, first we have to check if the node is an element of a composite object. If so, we have to cases:

first case:

  • other nodes exist, which are element of the composite object. -> we can delete the node and keep the group

second case:

  • this node is the only (last) one of the composite object -> we have to delete both, the node and the group

At this moment we only the physical implementation handle the groups, so the tow cases can be handled here in the same way: -> tell the physics to destroy the object and remove the node from the core.

What about joints?

Implements mars::interfaces::NodeManagerInterface.

Definition at line 660 of file NodeManager.cpp.

◆ removeNode() [2/2]

void mars::sim::NodeManager::removeNode ( interfaces::NodeId  id,
bool  lock,
bool  clearGraphics = true 
)
private

Definition at line 664 of file NodeManager.cpp.

◆ resetRelativeJoints()

void mars::sim::NodeManager::resetRelativeJoints ( const SimNode node,
NodeMap nodes,
std::vector< SimJoint *> *  joints,
const utils::Quaternion rotate = 0 
)
private

Definition at line 949 of file NodeManager.cpp.

◆ resetRelativeNodes()

void mars::sim::NodeManager::resetRelativeNodes ( const SimNode node,
NodeMap nodes,
const utils::Quaternion rotate = 0 
)
private

Definition at line 923 of file NodeManager.cpp.

◆ rotateNode()

void mars::sim::NodeManager::rotateNode ( interfaces::NodeId  id,
utils::Vector  pivot,
utils::Quaternion  q,
unsigned long  excludeJointId,
bool  includeConnected = true 
)
virtual

Rotates the specified node according to the provided quaternion.

Parameters
idThe id of the node to be rotated.
pivotThe utils::Vector defining the pivot point around which to rotate.
qThe utils::Quaternion defining the rotation vector and angle.
excludeJointId?

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1084 of file NodeManager.cpp.

◆ rotateNodeRecursive()

void mars::sim::NodeManager::rotateNodeRecursive ( interfaces::NodeId  id,
const utils::Vector rotation_point,
const utils::Quaternion rotation,
std::vector< SimJoint *> *  joints,
std::vector< int > *  gids,
NodeMap nodes 
)
private

Definition at line 1155 of file NodeManager.cpp.

◆ rotateRelativeNodes()

void mars::sim::NodeManager::rotateRelativeNodes ( const SimNode node,
NodeMap nodes,
utils::Vector  pivot,
utils::Quaternion  rot 
)
private

Definition at line 1686 of file NodeManager.cpp.

◆ scaleReloadNodes()

void mars::sim::NodeManager::scaleReloadNodes ( interfaces::sReal  x,
interfaces::sReal  y,
interfaces::sReal  z 
)
virtual

Scales the nodes to reload.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1386 of file NodeManager.cpp.

◆ setAngularDamping()

void mars::sim::NodeManager::setAngularDamping ( interfaces::NodeId  id,
interfaces::sReal  damping 
)
virtual

Sets a angular damping factor to the node dynamics.

It is very important to assure the serialization between the threads to have the desired results. Currently the verified use of this function is only guaranteed by calling it within the main thread (update callback from gui_thread).

Parameters
idThe id of the node to add the angular damping.
dampingFactor to multiply with the velocity of the node after every simulation step. The value should be between 0 and 1, while 0 means no damping and 1 the maximum damping. $ angular\_velocity = angular\_velocity * (1-damping)$

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1418 of file NodeManager.cpp.

◆ setAngularVelocity()

void mars::sim::NodeManager::setAngularVelocity ( interfaces::NodeId  id,
const utils::Vector vel 
)
virtual

Sets the angular velocity of a node.

It is very important to assure the serialization between the threads to have the desired results. Currently the verified use of this function is only guaranteed by calling it within the main thread (update callback from gui_thread).

Parameters
idThe id of the node to edit.
velThe new angular velocity of the node. The vector describes the axis of the rotation and the angular velocity (length of the vector).

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1375 of file NodeManager.cpp.

◆ setContactParamMotion1()

void mars::sim::NodeManager::setContactParamMotion1 ( interfaces::NodeId  id,
interfaces::sReal  motion 
)
virtual

Sets the contact parameter motion1 for the node with the given id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 864 of file NodeManager.cpp.

◆ setContactParams()

void mars::sim::NodeManager::setContactParams ( interfaces::NodeId  id,
const interfaces::contact_params cp 
)
virtual

Set the contact parameter of a node.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1359 of file NodeManager.cpp.

◆ setIsMovable()

void mars::sim::NodeManager::setIsMovable ( interfaces::NodeId  id,
bool  isMovable 
)
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1661 of file NodeManager.cpp.

◆ setNodeState()

void mars::sim::NodeManager::setNodeState ( interfaces::NodeId  id,
const interfaces::nodeState state 
)
virtual

Set physical dynamic values for the node with the given id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 711 of file NodeManager.cpp.

◆ setNodeStructPositionFromRelative()

void mars::sim::NodeManager::setNodeStructPositionFromRelative ( interfaces::NodeData node) const
private

Definition at line 914 of file NodeManager.cpp.

◆ setPosition()

void mars::sim::NodeManager::setPosition ( interfaces::NodeId  id,
const utils::Vector pos 
)
virtual

Sets the position of the node with the given id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 751 of file NodeManager.cpp.

◆ setReloadAngle()

void mars::sim::NodeManager::setReloadAngle ( interfaces::NodeId  id,
const utils::sRotation angle 
)
virtual

Set the reload orientation of a node.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1340 of file NodeManager.cpp.

◆ setReloadExtent()

const Vector mars::sim::NodeManager::setReloadExtent ( interfaces::NodeId  id,
const utils::Vector ext 
)
virtual

set the size for the node with the given id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1223 of file NodeManager.cpp.

◆ setReloadFriction()

void mars::sim::NodeManager::setReloadFriction ( interfaces::NodeId  id,
interfaces::sReal  friction1,
interfaces::sReal  friction2 
)
virtual

Sets the new contact friction of a node after a reset of the simulation.

It is very important to assure the serialization between the threads to have the desired results. Currently the verified use of this function is only guaranteed by calling it within the main thread (update callback from gui_thread).

Parameters
idThe id of the node to edit.
friction1The new contact friction coefficient for the first friction direction.
friction2The new contact friction coefficient for the second friction direction.
See also
contact_params

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1239 of file NodeManager.cpp.

◆ setReloadPosition()

void mars::sim::NodeManager::setReloadPosition ( interfaces::NodeId  id,
const utils::Vector pos 
)
virtual

set the position for the node with the given id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1254 of file NodeManager.cpp.

◆ setReloadQuaternion()

void mars::sim::NodeManager::setReloadQuaternion ( interfaces::NodeId  id,
const utils::Quaternion q 
)
virtual

Set the reload orientation of a node by using a quaternion.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1348 of file NodeManager.cpp.

◆ setRotation()

void mars::sim::NodeManager::setRotation ( interfaces::NodeId  id,
const utils::Quaternion rot 
)
virtual

Sets the rotation of the node with the given id.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 824 of file NodeManager.cpp.

◆ setVelocity()

void mars::sim::NodeManager::setVelocity ( interfaces::NodeId  id,
const utils::Vector vel 
)
virtual

Sets the linear velocity of a node.

It is very important to assure the serialization between the threads to have the desired results. Currently the verified use of this function is only guaranteed by calling it within the main thread (update callback from gui_thread).

Parameters
idThe id of the node to edit.
velThe new linear velocity of the node. The vector describes the direction and the velocity (length of the vector).

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1367 of file NodeManager.cpp.

◆ setVisualQOffset()

void mars::sim::NodeManager::setVisualQOffset ( interfaces::NodeId  id,
const utils::Quaternion q 
)
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1634 of file NodeManager.cpp.

◆ setVisualRep()

void mars::sim::NodeManager::setVisualRep ( interfaces::NodeId  id,
int  val 
)
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1530 of file NodeManager.cpp.

◆ unlock()

virtual void mars::sim::NodeManager::unlock ( )
inlinevirtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 153 of file NodeManager.h.

◆ updateDynamicNodes()

void mars::sim::NodeManager::updateDynamicNodes ( interfaces::sReal  calc_ms,
bool  physics_thread = true 
)
virtual

Updates the Node values of dynamical nodes from the physics.

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1266 of file NodeManager.cpp.

◆ updatePR()

void mars::sim::NodeManager::updatePR ( interfaces::NodeId  id,
const utils::Vector pos,
const utils::Quaternion rot,
const utils::Vector visOffsetPos,
const utils::Quaternion visOffsetRot,
bool  doLock = true 
)
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1640 of file NodeManager.cpp.

◆ updateRay()

void mars::sim::NodeManager::updateRay ( interfaces::NodeId  id)
virtual

Implements mars::interfaces::NodeManagerInterface.

Definition at line 1491 of file NodeManager.cpp.

Member Data Documentation

◆ control

interfaces::ControlCenter* mars::sim::NodeManager::control
private

Definition at line 176 of file NodeManager.h.

◆ iMutex

utils::Mutex mars::sim::NodeManager::iMutex
mutableprivate

Definition at line 174 of file NodeManager.h.

◆ libManager

lib_manager::LibManager* mars::sim::NodeManager::libManager
private

Definition at line 173 of file NodeManager.h.

◆ maxGroupID

unsigned long mars::sim::NodeManager::maxGroupID
private

Definition at line 172 of file NodeManager.h.

◆ next_node_id

interfaces::NodeId mars::sim::NodeManager::next_node_id
private

Definition at line 164 of file NodeManager.h.

◆ nodesToUpdate

NodeMap mars::sim::NodeManager::nodesToUpdate
private

Definition at line 169 of file NodeManager.h.

◆ simNodes

NodeMap mars::sim::NodeManager::simNodes
private

Definition at line 167 of file NodeManager.h.

◆ simNodesDyn

NodeMap mars::sim::NodeManager::simNodesDyn
private

Definition at line 168 of file NodeManager.h.

◆ simNodesReload

std::list<interfaces::NodeData> mars::sim::NodeManager::simNodesReload
private

Definition at line 171 of file NodeManager.h.

◆ update_all_nodes

bool mars::sim::NodeManager::update_all_nodes
private

Definition at line 165 of file NodeManager.h.

◆ visual_rep

int mars::sim::NodeManager::visual_rep
private

Definition at line 166 of file NodeManager.h.

◆ vizNodes

NodeMap mars::sim::NodeManager::vizNodes
private

Definition at line 170 of file NodeManager.h.


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