Privacy
An open-source, flexible 3D physical simulation framework
mars::interfaces::MotorManagerInterface Class Referenceabstract

"MotorManagerInterface" declares the interfaces for all motor operations that are used for the communication between the simulation modules. More...

#include <MotorManagerInterface.h>

Public Member Functions

virtual ~MotorManagerInterface ()
 Destructor. More...
 
virtual unsigned long addMotor (MotorData *motorS, bool reload=false)=0
 Add a motor to the simulation. More...
 
virtual int getMotorCount () const =0
 Returns the number of motors that are currently present in the simulation. More...
 
virtual void editMotor (const MotorData &motorS)=0
 Change motor properties. More...
 
virtual void getListMotors (std::vector< core_objects_exchange > *motorList) const =0
 Gives information about core exchange data for motors. More...
 
virtual const MotorData getFullMotor (unsigned long index) const =0
 Gives all information of a certain motor. More...
 
virtual void removeMotor (unsigned long index)=0
 Removes a motor from the simulation. More...
 
virtual void moveMotor (unsigned long index, sReal value)=0
 Sets the value of the motor with the given id to the given value. More...
 
virtual sim::SimMotorgetSimMotor (unsigned long index) const =0
 This function returns the SimMotor object for a given id. More...
 
virtual sim::SimMotorgetSimMotorByName (const std::string &name) const =0
 This function returns the SimMotor object for a given name. More...
 
virtual void setMotorValue (unsigned long id, sReal value)=0
 Sets the value of the motor with the given id to the given value. More...
 
virtual void setMaxTorque (unsigned long id, sReal maxTorque)=0
 Sets the maximum torque of the motor with the given id to the given value. More...
 
virtual void setMaxSpeed (unsigned long id, sReal maxSpeed)=0
 Sets the maximum speed of the motor with the given id to the given value. More...
 
virtual void setMotorValueDesiredVelocity (unsigned long id, sReal velocity)=0
 Sets the desired speed of a motor. More...
 
virtual void setMotorP (unsigned long id, sReal value)=0
 Sets the proportional term of the motor with the given id to the given value. More...
 
virtual void setMotorI (unsigned long id, sReal value)=0
 Sets the integral term of the motor with the given id to the given value. More...
 
virtual void setMotorD (unsigned long id, sReal value)=0
 Sets the derivative term of the motor with the given id to the given value. More...
 
virtual void deactivateMotor (unsigned long id)=0
 Deactivates the motor with the given id. More...
 
virtual void clearAllMotors (bool clear_all=false)=0
 Destroys all motors in the simulation. More...
 
virtual void reloadMotors (void)=0
 This function reloads all motors from a temporary motor pool. More...
 
virtual void updateMotors (sReal calc_ms)=0
 This function updates all motors with timing value calc_ms in miliseconds. More...
 
virtual sReal getActualPosition (unsigned long motorId) const =0
 
virtual sReal getTorque (unsigned long motorId) const =0
 
virtual unsigned long getID (const std::string &motor_name) const =0
 Retrieves the id of a motor by name. More...
 
virtual void removeJointFromMotors (unsigned long joint_index)=0
 Detaches the joint with the given index from all motors that act on it, if any. More...
 
virtual void getDataBrokerNames (unsigned long jointId, std::string *groupName, std::string *dataName) const =0
 Retrieves the groupName and dataName under which the motor with the specified id publishes its data in the DataBroker. More...
 
virtual void connectMimics ()=0
 
virtual void edit (MotorId id, const std::string &key, const std::string &value)=0
 

Detailed Description

"MotorManagerInterface" declares the interfaces for all motor operations that are used for the communication between the simulation modules.

The class defines only pure virtual functions that are implemented within the simulation and can be used everywhere by accessing this interface via the ControlCenter class.

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

Definition at line 64 of file MotorManagerInterface.h.

Constructor & Destructor Documentation

◆ ~MotorManagerInterface()

virtual mars::interfaces::MotorManagerInterface::~MotorManagerInterface ( )
inlinevirtual

Destructor.

Definition at line 69 of file MotorManagerInterface.h.

Member Function Documentation

◆ addMotor()

virtual unsigned long mars::interfaces::MotorManagerInterface::addMotor ( MotorData motorS,
bool  reload = false 
)
pure virtual

Add a motor to the simulation.

Parameters
motorSA pointer to the MotorData that defines the new motor.
reloadUsed internally by the simulation. The default value is false. If this param is set to true the new motor will not be reloaded after a reset of the simulation.
Returns
The unique id of the newly added motor.

Implemented in mars::sim::MotorManager.

◆ clearAllMotors()

virtual void mars::interfaces::MotorManagerInterface::clearAllMotors ( bool  clear_all = false)
pure virtual

