View unanswered posts | View active topics It is currently Sun Dec 16, 2018 12:24 pm






Reply to topic  [ 6 posts ] 
Noob joystick control question 
Author Message
Rookie

Joined: Tue Oct 28, 2014 7:53 am
Posts: 3
Post Noob joystick control question
Hello all,

I'm a programmer for an FTC team this year. This is our FTC teams first year, however this isn't my first time programming, as our FTC team is an off-shoot of FRC team Sparky 384, of whom I am the head programmer for.

My question is thus: I have a lot of experience programming in c and c++, however I cannot find example joystick control code anywhere, and any tutorials I see do not seem to work for me. I write this:
Code:
#pragma config(Hubs,  S4, HTMotor,  none,     none,     none)
#pragma config(Motor,  mtr_S4_C1_1,     leftDrive,     tmotorTetrix, openLoop, driveLeft)
#pragma config(Motor,  mtr_S4_C1_2,     rightDrive,    tmotorTetrix, openLoop, driveRight)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

void initializeRobot () {

}

task main()
 {
  initializeRobot();

  //waitForStart();
   while(true)
     {
      //User Control code goes here.
     getJoystickSettings(joystick);
     //motor[leftDrive] = joystick.joy1_y1;
     //motor[rightDrive] = -joystick.joy1_y2;
     motor[leftDrive] = 75;
     motor[rightDrive] = -75;
     }
 }


and this works. However, when I comment out the 75 lines and recomment in the two joystick lines, I cannot control the robot with the joystick. I have selected joystick control basic and checked that the game controller (logitech gamepad F310) is in fact being seen as joystick 1, and the joystick does give proper input when I move it around. However, when I run joystick code and move the joystick the robot stays completely stationary.

Does anyone have any advice? I know for to get the external motor controllers to work I had to turn that on. Is there any other setting that I am missing to get the joystick values to the robot?

Also, when I comment in the waitForStart() function, it compiles fine, but then when I deploy and I try and run the code, nothing happens. Is there a way to tell the robot to begin in shop, or is that line only necessary for competition?

Thank you very much in advance!


Tue Oct 28, 2014 8:14 am
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Noob joystick control question
Just wondering, are you using ROBOTC version 4.26 or 3.62? There seem to be a lot of people having issues with joysticks in 4.26.

_________________
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 11:06 am
Profile
Rookie

Joined: Tue Oct 28, 2014 7:53 am
Posts: 3
Post Re: Noob joystick control question
4.26. I'm glad I'm not the only one with issue. Has there been a reliable fix discovered as of yet? and do you know anything about the waitForStart() issue?


Tue Oct 28, 2014 11:57 am
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Noob joystick control question
The waitForStart() is what makes your program wait for the FCS to tell it to go at competitions. For testing, you can comment this out, or you can use the Joystick Control - Advanced/Game/FTC. It seems to keep changing names :? , but you should be able to find one of those. With this, you can mimic all of the functionality of the FCS, so you can test while still having the waitForStart() in your code.

_________________
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 12:31 pm
Profile
Rookie

Joined: Tue Oct 28, 2014 7:53 am
Posts: 3
Post Re: Noob joystick control question
Alright, thank you very much!

So do you think we should try and download v3.62?


Wed Oct 29, 2014 9:12 am
Profile
Rookie

Joined: Thu Oct 23, 2014 11:28 am
Posts: 7
Post Re: Noob joystick control question
ROBOTC 4.26- 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:31 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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:  
cron



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