Public Types | Public Member Functions | Static Public Attributes

JAUS::ControlDevice Class Reference

Interface for creating controller interfaces (e.g. Joystick, Wiimote) for controlling a Primitive Driver service of an Unmanned System. More...

#include <controldevice.h>

Inheritance diagram for JAUS::ControlDevice:
JAUS::Management::Child JAUS::AccessControl::Child JAUS::Events::Child JAUS::Service JAUS::Joystick JAUS::Keyboard

List of all members.

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 MessageCreateMessage (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, WrenchEffortGetInputIdToWrenchMapping ()

Static Public Attributes

static const std::string Name = "urn:jaus:jss:jpp:extras:ControlDevice"
 String name of the Service.

Detailed Description

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.


Member Enumeration Documentation

Enumeration of possible button mappings.

Enumerator:
RequestDriveControl 

Request drive control.

ReleaseDriveControl 

Release drive control.

Definition at line 66 of file controldevice.h.

Enumeration of different wrench efforts the data can be mapped to.

Enumerator:
PropulsiveLinearEffortX 
PropulsiveLinearEffortY 
PropulsiveLinearEffortZ 
PropulsiveRotationalEffortX 
PropulsiveRotationalEffortY 
PropulsiveRotationalEffortZ 
ResistiveLinearEffortX 
ResistiveLinearEffortY 
ResistiveLinearEffortZ 
ResistiveRotationalEffortX 
ResistiveRotationalEffortY 
ResistiveRotationalEffortZ 

Definition at line 77 of file controldevice.h.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

Message * ControlDevice::CreateMessage ( const UShort  messageCode ) const [virtual]

Given a message code, the Service attempts to create a Message object that can be used for de-serialization of JAUS packets.

Parameters:
[in]messageCodeJAUS Message to try create.
Returns:
Pointer to created message, NULL if message not supported by any Services attached to the Transport.

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.

Returns:
True if control of a Primitive Driver has been established.

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.

Parameters:
[in]filenameName of the XML file containing data.
Returns:
True on success, false on failure.

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.

Parameters:
[in]vehicleIdentificationNameName of robot to load joystick settings for.
[in]directoryName of the directory containing joystick files.
Returns:
True on success, false on failure.

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.

Parameters:
[in]buttonNumberID/Number of the button to map.
[in]actionThe 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.

Parameters:
[in]buttonNumberID/Number of the button to map.
[in]digitalDigital device to toggle on/off.
[in]onPressValue 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.

Parameters:
[in]inputIDID/Number of the input axis/lever, etc.
[in]analogName of analog out to map to.
[in]invertIf true, input value are inverted for this wrench.
[in]limitThe 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%).

Parameters:
[in]inputIDID/Number of the input axis/lever, etc.
[in]wrenchIDThe wrench to map to.
[in]deadzoneIf a desired value is within the deazone range (e.g. 10%) wrench will be set to 0. Values are scaled/offset by deadzones.
[in]invertIf true, input value are inverted for this wrench.
[in]limitThe 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.

Parameters:
[in]controlledComponentThe 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.

Parameters:
[in]idID 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.

Parameters:
[in]buttonNumberID/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.

Parameters:
[in]buttonNumberID/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.

Parameters:
[in]enableIf 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.

Parameters:
[in]inputIDThe ID of the device input axis (e.g. joystick x or y axis).
[in]signalValueSignal 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.

Parameters:
[in]inputIDThe ID of the device input axis (e.g. joystick x or y axis).
[in]percentEffortPercent effort value to send [-100,100]%.

Definition at line 493 of file controldevice.cpp.


Member Data Documentation

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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines