![]() |
An open-source, flexible 3D physical simulation framework
|
"MotorManager" imlements the interfaces for all motor operations that are used for the communication between the simulation modules. More...
#include <MotorManager.h>
Public Member Functions | |
MotorManager (interfaces::ControlCenter *c) | |
Constructor. More... | |
virtual | ~MotorManager () |
Destructor. More... | |
virtual unsigned long | addMotor (interfaces::MotorData *motorS, bool reload=false) |
Add a motor to the simulation. More... | |
virtual int | getMotorCount () const |
Returns the number of motors that are currently present in the simulation. More... | |
virtual void | editMotor (const interfaces::MotorData &motorS) |
Change motor properties. More... | |
virtual void | getListMotors (std::vector< interfaces::core_objects_exchange > *motorList) const |
Gives information about core exchange data for motors. More... | |
virtual const interfaces::MotorData | getFullMotor (unsigned long index) const |
Gives all information of a certain motor. More... | |
virtual void | removeMotor (unsigned long index) |
Removes a motor from the simulation. More... | |
virtual SimMotor * | getSimMotor (unsigned long id) const |
This function returns the SimMotor object for a given id. More... | |
virtual SimMotor * | getSimMotorByName (const std::string &name) const |
This function returns the SimMotor object for a given name. More... | |
virtual void | setMotorValue (unsigned long id, interfaces::sReal value) |
Sets the value of the motor with the given id to the given value. More... | |
virtual void | setMaxTorque (unsigned long id, interfaces::sReal maxTorque) |
Sets the maximum torque of the motor with the given id to the given value. More... | |
virtual void | setMaxSpeed (unsigned long id, interfaces::sReal maxSpeed) |
Sets the maximum speed of the motor with the given id to the given value. More... | |
virtual void | setMotorValueDesiredVelocity (unsigned long id, interfaces::sReal velocity) |
Sets the desired speed of a motor. More... | |
virtual void | setMotorP (unsigned long id, interfaces::sReal value) |
Sets the proportional term of the motor with the given id to the given value. More... | |
virtual void | setMotorI (unsigned long id, interfaces::sReal value) |
Sets the integral term of the motor with the given id to the given value. More... | |
virtual void | setMotorD (unsigned long id, interfaces::sReal value) |
Sets the derivative term of the motor with the given id to the given value. More... | |
virtual void | deactivateMotor (unsigned long id) |
Deactivates the motor with the given id. More... | |
virtual void | clearAllMotors (bool clear_all=false) |
Destroys all motors in the simulation. More... | |
virtual void | reloadMotors (void) |
This function reloads all motors from a temporary motor pool. More... | |
virtual void | updateMotors (interfaces::sReal calc_ms) |
This function updates all motors with timing value calc_ms in miliseconds. More... | |
virtual interfaces::sReal | getActualPosition (unsigned long motorId) const |
virtual interfaces::sReal | getTorque (unsigned long motorId) const |
virtual void | moveMotor (unsigned long index, interfaces::sReal value) |
Sets the value of the motor with the given id to the given value. More... | |
virtual void | removeJointFromMotors (unsigned long joint_index) |
Detaches the joint with the given index from all motors that act on it, if any. More... | |
virtual unsigned long | getID (const std::string &motor_name) const |
Retrieves the id of a motor by name. More... | |
virtual void | getDataBrokerNames (unsigned long jointId, std::string *groupName, std::string *dataName) const |
Retrieves the groupName and dataName under which the motor with the specified id publishes its data in the DataBroker. More... | |
virtual void | connectMimics () |
virtual void | edit (interfaces::MotorId id, const std::string &key, const std::string &value) |
![]() | |
virtual | ~MotorManagerInterface () |
Destructor. More... | |
Private Attributes | |
unsigned long | next_motor_id |
the id of the next motor that is added to the simulation More... | |
std::map< unsigned long, SimMotor * > | simMotors |
a container for all motors currently present in the simulation More... | |
std::list< interfaces::MotorData > | simMotorsReload |
a containter for all motors that are reloaded after a reset of the simulation More... | |
interfaces::ControlCenter * | control |
a pointer to the control center More... | |
utils::Mutex | iMutex |
a mutex for the motor containters More... | |
std::map< unsigned long, std::string > | mimicmotors |
"MotorManager" imlements the interfaces for all motor operations that are used for the communication between the simulation modules.
Inherits from MotorManagerInterface.
gui_thread
). Definition at line 60 of file MotorManager.h.
mars::sim::MotorManager::MotorManager | ( | interfaces::ControlCenter * | c | ) |
Constructor.
c | The pointer to the ControlCenter of the simulation. |
Definition at line 59 of file MotorManager.cpp.
|
inlinevirtual |
Destructor.
Definition at line 73 of file MotorManager.h.
|
virtual |
Add a motor to the simulation.
motorS | A pointer to the MotorData that defines the new motor. |
reload | Used 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. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 77 of file MotorManager.cpp.
|
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.
clear_all | Indicates if the reload motors should be destroyed as well. If set to false they are left intact. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 428 of file MotorManager.cpp.
|
virtual |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 536 of file MotorManager.cpp.
|
virtual |
Deactivates the motor with the given id.
id | The id of the motor that is to be deactivated. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 373 of file MotorManager.cpp.
|
virtual |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 545 of file MotorManager.cpp.
|
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.
motorS | The id of the MotorData referred by this pointer must be the same as the id of the motor that is to be edited. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 168 of file MotorManager.cpp.
|
virtual |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 474 of file MotorManager.cpp.
|
virtual |
Retrieves the groupName and dataName under which the motor with the specified id publishes its data in the DataBroker.
true
if the names were successfully retrieved. false
if no motor with the given id exists. Implements mars::interfaces::MotorManagerInterface.
Definition at line 527 of file MotorManager.cpp.
|
virtual |
Gives all information of a certain motor.
index | The unique id of the motor to get information for. |
index | The unique id of the motor to get information for. |
std::runtime_error | if a motor with the given index does not exist. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 204 of file MotorManager.cpp.
|
virtual |
Retrieves the id of a motor by name.
motor_name | Name of the motor to get the id for |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 388 of file MotorManager.cpp.
|
virtual |
Gives information about core exchange data for motors.
motorList | A 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. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 183 of file MotorManager.cpp.
|
virtual |
Returns the number of motors that are currently present in the simulation.
Implements mars::interfaces::MotorManagerInterface.
Definition at line 152 of file MotorManager.cpp.
|
virtual |
This function returns the SimMotor object for a given id.
index | The id of the motor to get the core node object. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 250 of file MotorManager.cpp.
|
virtual |
This function returns the SimMotor object for a given name.
name | The name of the motor to get the core node object. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 273 of file MotorManager.cpp.
|
virtual |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 483 of file MotorManager.cpp.
|
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
id | The id of the motor whose value is to be changed. |
value | The new value. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 411 of file MotorManager.cpp.
|
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
.
Implements mars::interfaces::MotorManagerInterface.
Definition at line 446 of file MotorManager.cpp.
|
virtual |
Detaches the joint with the given index from all motors that act on it, if any.
Used when a joint is destroyed.
removeMotor
must be made to remove the motor completely.joint_index | The id of the joint that is to be detached. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 519 of file MotorManager.cpp.
|
virtual |
Removes a motor from the simulation.
index | The unique id of the motor to remove form the simulation. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 222 of file MotorManager.cpp.
|
virtual |
Sets the maximum speed of the motor with the given id to the given value.
id | The id of the motor whose value is to be changed. |
maxSpeed | The new maximum speed for the motor. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 500 of file MotorManager.cpp.
|
virtual |
Sets the maximum torque of the motor with the given id to the given value.
id | The id of the motor whose value is to be changed. |
maxTorque | The new maximum torque for the motor. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 492 of file MotorManager.cpp.
|
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.
id | The id of the motor whose D value is to be changed. |
value | The new D value. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 360 of file MotorManager.cpp.
|
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.
id | The id of the motor whose I value is to be changed. |
value | The new I value. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 341 of file MotorManager.cpp.
|
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.
id | The id of the motor whose P value is to be changed. |
value | The new P value. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 322 of file MotorManager.cpp.
|
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
id | The id of the motor whose value is to be changed. |
value | The new value. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 294 of file MotorManager.cpp.
|
virtual |
Sets the desired speed of a motor.
id | The id of the motor whose value is to be changed. |
value | The new value in rad/s. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 302 of file MotorManager.cpp.
|
virtual |
This function updates all motors with timing value calc_ms
in miliseconds.
calc_ms | The timing value in miliseconds. |
Implements mars::interfaces::MotorManagerInterface.
Definition at line 466 of file MotorManager.cpp.
|
private |
a pointer to the control center
Definition at line 331 of file MotorManager.h.
|
mutableprivate |
a mutex for the motor containters
Definition at line 334 of file MotorManager.h.
|
private |
Definition at line 337 of file MotorManager.h.
|
private |
the id of the next motor that is added to the simulation
Definition at line 322 of file MotorManager.h.
|
private |
a container for all motors currently present in the simulation
Definition at line 325 of file MotorManager.h.
|
private |
a containter for all motors that are reloaded after a reset of the simulation
Definition at line 328 of file MotorManager.h.