Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Robot drives forward with no joystick connected (http://www.chiefdelphi.com/forums/showthread.php?t=135112)

GuyM142 24-02-2015 00:39

Robot drives forward with no joystick connected
 
I have noticed that when I'm not connecting the driver's joystick to the laptop the rocky just drives forward when enabled.
It's pretty dangerous and happens frequently because we use 2 laptops ac don't always move the joystick between them.
What can be done?

Levansic 24-02-2015 02:39

Re: Robot drives forward with no joystick connected
 
What is your drive setup? Are you directly feeding the joystick data into a drive VI like arcade or holonomic (mechanum)?

Does this happen all of the time, or just some of the time?

We have had this in the past, if someone was displacing the joystick while plugging it in, like pulling it slightly backwards. This happens when someone is holding the joystick as another person plugs it in to the USB port. Windows takes the initial position when plugged in as the default zero, so when the stick is released to its natural zero point, the computer thinks it is being pushed off of zero.

GuyM142 24-02-2015 04:48

Quote:

Originally Posted by Levansic (Post 1449091)
What is your drive setup? Are you directly feeding the joystick data into a drive VI like arcade or holonomic (mechanum)?

Does this happen all of the time, or just some of the time?

We have had this in the past, if someone was displacing the joystick while plugging it in, like pulling it slightly backwards. This happens when someone is holding the joystick as another person plugs it in to the USB port. Windows takes the initial position when plugged in as the default zero, so when the stick is released to its natural zero point, the computer thinks it is being pushed off of zero.

We just use the x and y axes for holonomic drive.
The weird thing is that it happens only for driving and only forward (y axis).
Happens every time the joystick is not plugged in.

Greg McKaskle 24-02-2015 07:00

Re: Robot drives forward with no joystick connected
 
If you request a joystick value, and the joystick isn't plugged in, the VI returns empty arrays. If you then index those empty arrays, LV will return the default value for that array type -- numbers will be zero, Booleans false, etc.

We were sort seeing the same thing earlier in the season with the POVs. The array was empty, but they were indexed anyway. The index returns a zero, which meant up on the elevator.

So, does any of this explain why this was happening? If not, can you post the code or a picture of the code that reads the joysticks and sends values to drive?

Greg McKaskle

GuyM142 24-02-2015 07:34

Re: Robot drives forward with no joystick connected
 
Quote:

Originally Posted by Greg McKaskle (Post 1449106)
If you request a joystick value, and the joystick isn't plugged in, the VI returns empty arrays. If you then index those empty arrays, LV will return the default value for that array type -- numbers will be zero, Booleans false, etc.

We were sort seeing the same thing earlier in the season with the POVs. The array was empty, but they were indexed anyway. The index returns a zero, which meant up on the elevator.

So, does any of this explain why this was happening? If not, can you post the code or a picture of the code that reads the joysticks and sends values to drive?

Greg McKaskle

That's it!
We use the POV to make the mecanum go straight in any direction.
Is there a solution for this?

Greg McKaskle 24-02-2015 07:46

Re: Robot drives forward with no joystick connected
 
1 Attachment(s)
We added code to check the array size of the POV before blindly indexing it.

The attached image returns a -1 instead of a zero. This still may not be what you want, but it shows how to detect an empty array and control the downstream value. You can also put your code into a case structure and only execute it if the array size is not zero.

Greg McKaskle


All times are GMT -5. The time now is 10:26.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi