Current Controller Management Design
Responsible Module: ControllerManagement RobotUnitModule
NJointControllerBase (very well documented)
- This is the abstract base class for all NJointControllers.
- It implements basic management routines required by the RobotUnit and some basic ice calls.
-
NJointControllersare instantiated and managed by the RobotUnit.- A
NJointControllercalculatesControlTargets(ControlTargetBase) for a set ofControlDevices(ControlDevice) in a specific ControlMode. - This ControlMode is defined for each
ControlDeviceduring construction.
- A
States: Requested and Active
- The state of an
NJointControllercan be requested / not requested and active / inactive. - All four combinations are possible.
Requested / Not Requested
- If the user wants this
NJointControllerto be executed it is in a requested state (seeisControllerRequested). - Otherwise the controler is not requested.
- Calling
activateControllersets the state to requested. - Calling
deactivateControllersets the state to not requested.
- Calling
- If the \ref NJointControllerBase causes an error or a different
NJointControllerusing one or more of the sameControlDevice's is requested, thisNJointControlleris deactivated.
Active / Inactive
- Is the
NJointControllerexecuted by theRobotUnitModules::ControlThread"ControlThread" it is active (seeisControllerActive). - To be executed by the
ControlThread, theNJointControllerhas to be requested at some point in the past.- If a controller is active, it has to write a valid
ControlTargetfor each of itsControlDevices (if it fails, it will be deactivated).
- If a controller is active, it has to write a valid
Using ControlTargets
- A
NJointControllercan usepeekControlDeviceto examine aControlDevicebefore using it (e.g.: checking the supportedControlTargets). - If a
ControlDeviceshould be used by thisNJointController, it has to calluseControlDevice. - This sets the ControlMode for the
ControlDeviceand returns a pointer to theControlTarget.- This pointer has to be used to send commands in each iteration of
rtRun. - The ControlMode can't be changed afterwards (A new
NJointControllerBasehas to be created).
- This pointer has to be used to send commands in each iteration of
Steps (Input: deviceName and controlMode):
- Check that this function is called during construction
- Check that the
controlDeviceControlModeMapdoes not have an instance ofdeviceNameyet - Get
JointControllerfordeviceNameandcontrolMode - Get
deviceIndexfordeviceNamefromRobotUnitModuleDevices - set
controlDeviceUsedJointControllerfordeviceNametoJointController - set
controlDeviceControlModeMapfordeviceNametocontrolMode - set
controlDeviceUsedBitmapatdeviceIndextotrue - insert
deviceIndextocontrolDeviceUsedIndex
Using SensorValues
- A
NJointControllercan usepeekSensorDeviceto examine aSensorDevicebefore using it. - If a
SensorDeviceshould be used by thisNJointController, it has to calluseSensorDevice. - This returns a pointer to the
SensorValue.
A synchronized Virtualrobot
- If the controller needs a simox robot in
rtRun, it should calluseSynchronizedRtRobot. - This will provide a simoxRobot via
rtGetRobot. - This robot is synchronized with the real robots state before calling
rtRun
RobotUnitModuleControllerManagement
Members:
-
std::map<std::string, NJointControllerBasePtr> nJointControllers;- Holds all currently loaded
NJointControllers(index:instanceName)(May not be accessed in rt.)
- Holds all currently loaded
-
std::map<std::string, NJointControllerBasePtr> nJointControllersToBeDeleted;- These controllers will be deleted in the next iteration of publish
Creation:
createNJointController(className, instanceName, NJointControllerConfigPtr)createNJointControllerFromVariantConfig(className, instanceName, StringVariantBaseMap)createOrReplaceNJointController(className, instanceName, NJointControllerConfigPtr)createNJointController(className, instanceName, NJointControllerConfigPtr, deletable)
Steps
- Check if in
ControlThread - Check if
Devicesare ready - Check if
Controllercould be constructed by checking theclassNameand constructing a factory - Check if instance with
instanceNamealready exists innJointControllers(throws if it does) - Create
Controllerwith factory - Check if
Controlleruses at least oneControlDevice - Add
ControllertoArmarXManager - Publish that
NJointControllerwithinstanceNamewas created
Activation:
activateNJointController(name)activateNJointControllers(vector<name>)activateNJointController(NJointControllerBasePtr)activateNJointControllers(vector<NJointControllerBasePtr>)
Steps:
- Check if in
ControlThread - Check if
Devicesare ready - Check if all
controllersToActivateare already active - Copy currently requested
requestedControllersfromControlThreadDataBuffer - Check if
controllersToActivateAreNotInConflictwith each other1 - Check if
requestedControllersare incontrollersToActivateandNotInConflictWith; if not add them tocontrollersToActivate -
setActivateControllersRequestthecontrollersToActivate- Check if in
ControlThread - Check if
Devicesare ready - Create
JointAndNJointControllersrequest - For each controller in
controllersToActivate:- For each
controlDevice2ControlModeinControlDeviceUsedControlModeMap3- Get
jointControlIndexforcontrolDevice2ControlMode -
If
requesthas ajointController(4) atjointControlIndexthrowcontrollers to activate are in conflict(This is were globally is checked that only one controller is active for one device) - Add
JointControllerforControlModetojointControllersofrequestat postionjointControlIndex
- Get
- For each
- For each
JointController:- get currently used
JointControlleratjointControlIndex - if old controller is a
StopMovementControllersetjointController = oldJointController(??, comment says: "don't replace this controller with emergency stop") - else: set the
jointControllerto theEmergencyStopControllerfor thisjointControlIndex
- get currently used
- Write message with the requested controller names as output stream
- Check if in
1 optional<vector<char>> NJointControllerBase::isNotInConflictWith(vector<char> used):
- for each entry in used check if the corresponding entry in
controlDeviceBitmapexists; if yes set the corresponding entry of the output vector totrue -
controlDeviceBitmap= Bitmap of usedControlDevices2 (1 == used, 0 == not used)
- The
ControlDeviceclass represents a logical unit accepting commands via itsJointControllers. - It holds a set of
JointControllerswith different Controll modes.- It always has a
JointControllerwith modeControlModes::EmergencyStopwhich is used in case of an error. - It always has a
JointControllerwith modeControlModes::StopMovementwhich is used when the controled device should stop any movement.
- It always has a
- It holds a set of tags.
- These tags are used by different components to create default controllers, check for abilities or present output to the user.
3 controlDeviceControlModeMap:
- Maps names of used
ControlDevicesto theControlTarget's control mode - Basically represents a mapping from
ControlDevicesto the
Deactivation:
deactivateNJointController(name)deactivateNJointControllers(vector<name>)deactivateNJointController(NJointControllerBasePtr)deactivateNJointControllers(vector<NJointControllerBasePtr>)
Deletion:
deleteNJointController(name)deleteNJointControllers(vector<name>)deleteNJointController(NJointControllerBasePtr)deleteNJointControllers(vector<NJointControllerBasePtr>)
Deactivate and Delete
Edited by Christoph Pohl