View unanswered posts | View active topics It is currently Sat Mar 23, 2019 9:07 am






Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Use joystick with USB cable 
Author Message
Rookie

Joined: Mon Oct 13, 2014 12:02 pm
Posts: 18
Post 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


Sun Jan 04, 2015 6:56 am
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post 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:

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Sun Jan 04, 2015 2:53 pm
Profile
Rookie

Joined: Mon Oct 13, 2014 12:02 pm
Posts: 18
Post 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


Mon Jan 05, 2015 8:21 am
Profile
Rookie

Joined: Mon Oct 13, 2014 12:02 pm
Posts: 18
Post 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 ?


Mon Jan 05, 2015 1:46 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post 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:

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Mon Jan 05, 2015 5:52 pm
Profile
Rookie

Joined: Mon Oct 13, 2014 12:02 pm
Posts: 18
Post 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.


Tue Jan 06, 2015 6:05 am
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post 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.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Tue Jan 06, 2015 9:43 am
Profile
Rookie

Joined: Mon Oct 13, 2014 12:02 pm
Posts: 18
Post 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


Tue Jan 06, 2015 1:27 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post 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.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Tue Jan 06, 2015 3:23 pm
Profile
Rookie

Joined: Mon Oct 13, 2014 12:02 pm
Posts: 18
Post 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


Wed Jan 07, 2015 3:59 pm
Profile
Rookie

Joined: Mon Oct 13, 2014 12:02 pm
Posts: 18
Post 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


Wed Jan 07, 2015 4:00 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post 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

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Thu Jan 08, 2015 5:43 am
Profile WWW
Rookie

Joined: Mon Oct 13, 2014 12:02 pm
Posts: 18
Post 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.


Thu Jan 08, 2015 9:20 am
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post 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.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Thu Jan 08, 2015 9:32 am
Profile
Rookie

Joined: Mon Oct 13, 2014 12:02 pm
Posts: 18
Post 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.


Sat Jan 10, 2015 10:31 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 16 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.