ROBOTC.net forums
http://robotc.net/forums/

Use joystick with USB cable
http://robotc.net/forums/viewtopic.php?f=1&t=10147
Page 1 of 2

Author:  Koenigsegg1525 [ Sun Jan 04, 2015 6:56 am ]
Post subject:  Use joystick with USB cable

Hello everyone,
I'm currently trying to make a robot that can be controlled with a joystick but I'm encountering some issues with the bluetooth and so on, and I've heard that it was possible to use the USB cable instead of a bluetooth connection. It would really help me since I've never had a problem with the USB connection but I don't know how to do it if it's even possible. Can somebody tell me how to do it ?
thank you
Anthony

Author:  BurningLights [ Sun Jan 04, 2015 2:53 pm ]
Post subject:  Re: Use joystick with USB cable

Are you running your program through ROBOTC? If so, it's exactly the same, except that your robot will be connected by USB instead of by Bluetooth. :bigthumb:

Author:  Koenigsegg1525 [ Mon Jan 05, 2015 8:21 am ]
Post subject:  Re: Use joystick with USB cable

thank you very much. I had no clue it was this easy, I'll try it as soon as I can

Author:  Koenigsegg1525 [ Mon Jan 05, 2015 1:46 pm ]
Post subject:  Re: Use joystick with USB cable

Ok so it looks like I've got a problem. but it comes from my controller this time: my joysticks are recognized badly and it doesn't change anything wether it's on Xinput or DIrectinput mode, in Dinput mode in Robot>LEGO brick>Joystick control - basic only one joystick is recognized (but it doesn't matter since I only need one) but if I go on Robot>debugger window>joystick control-basic it says "joystick not equipped". If I put it in Xinput mode first the buttons are messed up and the joysticks are weird: they are both set to 127 for both axes and only have 127 or 0 as a value. what's the matter ?

Author:  BurningLights [ Mon Jan 05, 2015 5:52 pm ]
Post subject:  Re: Use joystick with USB cable

Ok, so the DirectInput mode is the correct one for using joysticks with ROBOTC. The joystick should always be in DirectInput mode when it is being used with ROBOTC.
Now, to your other issues. I hope I'm understanding what you're saying correctly, so if I don't seem to be, let me know. Joystick Control-Basic only lets you use one joystick. In other words, you cannot use two with the Basic mode. And if you see a joystick window saying "Joystick Not Equipped", you simply need to click the arrow on the drop-down box and select the joystick you want to use. I hope I'm answering your questions. Just let me know if anything doesn't make sense. :mrgreen:

Author:  Koenigsegg1525 [ Tue Jan 06, 2015 6:05 am ]
Post subject:  Re: Use joystick with USB cable

thank you for the tip about the controller's differences between basic and competition and the input mode to use, but I can't find competition mode under debbuging windows, there is only basic. On DirectInput the drop-down box only shows one controller and it doesn't change anything if I click on refresh list the "joystick not equipped" window won't disappear.

Author:  BurningLights [ Tue Jan 06, 2015 9:43 am ]
Post subject:  Re: Use joystick with USB cable

So, I just realized, are you using ROBOTC 4? If so, the other joystick window has been renamed Joystick Control - Competition. And I believe it has been moved to the LEGO Brick submenu. As for your other issues, I'll have to monkey around with ROBOTC for a bit and see if I can replicate them.

Author:  Koenigsegg1525 [ Tue Jan 06, 2015 1:27 pm ]
Post subject:  Re: Use joystick with USB cable

