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

NXT Controller Issues
http://robotc.net/forums/viewtopic.php?f=1&t=9618
Page 1 of 1

Author:  garyroachfreeman [ Thu Oct 23, 2014 3:25 pm ]
Post subject:  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.

Author:  BurningLights [ Thu Oct 23, 2014 8:35 pm ]
Post subject:  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.

Author:  JohnWatson [ Fri Oct 24, 2014 9:45 am ]
Post subject:  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.

Author:  Ben [ Sat Oct 25, 2014 5:11 pm ]
Post subject:  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

Author:  BurningLights [ Sat Oct 25, 2014 10:16 pm ]
Post subject:  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.

Author:  Ben [ Sat Oct 25, 2014 11:49 pm ]
Post subject:  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

Author:  BurningLights [ Sun Oct 26, 2014 12:13 pm ]
Post subject:  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.

Author:  garyroachfreeman [ Mon Oct 27, 2014 12:42 pm ]
Post subject:  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;
   }
}

Author:  BurningLights [ Mon Oct 27, 2014 8:31 pm ]
Post subject:  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?

Author:  garyroachfreeman [ Mon Oct 27, 2014 10:50 pm ]
Post subject:  Re: NXT Controller Issues

None of what you said is coming up for me. How do I have robotc show those

Author:  BurningLights [ Tue Oct 28, 2014 4:50 pm ]
Post subject:  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.

Author:  garyroachfreeman [ Wed Oct 29, 2014 9:30 am ]
Post subject:  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.

Author:  Ben [ Thu Oct 30, 2014 7:25 pm ]
Post subject:  Re: NXT Controller Issues

Thank you for sharing the result of the RobotC support call!
Turning off natural language resolved the problem for us.

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