View unanswered posts | View active topics It is currently Mon Nov 18, 2019 12:32 pm






Reply to topic  [ 13 posts ] 
NXT Controller Issues 
Author Message
Rookie

Joined: Thu Oct 23, 2014 11:28 am
Posts: 7
Post NXT Controller Issues
Im using ROBOTC 4.26 With NXT

I have been having issues having my logitech controller. I am using the basic sample code for joystick control, with both motors on the B and C ports. I can use code that tells the motors to move forward or backwards and have no issues, but as soon as I attempt to use the joystick nothing works. Sample:

while(true)
{
getJoystickSettings(joystick); // Update Buttons and Joysticks
motor[motorC] = joystick.joy1_y1;
motor[motorB] = joystick.joy1_y2;
}
This does nothing but if I change motor Cs value to this
motor[motorC] = 100;
It will run at max power forever while B will sit their doing nothing no matter what goes on with the joystick. Anyone have this problem?


Windows 7 with the Logitech F310.


Thu Oct 23, 2014 3:25 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: NXT Controller Issues
Do you have the basic joystick window open while running your code? Because when running through ROBOTC, the joysticks only work if a joystick debugger window is open.

_________________
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 Oct 23, 2014 8:35 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: NXT Controller Issues
BurningLights wrote:
Do you have the basic joystick window open while running your code? Because when running through ROBOTC, the joysticks only work if a joystick debugger window is open.


This is correct; also, can you post the entirety of the code using the [code] tags? You will also need to make sure that you include the joystickdriver.c file at the top of your program in order to enable joystick functionality.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.


Fri Oct 24, 2014 9:45 am
Profile
Rookie

Joined: Sat Oct 25, 2014 5:00 pm
Posts: 3
Post Re: NXT Controller Issues
I am facing the very same problem.
The code is the code of a sample program (with the line for motorA added), it does include the joystickdriver.c file:

#include "JoystickDriver.c"
#pragma DebuggerWindows("joystickSimple")

task main()
{
while(1 == 1)
{
getJoystickSettings(joystick);
motor[motorA] = 25;
motor[motorC] = joystickCopy.joy1_y1;
motor[motorB] = joystickCopy.joy1_y2;
}
}

motorA starts running, motorB and motorC do not react to the joystick.
Debugging the program shows that the joystick variable has always initial value. In other words, it does not get populated.
However, the debug window for the joystick shows the values based on joystick action.

Any help regarding this problem is much appreciated!
Thank you!
Ben


Sat Oct 25, 2014 5:11 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: NXT Controller Issues
Ben wrote:
I am facing the very same problem.
The code is the code of a sample program (with the line for motorA added), it does include the joystickdriver.c file:

#include "JoystickDriver.c"
#pragma DebuggerWindows("joystickSimple")

task main()
{
while(1 == 1)
{
getJoystickSettings(joystick);
motor[motorA] = 25;
motor[motorC] = joystickCopy.joy1_y1;
motor[motorB] = joystickCopy.joy1_y2;
}
}

motorA starts running, motorB and motorC do not react to the joystick.
Debugging the program shows that the joystick variable has always initial value. In other words, it does not get populated.
However, the debug window for the joystick shows the values based on joystick action.

Any help regarding this problem is much appreciated!
Thank you!
Ben


Well, one thing that I can immediately spot is that the code uses joystickCopy to get the joystick data, not joystick. Those two lines should look like this:
Code:
motor[motorC] = joystick.joy1_y1;
motor[motorB] = joystick.joy1_y2;


I don't know if this will fix your problem for sure, but it is the proper way to use the joysticks, since joystickCopy is just kind of a temporary holding place for the joystick data.

_________________
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/.


Sat Oct 25, 2014 10:16 pm
Profile
Rookie

Joined: Sat Oct 25, 2014 5:00 pm
Posts: 3
Post Re: NXT Controller Issues
Thank you very much for the reply.
You are correct. The code should use the joystick variable (not joystickCopy).
In my tests, I did use the correct variables as you suggest.

The program does not receive the joystick values.

Best,
Ben


Sat Oct 25, 2014 11:49 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: NXT Controller Issues
When you run your program it should display some joystick diagnostic information on the NXT screen. Of most interest, at the top it should say "TeleOp Running" and about midway you'll see "FMS Msgs:". The number next to that should be steadily increasing.

_________________
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 Oct 26, 2014 12:13 pm
Profile
Rookie

Joined: Thu Oct 23, 2014 11:28 am
Posts: 7
Post Re: NXT Controller Issues
BurningLights wrote:
Do you have the basic joystick window open while running your code? Because when running through ROBOTC, the joysticks only work if a joystick debugger window is open.


Yea that is always open

My code
Code:
#include "JoystickDriver.c"
#pragma DebuggerWindows("joystickSimple")

task main()
{
   while(true)
   {
      getJoystickSettings(joystick);
      motor[motorB] = joystick.joy1_y1;
      motor[motorC]= joystick.joy1_y2;
   }
}


Mon Oct 27, 2014 12:42 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: NXT Controller Issues
BurningLights wrote:
When you run your program it should display some joystick diagnostic information on the NXT screen. Of most interest, at the top it should say "TeleOp Running" and about midway you'll see "FMS Msgs:". The number next to that should be steadily increasing.


Is this what you see on your screen when your program is running?

_________________
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 Oct 27, 2014 8:31 pm
Profile
Rookie

Joined: Thu Oct 23, 2014 11:28 am
Posts: 7
Post Re: NXT Controller Issues
None of what you said is coming up for me. How do I have robotc show those


Mon Oct 27, 2014 10:50 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: NXT Controller Issues
garyroachfreeman wrote:
None of what you said is coming up for me. How do I have robotc show those

Insert
Code:
bDisplayDiagnostics = true;

at the top of your task main(). That should make the joystick driver display the diagnostic information when you run the program.

_________________
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 Oct 28, 2014 4:50 pm
Profile
Rookie

Joined: Thu Oct 23, 2014 11:28 am
Posts: 7
Post Re: NXT Controller Issues
I sent a request to the ROBOTC support and they told me to turn off natural language under Robot->Platform Type. I really hope this solves other peoples issues.


Wed Oct 29, 2014 9:30 am
Profile
Rookie

Joined: Sat Oct 25, 2014 5:00 pm
Posts: 3
Post Re: NXT Controller Issues
Thank you for sharing the result of the RobotC support call!
Turning off natural language resolved the problem for us.


Thu Oct 30, 2014 7:25 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 13 posts ] 

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.