Interface for creating controller interfaces (e.g. Joystick, Wiimote) for controlling a Primitive Driver service of an Unmanned System. More...
#include <controldevice.h>
Public Types | |
enum | ButtonActions { RequestDriveControl = 0, ReleaseDriveControl } |
Enumeration of possible button mappings. More... | |
enum | WrenchEffort { PropulsiveLinearEffortX = 0, PropulsiveLinearEffortY, PropulsiveLinearEffortZ, PropulsiveRotationalEffortX, PropulsiveRotationalEffortY, PropulsiveRotationalEffortZ, ResistiveLinearEffortX, ResistiveLinearEffortY, ResistiveLinearEffortZ, ResistiveRotationalEffortX, ResistiveRotationalEffortY, ResistiveRotationalEffortZ } |
Enumeration of different wrench efforts the data can be mapped to. More... | |
Public Member Functions | |
ControlDevice () | |
Constructor, initializes default value. | |
virtual | ~ControlDevice () |
Destructor. | |
virtual bool | LoadSettings (const std::string &filename) |
Loads settings for the service from an XML file. | |
virtual bool | LoadSettingsForVehicle (const std::string &vehicleIdentificationName, const std::string &directory) |
Loads settings for the service from an XML file. | |
virtual void | Shutdown () |
Shutsdown the service. | |
void | SetSubsystemToControl (const UShort id) |
Sets the ID of the subsystem to control with the control device. | |
virtual void | TakeDriveControl (const bool enable=true) |
Takes or releases control of the Primitive Driver service on the subsystem being controlled. | |
virtual bool | HaveDriveControl () const |
Method to check if Control Device has control of a Primitive Driver. | |
virtual void | SignalButtonPress (const int buttonNumber) |
Method to call when a button is pressed. Method will convert button number to a ButtonActions command based on button mappings. | |
virtual void | SignalButtonRelease (const int buttonNumber) |
Method to call when a button is released. Method will convert button number to a ButtonActions command based on button mappings. | |
virtual void | UpdateWrench (const int inputID, const double percentEffort) |
Updates the value of a Wrench for the Set Wrench Effort command being sent to the controlled Primitive Driver. | |
virtual void | UpdateAnalogOut (const int inputID, const double signalValue) |
Updates the value of a Set Microcontroller State message to transmit to any Microcontroller Service of the vehicle we are controlling. | |
virtual void | SendWrenchEffort () |
Sends the current wrench effort built using the UpdateWrench method to the Primitive Driver service being controlled. | |
virtual void | SendMicrocontrollerState () |
Sends the current wrench effort built using the UpdateWrench method to the Primitive Driver service being controlled. | |
virtual void | ClearWrenchEffort () |
Clears the current wrench effort. | |
virtual void | ClearMicrocontrollState () |
Clears the current Set Microcontroller State message. | |
virtual void | MapButtonToAction (const int buttonNumber, const ButtonActions action) |
Method to map a button ID/number to an button action. | |
virtual void | MapButtonToDigitalOut (const int buttonNumber, const std::string &digital, const bool onPress=true) |
Method to map a button ID/number to a digital state output. | |
virtual void | MapInputToWrench (const int inputID, const WrenchEffort wrenchID, const double deadzone, const bool invert, const double limit) |
Method to map an control device input ID to a wrench effort ID value. | |
virtual void | MapInputToAnalogOut (const int inputID, const std::string &analog, const bool invert, const double limit) |
Method to map an control device input ID to analog out. | |
virtual void | CheckServiceStatus (const unsigned int timeSinceLastCheckMs) |
Called periodicly by the Component the service belongs to. This method attempts to lookup a primitive driver on the subsystem we are trying to control. | |
virtual bool | GenerateEvent (const Events::Subscription &info) const |
virtual bool | IsEventSupported (const Events::Type type, const double requestedPeriodicRate, const Message *queryMessage, double &confirmedPeriodicRate, std::string &errorMessage) const |
virtual void | ProcessAcquisitionOfControl (const Address &controlledComponent) |
This method is called whenever our component is able to acquire control of a component. | |
virtual bool | IsDiscoverable () const |
virtual void | Receive (const Message *message) |
Processes messages received by the component that are supported by this service. | |
virtual Message * | CreateMessage (const UShort messageCode) const |
Given a message code, the Service attempts to create a Message object that can be used for de-serialization of JAUS packets. | |
virtual bool | Resume () |
virtual bool | Reset () |
virtual bool | Standby () |
virtual bool | SetEmergency () |
virtual bool | ClearEmergency () |
virtual bool | ReleaseControl () |
Method called whenever control of the parent component has been released. | |
virtual void | PrintStatus () const |
Prints service status. | |
Address | GetDriverID () const |
std::map< int, WrenchEffort > | GetInputIdToWrenchMapping () |
Static Public Attributes | |
static const std::string | Name = "urn:jaus:jss:jpp:extras:ControlDevice" |
String name of the Service. |
Interface for creating controller interfaces (e.g. Joystick, Wiimote) for controlling a Primitive Driver service of an Unmanned System.
Definition at line 58 of file controldevice.h.
Enumeration of possible button mappings.
Definition at line 66 of file controldevice.h.
Enumeration of different wrench efforts the data can be mapped to.
Definition at line 77 of file controldevice.h.
ControlDevice::ControlDevice | ( | ) |
Constructor, initializes default value.
Definition at line 59 of file controldevice.cpp.
ControlDevice::~ControlDevice | ( | ) | [virtual] |
Destructor.
Definition at line 78 of file controldevice.cpp.
void ControlDevice::CheckServiceStatus | ( | const unsigned int | timeSinceLastCheckMs ) | [virtual] |
Called periodicly by the Component the service belongs to. This method attempts to lookup a primitive driver on the subsystem we are trying to control.
Reimplemented from JAUS::Service.
Reimplemented in JAUS::Joystick, and JAUS::Keyboard.
Definition at line 831 of file controldevice.cpp.
virtual bool JAUS::ControlDevice::ClearEmergency | ( | ) | [inline, virtual] |
Reimplemented from JAUS::Management::Child.
Definition at line 169 of file controldevice.h.
void ControlDevice::ClearMicrocontrollState | ( | ) | [virtual] |
Clears the current Set Microcontroller State message.
Definition at line 714 of file controldevice.cpp.
void ControlDevice::ClearWrenchEffort | ( | ) | [virtual] |
Clears the current wrench effort.
Definition at line 702 of file controldevice.cpp.
Given a message code, the Service attempts to create a Message object that can be used for de-serialization of JAUS packets.
Implements JAUS::Service.
Definition at line 916 of file controldevice.cpp.
virtual bool JAUS::ControlDevice::GenerateEvent | ( | const Events::Subscription & | info ) | const [inline, virtual] |
Implements JAUS::Events::Child.
Definition at line 146 of file controldevice.h.
Address JAUS::ControlDevice::GetDriverID | ( | ) | const [inline] |
Definition at line 175 of file controldevice.h.
std::map<int, WrenchEffort> JAUS::ControlDevice::GetInputIdToWrenchMapping | ( | ) | [inline] |
Definition at line 177 of file controldevice.h.
bool ControlDevice::HaveDriveControl | ( | ) | const [virtual] |
Method to check if Control Device has control of a Primitive Driver.
Definition at line 378 of file controldevice.cpp.
virtual bool JAUS::ControlDevice::IsDiscoverable | ( | ) | const [inline, virtual] |
Implements JAUS::Service.
Definition at line 155 of file controldevice.h.
virtual bool JAUS::ControlDevice::IsEventSupported | ( | const Events::Type | type, |
const double | requestedPeriodicRate, | ||
const Message * | queryMessage, | ||
double & | confirmedPeriodicRate, | ||
std::string & | errorMessage | ||
) | const [inline, virtual] |
Implements JAUS::Events::Child.
Definition at line 148 of file controldevice.h.
bool ControlDevice::LoadSettings | ( | const std::string & | filename ) | [virtual] |
Loads settings for the service from an XML file.
[in] | filename | Name of the XML file containing data. |
Reimplemented from JAUS::Service.
Reimplemented in JAUS::Joystick, and JAUS::Keyboard.
Definition at line 93 of file controldevice.cpp.
bool ControlDevice::LoadSettingsForVehicle | ( | const std::string & | vehicleIdentificationName, |
const std::string & | directory | ||
) | [virtual] |
Loads settings for the service from an XML file.
[in] | vehicleIdentificationName | Name of robot to load joystick settings for. |
[in] | directory | Name of the directory containing joystick files. |
Definition at line 242 of file controldevice.cpp.
void ControlDevice::MapButtonToAction | ( | const int | buttonNumber, |
const ButtonActions | action | ||
) | [virtual] |
Method to map a button ID/number to an button action.
[in] | buttonNumber | ID/Number of the button to map. |
[in] | action | The action to map the button to (e.g. TakeDriveControl). |
Definition at line 729 of file controldevice.cpp.
void ControlDevice::MapButtonToDigitalOut | ( | const int | buttonNumber, |
const std::string & | digital, | ||
const bool | onPress = true |
||
) | [virtual] |
Method to map a button ID/number to a digital state output.
[in] | buttonNumber | ID/Number of the button to map. |
[in] | digital | Digital device to toggle on/off. |
[in] | onPress | Value to send when button is pressed, opposit value is sent on release. |
Definition at line 747 of file controldevice.cpp.
void ControlDevice::MapInputToAnalogOut | ( | const int | inputID, |
const std::string & | analog, | ||
const bool | invert, | ||
const double | limit | ||
) | [virtual] |
Method to map an control device input ID to analog out.
[in] | inputID | ID/Number of the input axis/lever, etc. |
[in] | analog | Name of analog out to map to. |
[in] | invert | If true, input value are inverted for this wrench. |
[in] | limit | The maximum value (positive and negative) that can be set for an analog signal. [1-100). |
Definition at line 809 of file controldevice.cpp.
void ControlDevice::MapInputToWrench | ( | const int | inputID, |
const WrenchEffort | wrenchID, | ||
const double | deadzone, | ||
const bool | invert, | ||
const double | limit | ||
) | [virtual] |
Method to map an control device input ID to a wrench effort ID value.
An example could be mapping a joystick axis (e.g. X axis = 1) to a wrench effort (e.g. PropulsiveLinearEffortX).
For example, if you set the limit to 50, and you try to sent a value of 100% for the matching wrench, the resulting wrench will be 100% of the limit (e.g. desired*limit/100 = 100*50/100 = 50%).
[in] | inputID | ID/Number of the input axis/lever, etc. |
[in] | wrenchID | The wrench to map to. |
[in] | deadzone | If a desired value is within the deazone range (e.g. 10%) wrench will be set to 0. Values are scaled/offset by deadzones. |
[in] | invert | If true, input value are inverted for this wrench. |
[in] | limit | The maximum value (positive and negative) that can be set for a wrench. [1-100). |
Definition at line 778 of file controldevice.cpp.
void ControlDevice::PrintStatus | ( | ) | const [virtual] |
Prints service status.
Reimplemented from JAUS::Service.
Definition at line 935 of file controldevice.cpp.
void ControlDevice::ProcessAcquisitionOfControl | ( | const Address & | controlledComponent ) | [virtual] |
This method is called whenever our component is able to acquire control of a component.
For a ControlDevice, if the ID matches that of the Primitive Driver component we are trying to drive, then this method sends a Resume command to it.
[in] | controlledComponent | The component we took control of. |
Reimplemented from JAUS::AccessControl::Child.
Definition at line 877 of file controldevice.cpp.
void ControlDevice::Receive | ( | const Message * | message ) | [virtual] |
Processes messages received by the component that are supported by this service.
Reimplemented from JAUS::Service.
Definition at line 899 of file controldevice.cpp.
virtual bool JAUS::ControlDevice::ReleaseControl | ( | ) | [inline, virtual] |
Method called whenever control of the parent component has been released.
Reimplemented from JAUS::Management::Child.
Definition at line 171 of file controldevice.h.
virtual bool JAUS::ControlDevice::Reset | ( | ) | [inline, virtual] |
Implements JAUS::Management::Child.
Definition at line 163 of file controldevice.h.
virtual bool JAUS::ControlDevice::Resume | ( | ) | [inline, virtual] |
Implements JAUS::Management::Child.
Definition at line 161 of file controldevice.h.
void ControlDevice::SendMicrocontrollerState | ( | ) | [virtual] |
Sends the current wrench effort built using the UpdateWrench method to the Primitive Driver service being controlled.
Definition at line 676 of file controldevice.cpp.
void ControlDevice::SendWrenchEffort | ( | ) | [virtual] |
Sends the current wrench effort built using the UpdateWrench method to the Primitive Driver service being controlled.
Definition at line 649 of file controldevice.cpp.
virtual bool JAUS::ControlDevice::SetEmergency | ( | ) | [inline, virtual] |
Reimplemented from JAUS::Management::Child.
Definition at line 167 of file controldevice.h.
void ControlDevice::SetSubsystemToControl | ( | const UShort | id ) |
Sets the ID of the subsystem to control with the control device.
[in] | id | ID number of the subsystem. |
Definition at line 318 of file controldevice.cpp.
void ControlDevice::Shutdown | ( | ) | [virtual] |
Shutsdown the service.
Reimplemented from JAUS::Service.
Reimplemented in JAUS::Joystick, and JAUS::Keyboard.
Definition at line 289 of file controldevice.cpp.
void ControlDevice::SignalButtonPress | ( | const int | buttonNumber ) | [virtual] |
Method to call when a button is pressed. Method will convert button number to a ButtonActions command based on button mappings.
For digital out mappings, a button press turns a mapped digital out to true. For example, on button press, turn trigger digital out to 1. For reset to 0, see SignalButtonRelease.
[in] | buttonNumber | ID/Number of the button that was pressed. |
Definition at line 403 of file controldevice.cpp.
void ControlDevice::SignalButtonRelease | ( | const int | buttonNumber ) | [virtual] |
Method to call when a button is released. Method will convert button number to a ButtonActions command based on button mappings.
For digital out mappings, a button press turns a mapped digital out to false. For example, on button release, turn trigger digital out to 0. For reset to 1, see SignalButtonPress.
[in] | buttonNumber | ID/Number of the button that was released. |
Definition at line 455 of file controldevice.cpp.
virtual bool JAUS::ControlDevice::Standby | ( | ) | [inline, virtual] |
Implements JAUS::Management::Child.
Definition at line 165 of file controldevice.h.
void ControlDevice::TakeDriveControl | ( | const bool | enable = true ) |
[virtual] |
Takes or releases control of the Primitive Driver service on the subsystem being controlled.
[in] | enable | If true, take control, false to release. |
Definition at line 364 of file controldevice.cpp.
void ControlDevice::UpdateAnalogOut | ( | const int | inputID, |
const double | signalValue | ||
) | [virtual] |
Updates the value of a Set Microcontroller State message to transmit to any Microcontroller Service of the vehicle we are controlling.
[in] | inputID | The ID of the device input axis (e.g. joystick x or y axis). |
[in] | signalValue | Signal value to send [-100,100]%. |
Definition at line 615 of file controldevice.cpp.
void ControlDevice::UpdateWrench | ( | const int | inputID, |
const double | percentEffort | ||
) | [virtual] |
Updates the value of a Wrench for the Set Wrench Effort command being sent to the controlled Primitive Driver.
Based on input mappings to wrenches, the inputID is converted to a specfice Wrench Effort (e.g. 1 maps to PropulsiveLinearEffortX).
This method will also automatically apply deadzones, inversion, and scaling to the percent effort being set.
[in] | inputID | The ID of the device input axis (e.g. joystick x or y axis). |
[in] | percentEffort | Percent effort value to send [-100,100]%. |
Definition at line 493 of file controldevice.cpp.
const std::string ControlDevice::Name = "urn:jaus:jss:jpp:extras:ControlDevice" [static] |
String name of the Service.
Definition at line 92 of file controldevice.h.