![]() |
Wondering if anyone else is having an issue with Joysticks
I'm writing some code to help the team prototype some drivetrain ideas. As a quick hack, I defined 2 joysticks and was going to use the joystick triggers to control some steering motors. I'm using the WindRiver workbench, and I used the simple template. In the OperatorControl() function I created 2 Joystick objects, and used GetTrigger(). Doing something like this:
Code:
Joystick *left_stick, *right_stick;The odd thing is that the left_stick trigger works just fine (turning on/off the motors), but the right_stick trigger doesn't work at all. Commenting out the left_stick GetTrigger() block of code, and now the right trigger starts working. I've tried allocating the joystick on the stack, using new directly, etc. Bottom line is that I can get only one trigger working at a time. I'm using the KOP joysticks. I'm going to hook up a serial port and put some debug prints but was curious if anyone else is seeing the same thing. I do know that the the GetAxis functions are working because, using the same declarations for the joysticks, I was able to get the TankDrive() function to work properly. |
Re: Wondering if anyone else is having an issue with Joysticks
Try this:
Code:
Joystick *left_stick, *right_stick; |
Re: Wondering if anyone else is having an issue with Joysticks
You don't have to declare them like this
Code:
Joystick *left_stick, *right_stick;Code:
Joystick left_stick(1);//type joystick, variable name left_stick, port 1 |
Re: Wondering if anyone else is having an issue with Joysticks
Quote:
Obvious logic problem with the second logic block, which will stop the motor via the else clause because only one trigger was pushed, at a time. And you get the results I was seeing. One trigger works. As a side note, I had already changed to code to something similar to what you proposed, and it does indeed work because it removes the logic flaw, and has nothing to do with the frequency of the call to the set method. Although, now I'm curious about timing issues with the OperatorControl() function. Do you need to control update rates? And to byteit101, I'm aware that there are several methods, no pun intended, for declaring and allocating variables. One is allocated on the stack, the other is a pointer and is allocated in memory. Either method works just fine. |
| All times are GMT -5. The time now is 02:38. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi