|
Page 1 of 1
|
[ 9 posts ] |
|
Problems With Programming 2nd Logitech Controller
| Author |
Message |
|
colbyshaver10
Rookie
Joined: Fri Jan 28, 2011 2:30 pm Posts: 3
|
 Problems With Programming 2nd Logitech Controller
We are building a robot for an FTC competition and we have kind of hit a road block. We are new to programming and I'm not sure what we are doing wrong. The robot is simple, it has 3 tetrix motors, and 2 servos using 2 motor controllers and 1 servo controller. To run the robot we are using the Logitech "play station" controllers. I want to program it to where one logitech controller drives the robot and the other controls the arm with a claw at the end. The driving controller works just fine, but nothing works on the one that controls the arm. Here is my program, PLEASE give me some advice on what I am doing wrong.
#pragma config(Hubs, S1, HTMotor, HTMotor, none, none) #pragma config(Hubs, S2, HTServo, none, none, none) #pragma config(Motor, mtr_S1_C1_1, LeftWheel, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, RightWheel, tmotorNormal, openLoop, reversed) #pragma config(Motor, mtr_S1_C2_1, Arm, tmotorNormal, openLoop) #pragma config(Servo, srvo_S2_C1_1, Rotate, tServoStandard) #pragma config(Servo, srvo_S2_C1_2, Claw, tServoStandard) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
task main() { while (true) {
motor[RightWheel] = joystick.joy1_y1; motor[LeftWheel] = joystick.joy1_y2; motor[Arm] = joystick.joy2_y1;
if(joy2Btn(6)) { servoTarget[Rotate] = 60; } if(joy2Btn(8)) { servoTarget[Rotate] = 180; } if(joy2Btn(5)) { servoTarget[Claw] = 60; } if(joy2Btn(7)) { servoTarget[Claw] = 180; } } }
|
| Fri Jan 28, 2011 2:40 pm |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 496
|
 Re: Problems With Programming 2nd Logitech Controller
Why don't you have a "getJoystickSettings(joystick);" in your while loop?
_________________ sudo rm -rf /
|
| Fri Jan 28, 2011 3:42 pm |
|
 |
|
colbyshaver10
Rookie
Joined: Fri Jan 28, 2011 2:30 pm Posts: 3
|
 Re: Problems With Programming 2nd Logitech Controller
Because we are really new to this, and I really dont know what Im doing. haha. Ill try it out, any other advice?
|
| Fri Jan 28, 2011 4:47 pm |
|
 |
|
colbyshaver10
Rookie
Joined: Fri Jan 28, 2011 2:30 pm Posts: 3
|
 Re: Problems With Programming 2nd Logitech Controller
Is this where you are saying it should go? It compiled just fine but Im not around the bot right now so I cant test it out.
#pragma config(Hubs, S1, HTMotor, HTMotor, none, none) #pragma config(Hubs, S2, HTServo, none, none, none) #pragma config(Motor, mtr_S1_C1_1, LeftWheel, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, RightWheel, tmotorNormal, openLoop, reversed) #pragma config(Motor, mtr_S1_C2_2, Arm, tmotorNormal, openLoop) #pragma config(Servo, srvo_S2_C1_1, Rotate, tServoStandard) #pragma config(Servo, srvo_S2_C1_2, Claw, tServoStandard) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
task main() { while (true) getJoystickSettings(joystick); {
motor[RightWheel] = joystick.joy1_y1; motor[LeftWheel] = joystick.joy1_y2; motor[Arm] = joystick.joy2_y1;
if(joy2Btn(4)) { servo[Rotate] = 60; } if(joy2Btn(6)) { servo[Rotate] = 180; } if(joy2Btn(5)) { servo[Claw] = 60; } if(joy2Btn(7)) { servo[Claw] = 180; } } }
|
| Fri Jan 28, 2011 4:50 pm |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 496
|
 Re: Problems With Programming 2nd Logitech Controller
Nope. Below the open curly brace.
_________________ sudo rm -rf /
|
| Fri Jan 28, 2011 5:15 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: Problems With Programming 2nd Logitech Controller
colbyshaver10, If you did not have the "getJoystickSettings(joystick);" line to start with, how did you get the driving controller to work at all?
|
| Fri Jan 28, 2011 5:33 pm |
|
 |
|
alanlevezu
Rookie
Joined: Wed Feb 24, 2010 11:43 pm Posts: 34
|
 Re: Problems With Programming 2nd Logitech Controller
You don't really need to call getjoysticksettings().
As long as you give the looping task an opportunity to pause (even a wait1MSec(1)) somewhere, it will update itself. The FTC Joystick Driver file has a separate task that calls the function so it can update the front screen display. That call updates the global joystick structure, so, it works just fine without doing anything else...
|
| Mon Jan 31, 2011 1:26 pm |
|
 |
|
alanlevezu
Rookie
Joined: Wed Feb 24, 2010 11:43 pm Posts: 34
|
 Re: Problems With Programming 2nd Logitech Controller
Are you using the Joystick - Game window to run the program, and do you have "Dual Joysticks" selected? Your code doesn't have any obvious flaws, so my first guess is that it's a procedural or software environment issue.
|
| Mon Jan 31, 2011 1:28 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: Problems With Programming 2nd Logitech Controller
Right, I forgot about the DisplayTask  Our code stops the DisplayTask during initialization so that we can use the full LCD display for debugging, so we need to explicitly call getJoystickSettings() in our loop.
|
| Mon Jan 31, 2011 4:26 pm |
|
|
|
Page 1 of 1
|
[ 9 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
|
|