Aria  2.8.0
ArRatioInputJoydrive Class Reference

Use computer joystick to control an ArActionRatioInput and drive the robot. More...

#include <ArRatioInputJoydrive.h>

Public Member Functions

 ArRatioInputJoydrive (ArRobot *robot, ArActionRatioInput *input, int priority=50, bool stopIfNoButtonPressed=false, bool useOSCalForJoystick=true)
 Constructor. More...
 
ArJoyHandlergetJoyHandler (void)
 Gets the joyHandler.
 
bool getStopIfNoButtonPressed (void)
 Get if we'll stop if no button is pressed, otherwise just do nothing.
 
bool getUseOSCal (void)
 Gets whether OSCalibration is being used for the joystick or not. More...
 
bool joystickInited (void)
 Whether the joystick is initalized or not.
 
void setStopIfNoButtonPressed (bool stopIfNoButtonPressed)
 Set if we'll stop if no button is pressed, otherwise just do nothing.
 
void setUseOSCal (bool useOSCal)
 Sets whether to use OSCalibration the joystick or not. More...
 
virtual ~ArRatioInputJoydrive ()
 Destructor.
 

Protected Member Functions

void fireCallback (void)
 

Protected Attributes

ArFunctorC< ArRatioInputJoydrivemyFireCB
 
bool myFiredLast
 
ArActionRatioInputmyInput
 
ArJoyHandlermyJoyHandler
 
bool myPreviousUseOSCal
 
bool myPrinting
 
ArRobotmyRobot
 
bool myStopIfNoButtonPressed
 
bool myUseOSCal
 

Detailed Description

Use computer joystick to control an ArActionRatioInput and drive the robot.

This class obtains data from a joystick attached to the computer and provides it to an ArActionRatioInput which drives the robot. (See ArRatioInputRobotJoydrive for a similar class that uses the robot's built in joystick interface.) A callback is attached to the ArActionRatioInput object which reads joystick information and sets requested drive rations on the ArActionRatioInput

If the joystick button is pressed, then input values are set in the ArActionRatioDrive action object to request motion. If the button is not pressed, then either the robot will be stopped via the action (if stopIfNoButtonPressed is true), or no action will be requested and lower priority actions can take over (if stopIfNoButtonPressed is false)

You may need to calibrate the joystick for it to work right, for details about this see ArJoyHandler.

This class creates its own ArJoyHandler object to get input from the joystick, or uses the global ArJoyHandler object in the global Aria class if present. Then it will scale the speed between 0 and the given max for velocity and turning, up and down on the joystick go forwards/backwards while right and left go right and left.

NOTE: The joystick does not save calibration information, so you may need to calibrate the joystick before each time you use it. To do this, press the button for at least a half a second while the joystick is in the middle. Then let go of the button and hold the joystick in the upper left for at least a half second and then in the lower right corner for at least a half second. See also ArJoyHandler.

See also
ArRatioInputRobotJoydrive
ArActionRatioInput
ArJoyHandler

Constructor & Destructor Documentation

◆ ArRatioInputJoydrive()

ArRatioInputJoydrive::ArRatioInputJoydrive ( ArRobot robot,
ArActionRatioInput input,
int  priority = 50,
bool  stopIfNoButtonPressed = false,
bool  useOSCalForJoystick = true 
)

Constructor.

Parameters
robotrobot
inputAction to attach to and use to drive the robot.
priorityPriority of this joystick input handler with respect to other input objects attached to the input action object.
stopIfNoButtonPressedif this is true and there is a joystick and no button is pressed, we cause the action to stop the robot. .. otherwise it'll do nothing (letting lower priority actions fire)
useOSCalForJoystickif this is true we'll use the OS calibration, if false we'll do our own. See also ArJoyHandler::setUseOSCal()

Member Function Documentation

◆ getUseOSCal()

bool ArRatioInputJoydrive::getUseOSCal ( void  )

Gets whether OSCalibration is being used for the joystick or not.

See also
ArJoyHandler::getUseOSCal

◆ setUseOSCal()

void ArRatioInputJoydrive::setUseOSCal ( bool  useOSCal)

Sets whether to use OSCalibration the joystick or not.

See also
ArJoyHandler::setUseOSCal

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