Destroys all motors in the simulation.

The clear_all flag indicates if the reload motors should be destroyed as well. If set to false they are left intact.

Parameters
clear_allIndicates if the reload motors should be destroyed as well. If set to false they are left intact.

Implemented in mars::sim::MotorManager.

◆ connectMimics()

virtual void mars::interfaces::MotorManagerInterface::connectMimics ( )
pure virtual

Implemented in mars::sim::MotorManager.

◆ deactivateMotor()

virtual void mars::interfaces::MotorManagerInterface::deactivateMotor ( unsigned long  id)
pure virtual

Deactivates the motor with the given id.

Parameters
idThe id of the motor that is to be deactivated.

Implemented in mars::sim::MotorManager.

◆ edit()

virtual void mars::interfaces::MotorManagerInterface::edit ( MotorId  id,
const std::string &  key,
const std::string &  value 
)
pure virtual

Implemented in mars::sim::MotorManager.

◆ editMotor()

virtual void mars::interfaces::MotorManagerInterface::editMotor ( const MotorData motorS)
pure virtual

Change motor properties.

The old struct is replaced by the new one completely, so prior to calling this function, one must ensure that all properties of this parameter are valid and as desired.

Parameters
motorSThe id of the MotorData referred by this pointer must be the same as the id of the motor that is to be edited.

Implemented in mars::sim::MotorManager.

◆ getActualPosition()

virtual sReal mars::interfaces::MotorManagerInterface::getActualPosition ( unsigned long  motorId) const
pure virtual
Returns
the actual position of the motor with the given Id. returns 0 if a motor with the given Id doesn't exist.

Implemented in mars::sim::MotorManager.

◆ getDataBrokerNames()

virtual void mars::interfaces::MotorManagerInterface::getDataBrokerNames ( unsigned long  jointId,
std::string *  groupName,
std::string *  dataName 
) const
pure virtual

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

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

Implemented in mars::sim::MotorManager.

◆ getFullMotor()

virtual const MotorData mars::interfaces::MotorManagerInterface::getFullMotor ( unsigned long  index) const
pure virtual

Gives all information of a certain motor.

Parameters
indexThe unique id of the motor to get information for.
Returns
A pointer to the MotorData of the motor with the given id.

Implemented in mars::sim::MotorManager.

◆ getID()

virtual unsigned long mars::interfaces::MotorManagerInterface::getID ( const std::string &  motor_name) const
pure virtual

Retrieves the id of a motor by name.

Parameters
motor_nameName of the motor to get the id for
Returns
Id of the motor if it exists, otherwise 0

Implemented in mars::sim::MotorManager.

◆ getListMotors()

virtual void mars::interfaces::MotorManagerInterface::getListMotors ( std::vector< core_objects_exchange > *  motorList) const
pure virtual

Gives information about core exchange data for motors.

Parameters
motorListA pointer to a vector that is filled with a core_objects_exchange struct for every motor and its index. The vector is cleared in the beginning of this function.

Implemented in mars::sim::MotorManager.

◆ getMotorCount()

virtual int mars::interfaces::MotorManagerInterface::getMotorCount ( ) const
pure virtual

Returns the number of motors that are currently present in the simulation.

Returns
The number of all motors.

Implemented in mars::sim::MotorManager.

◆ getSimMotor()

virtual sim::SimMotor* mars::interfaces::MotorManagerInterface::getSimMotor ( unsigned long  index) const
pure virtual

This function returns the SimMotor object for a given id.

Warning
This method is only internally used by the MotorManager. Generally no other modules know the SimMotor class and shouldn't use this method. All motor operations from outside the core should be done over the MotorManager.
Parameters
indexThe id of the motor to get the core motor object.
Returns
Returns a pointer to the corresponding motor object.

Implemented in mars::sim::MotorManager.

◆ getSimMotorByName()

virtual sim::SimMotor* mars::interfaces::MotorManagerInterface::getSimMotorByName ( const std::string &  name) const
pure virtual

This function returns the SimMotor object for a given name.

Warning
This method is only internal used by the MotorManager. Generally no other modules know the SimMotor class and shouldn't use this method. All motor operations from outside the core should be done over the MotorManager.
Parameters
nameThe name of the motor to get the core motor object.
Returns
Returns a pointer to the corresponding motor object.

Implemented in mars::sim::MotorManager.

◆ getTorque()

virtual sReal mars::interfaces::MotorManagerInterface::getTorque ( unsigned long  motorId) const
pure virtual
Returns
the torque excerted by the motor with the given Id. returns 0 if a motor with the given Id doesn't exist.

Implemented in mars::sim::MotorManager.

◆ moveMotor()

virtual void mars::interfaces::MotorManagerInterface::moveMotor ( unsigned long  index,
sReal  value 
)
pure virtual

Sets the value of the motor with the given id to the given value.

Essentially this function triggers the motor and moves the joint that is attached to it. Equivalent to setMotorValue

Parameters
idThe id of the motor whose value is to be changed.
valueThe new value.

Implemented in mars::sim::MotorManager.

◆ reloadMotors()

virtual void mars::interfaces::MotorManagerInterface::reloadMotors ( void  )
pure virtual

This function reloads all motors from a temporary motor pool.

All motors that have been added with reload value as true are added back to the simulation again with a reload value of true.

Implemented in mars::sim::MotorManager.

◆ removeJointFromMotors()

virtual void mars::interfaces::MotorManagerInterface::removeJointFromMotors ( unsigned long  joint_index)
pure virtual

Detaches the joint with the given index from all motors that act on it, if any.

Used when a joint is destroyed.

Warning
The detached motors are not destroyed and are still present in the simulation, although they do not have any effect on it. A call to removeMotor must be made to remove the motor completely.
Parameters
joint_indexThe id of the joint that is to be detached.

Implemented in mars::sim::MotorManager.

◆ removeMotor()

virtual void mars::interfaces::MotorManagerInterface::removeMotor ( unsigned long  index)
pure virtual

Removes a motor from the simulation.

Parameters
indexThe unique id of the motor to remove form the simulation.

Implemented in mars::sim::MotorManager.

◆ setMaxSpeed()

virtual void mars::interfaces::MotorManagerInterface::setMaxSpeed ( unsigned long  id,
sReal  maxSpeed 
)
pure virtual

Sets the maximum speed of the motor with the given id to the given value.

Parameters
idThe id of the motor whose value is to be changed.
maxSpeedThe new maximum speed for the motor.

Implemented in mars::sim::MotorManager.

◆ setMaxTorque()

virtual void mars::interfaces::MotorManagerInterface::setMaxTorque ( unsigned long  id,
sReal  maxTorque 
)
pure virtual

Sets the maximum torque of the motor with the given id to the given value.

Parameters
idThe id of the motor whose value is to be changed.
maxTorqueThe new maximum torque for the motor.

Implemented in mars::sim::MotorManager.

◆ setMotorD()

virtual void mars::interfaces::MotorManagerInterface::setMotorD ( unsigned long  id,
sReal  value 
)
pure virtual

Sets the derivative term of the motor with the given id to the given value.

Only has effect on a PID motor. If the type of the motor with the given id is different from PID, no effect is observed, although the D value of the motor object is still changed.

Parameters
idThe id of the motor whose D value is to be changed.
valueThe new D value.

Implemented in mars::sim::MotorManager.

◆ setMotorI()

virtual void mars::interfaces::MotorManagerInterface::setMotorI ( unsigned long  id,
sReal  value 
)
pure virtual

Sets the integral term of the motor with the given id to the given value.

Only has effect on a PID motor. If the type of the motor with the given id is different from PID, no effect is observed, although the I value of the motor object is still changed.

Parameters
idThe id of the motor whose I value is to be changed.
valueThe new I value.

Implemented in mars::sim::MotorManager.

◆ setMotorP()

virtual void mars::interfaces::MotorManagerInterface::setMotorP ( unsigned long  id,
sReal  value 
)
pure virtual

Sets the proportional term of the motor with the given id to the given value.

Only has effect on a PID motor. If the type of the motor with the given id is different from PID, no effect is observed, although the P value of the motor object is still changed.

Parameters
idThe id of the motor whose P value is to be changed.
valueThe new P value.

Implemented in mars::sim::MotorManager.

◆ setMotorValue()

virtual void mars::interfaces::MotorManagerInterface::setMotorValue ( unsigned long  id,
sReal  value 
)
pure virtual

Sets the value of the motor with the given id to the given value.

Essentially this function triggers the motor and moves the joint that is attached to it. Equivalent to moveMotor

Parameters
idThe id of the motor whose value is to be changed.
valueThe new value.

Implemented in mars::sim::MotorManager.

◆ setMotorValueDesiredVelocity()

virtual void mars::interfaces::MotorManagerInterface::setMotorValueDesiredVelocity ( unsigned long  id,
sReal  velocity 
)
pure virtual

Sets the desired speed of a motor.

Parameters
idThe id of the motor whose value is to be changed.
valueThe new value in rad/s.

Implemented in mars::sim::MotorManager.

◆ updateMotors()

virtual void mars::interfaces::MotorManagerInterface::updateMotors ( sReal  calc_ms)
pure virtual

This function updates all motors with timing value calc_ms in miliseconds.

Warning
This function is only used internally and should not be called outside the core.
Parameters
calc_msThe timing value in miliseconds.

Implemented in mars::sim::MotorManager.


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