![]() |
Launching a command with a second thumbstick
We are using an Xbox controller for robot control, and would like to use the right thumbstick to call a command - specifically to be able to use the value from GetRawAxis() to determine the speed at which we activate a Victor. I know how to get a button to launch a command in OI, but don't know how to make movement of the right thumbstick do the same. Any ideas?
|
Re: Launching a command with a second thumbstick
Can you have a background command on the relevant subsystem that watches the joystick value and fires off a specific command when the value changes?
But it just sounds like you want a background command that continuously copies the joystick value to the Victor, nothing fancier than that. |
Re: Launching a command with a second thumbstick
Quote:
|
Re: Launching a command with a second thumbstick
Quote:
Thanks in advance for the help Nick |
Re: Launching a command with a second thumbstick
Quote:
Thanks Nick |
Re: Launching a command with a second thumbstick
Quote:
You can simply create a Button like your would a JoystickButton but also pass in a threshold at which point you consider the joystick "pressed". This allows the assignment of multiple commands to different thresholds. Typically we use .5 and -.5 to get both directions from the axis. Once you include the class below you can do the following. I'm assuming you know how to create a JoystickButton in OI. Have the member be an Code:
AnalogJoystickButton* fireDiscButton;Code:
fireDiscButton = new AnalogJoystickButton(shooterStick, XboxController::xbZAxis, -.5);In your actual command you can get your joystick from OI and get the actual value of the axis if you need it for speed. AnalogJoystickButton.h: Code:
#ifndef _ANAOLG_JOYSTICK_BUTTON_H__AnalogJoystickButton.cpp: Code:
#include "AnalogJoystickButton.h"EDIT -- Just to make like easier. XboxController.h: Code:
#ifndef XBOXCONTROLLER_H_XboxController.cpp Code:
#include "XboxController.h" |
Re: Launching a command with a second thumbstick
kylelanman:
Wow! That is awesome! I'm going to pass this on to my lead programmer and see what he makes of it. I'll let you know if I have any questions on implementation, but it looks really solid. I appreciate the help! Nick |
Re: Launching a command with a second thumbstick
teleopInit() is only called at the beginning of teleop, but if you schedule a command that doesn't end from teleopInit(), the scheduler will keep running it throughout teleop.
|
Re: Launching a command with a second thumbstick
Thank you kylelanman and Roboteers! We're using a Thrustmaster X this year and decided that the Throttle and it's slider make for intuitive inputs for an arm we're using. I was going down a different road, and decided to look for something better. Sure enough, a little search on CD yielded an elegant solution :cool:
Eric |
| All times are GMT -5. The time now is 09:18 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi