Aria
2.8.0
|
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... | |
ArJoyHandler * | getJoyHandler (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< ArRatioInputJoydrive > | myFireCB |
bool | myFiredLast |
ArActionRatioInput * | myInput |
ArJoyHandler * | myJoyHandler |
bool | myPreviousUseOSCal |
bool | myPrinting |
ArRobot * | myRobot |
bool | myStopIfNoButtonPressed |
bool | myUseOSCal |
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.
ArRatioInputJoydrive::ArRatioInputJoydrive | ( | ArRobot * | robot, |
ArActionRatioInput * | input, | ||
int | priority = 50 , |
||
bool | stopIfNoButtonPressed = false , |
||
bool | useOSCalForJoystick = true |
||
) |
Constructor.
robot | robot |
input | Action to attach to and use to drive the robot. |
priority | Priority of this joystick input handler with respect to other input objects attached to the input action object. |
stopIfNoButtonPressed | if 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) |
useOSCalForJoystick | if this is true we'll use the OS calibration, if false we'll do our own. See also ArJoyHandler::setUseOSCal() |
bool ArRatioInputJoydrive::getUseOSCal | ( | void | ) |
Gets whether OSCalibration is being used for the joystick or not.
void ArRatioInputJoydrive::setUseOSCal | ( | bool | useOSCal | ) |
Sets whether to use OSCalibration the joystick or not.