Yes I'm using robotC 4. I've been trying other things and opening other windows and I found out some other problems:
-Apparently both joysticks (oh and by joystick do you mean controler? because I wasn't sure when I was reading your reply) are recognized by the joystick configuration window but only one joystick (the left one) is recognized in the joystick control-competition window.
-I don't know what are the other options that appear in the competition window and maybe it could help fix my problem. Could you explain me a bit ?
-the joystick control-competition window disappears when I execute my programm and if I try to re-open it while the programm is running it stops the programm

Author:  BurningLights [ Tue Jan 06, 2015 3:23 pm ]
Post subject:  Re: Use joystick with USB cable

Sorry for the confusion. When I mean the little sticks on the controller I say thumbstick. And I have the unfortunate habit of using joystick, controller, and gamepad all interchangeably... :oops: I guess from now on I'll try to use controller to mean the big blue thing with buttons on it. :D
Anyhow... So, I haven't been running across any serious issues. If only the left stick is being recognized it sounds like your controller is in Xbox mode. Check to make sure the switch on the back of the controller is set to "D."
As for the extra stuff on the Joystick Control - Competition window, that allows you to start and stop your program, and choose which program to run. To use the controllers to control your robot, you'll want to select your program in Teleop Program Name drop down box. And then click on the "Tele Op: Ready" option to start your program, and then the "Tele Op: Running" option to make it go. And hopefully that should work for you.

Author:  Koenigsegg1525 [ Wed Jan 07, 2015 3:59 pm ]
Post subject:  Re: Use joystick with USB cable

I've been trying again to make everything work but it still won't work. Nevertheless I know now that my problem may come from only two things:
-My RobotC programm don't send the commands to the robot
-My robot don't receive/can't break the datas.

I'll ask my teacher if I can borrow another NXT brick to test it and I'll wait till the next update of RobotC is released (I'm still on the 4.26 since the robotC update programm downloads the package installs it puts a shortcut on the desktop but when I double-click on the shortcut, the opening window says 4.26) to see if it fixes my problem.

I've got one last question: I just don't understand the logic behind one thing: on the tutorial about the buttons on the controller, it says that to detect if the button 6 is pressed I have to test the value 32 (pic). Why 32 and not 6 ?
Image

Author:  Koenigsegg1525 [ Wed Jan 07, 2015 4:00 pm ]
Post subject:  Re: Use joystick with USB cable

oups the pic didn't went out as expected. Here have the link.
https://www.dropbox.com/s/isnxnon4sxp4c ... k.PNG?dl=0

Author:  mightor [ Thu Jan 08, 2015 5:43 am ]
Post subject:  Re: Use joystick with USB cable

What happens when button is let go? Does the robot stop moving? If it doesn't, why do you think that isn't the case?

= Xander

Author:  Koenigsegg1525 [ Thu Jan 08, 2015 9:20 am ]
Post subject:  Re: Use joystick with USB cable

the robot does not even start moving when I move the joystick. Controller is recognized and values seem right but when I lauch the programm and move the joystick the robot doesn't move a bit.

Author:  BurningLights [ Thu Jan 08, 2015 9:32 am ]
Post subject:  Re: Use joystick with USB cable

Koenigsegg1525 wrote:
the robot does not even start moving when I move the joystick. Controller is recognized and values seem right but when I lauch the programm and move the joystick the robot doesn't move a bit.

I'm wondering, do you have Natural Language enabled? There is a problem that controllers do not work correctly in 4.26 if Natural Language is enabled. I would recommend upgrading to version 4.27 - that problem is supposed to fixed in it.
As to the 32 thing, the joystick.joy1_Buttons is what is known as a bit mask, where every bit in a number represents something different. In this case, every bit represents if a button is pressed or not. So, every button is represented by a number 2^(button number - 1). The only problem is, these numbers are added together when multiple buttons are pressed, so the code example only works if button 6 is the only button that is pressed.

Author:  Koenigsegg1525 [ Sat Jan 10, 2015 10:31 am ]
Post subject:  Re: Use joystick with USB cable

I have disabled natural language but the only thing it changed was that I had to include "joystickDriver.c" for the programm to compile. Thanks for the explaination about the values on the controller and the Bit mask. I've already tried to upgrade several times but though the programm was installed the program still says "version 4.26" when it opens.

Page 1 of 2 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/