Author |
Message |
SCOPE
Rookie
Joined: Wed Feb 22, 2012 9:04 am Posts: 20 Location: behind you
|
 robotc error
I have a robot i am building and i am working on this code:  |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, HTMotor, HTMotor, HTMotor) #pragma config(Hubs, S2, HTServo, HTServo, none, none) #pragma config(Sensor, S1, , sensorI2CMuxController) #pragma config(Sensor, S2, , sensorI2CMuxController) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_1, motorF, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_2, motorG, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C3_1, motorH, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C3_2, motorI, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C4_1, motorJ, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C4_2, motorK, tmotorNormal, openLoop) #pragma config(Servo, srvo_S2_C1_1, servo1, tServoNone) #pragma config(Servo, srvo_S2_C1_2, servo2, tServoNone) #pragma config(Servo, srvo_S2_C1_3, servo3, tServoNone) #pragma config(Servo, srvo_S2_C1_4, servo4, tServoNone) #pragma config(Servo, srvo_S2_C1_5, servo5, tServoNone) #pragma config(Servo, srvo_S2_C1_6, servo6, tServoNone) #pragma config(Servo, srvo_S2_C2_1, servo7, tServoNone) #pragma config(Servo, srvo_S2_C2_2, servo8, tServoNone) #pragma config(Servo, srvo_S2_C2_3, servo9, tServoNone) #pragma config(Servo, srvo_S2_C2_4, servo10, tServoNone) #pragma config(Servo, srvo_S2_C2_5, servo11, tServoNone) #pragma config(Servo, srvo_S2_C2_6, servo12, tServoNone) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
const int armup = 2; const int armdown = 3; const int armleft = 1; const int armright = 4; #include "JoystickDriver.c"
void topHat() { if(joy1_TopHat == 0) { //top hat controls claw } else if (joystick.joy1_TopHat == 1) { //same as 0 } else if (joystick.joy1_TopHat == 2) { //same as 0 } else if (joystick.joy1_TopHat == 3) { //same as 0 } else if (joystick.joy1_TopHat == 4) { //same as 0 } else if (joystick.joy1_TopHat == 5) { //same as 0 } else if (joystick.joy1_TopHat == 6) { //same as 0 } else if (joystick.joy1_TopHat == 7) { //same as 0 } else { //set the servo to 0 } }
void handleArm() { //up/down [u]if (joy1_Buttons(armup))[/u] { motor[motorA] = 25; //motor that lifts the arm goes up } else if (joy1_Buttons(armdown)) { motor[motorA] = -25; //motor that lifts the arm goes down } else { motor[motorA] = 0; //motor that lifts the arm is stationary } //left/right if (joy1_Buttons(armleft)) { motor[motorB] = 10; //motor that turns the arm moves to the left } else if (joy1_Buttons(armright)) { motor[motorB] = -10; //motor that turns the arm moves to the right } else { motor[motorB] = 0; //motor that turns the arm is stationary } } void tankDrive() { //put tank drive code here //forward backward }
task main() { handleArm(); tankDrive(); topHat(); //The rest of the main loop code here } |  |  |  |  |
the error is: **Error**:Variable 'joy1_Buttons' is subsequently used as a procedure **Error**:Variable 'joy1_Buttons' is not a Procedure. the underlined area is the error could someone tell me how to fix it???
_________________ ------------------- "She laughs at everything you say. Why? Because she has fine teeth." "Three can keep a secret, if two of them are dead." "Either write something worth reading or do something worth writing."
|
Wed Feb 22, 2012 9:31 am |
|
 |
SCOPE
Rookie
Joined: Wed Feb 22, 2012 9:04 am Posts: 20 Location: behind you
|
 Re: robotc error
#pragma config(Hubs, S1, HTMotor, HTMotor, HTMotor, HTMotor) #pragma config(Hubs, S2, HTServo, HTServo, none, none) #pragma config(Sensor, S1, , sensorI2CMuxController) #pragma config(Sensor, S2, , sensorI2CMuxController) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_1, motorF, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_2, motorG, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C3_1, motorH, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C3_2, motorI, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C4_1, motorJ, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C4_2, motorK, tmotorNormal, openLoop) #pragma config(Servo, srvo_S2_C1_1, servo1, tServoNone) #pragma config(Servo, srvo_S2_C1_2, servo2, tServoNone) #pragma config(Servo, srvo_S2_C1_3, servo3, tServoNone) #pragma config(Servo, srvo_S2_C1_4, servo4, tServoNone) #pragma config(Servo, srvo_S2_C1_5, servo5, tServoNone) #pragma config(Servo, srvo_S2_C1_6, servo6, tServoNone) #pragma config(Servo, srvo_S2_C2_1, servo7, tServoNone) #pragma config(Servo, srvo_S2_C2_2, servo8, tServoNone) #pragma config(Servo, srvo_S2_C2_3, servo9, tServoNone) #pragma config(Servo, srvo_S2_C2_4, servo10, tServoNone) #pragma config(Servo, srvo_S2_C2_5, servo11, tServoNone) #pragma config(Servo, srvo_S2_C2_6, servo12, tServoNone) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
const int armup = 2; const int armdown = 3; const int armleft = 1; const int armright = 4; #include "JoystickDriver.c"
void topHat() { if(joy1_TopHat == 0) { //top hat controls claw } else if (joystick.joy1_TopHat == 1) { //same as 0 } else if (joystick.joy1_TopHat == 2) { //same as 0 } else if (joystick.joy1_TopHat == 3) { //same as 0 } else if (joystick.joy1_TopHat == 4) { //same as 0 } else if (joystick.joy1_TopHat == 5) { //same as 0 } else if (joystick.joy1_TopHat == 6) { //same as 0 } else if (joystick.joy1_TopHat == 7) { //same as 0 } else { //set the servo to 0 } }
void handleArm() { //up/down if (joy1_Buttons(armup)) { motor[motorA] = 25; //motor that lifts the arm goes up } else if (joy1_Buttons(armdown)) { motor[motorA] = -25; //motor that lifts the arm goes down } else { motor[motorA] = 0; //motor that lifts the arm is stationary } //left/right if (joy1_Buttons(armleft)) { motor[motorB] = 10; //motor that turns the arm moves to the left } else if (joy1_Buttons(armright)) { motor[motorB] = -10; //motor that turns the arm moves to the right } else { motor[motorB] = 0; //motor that turns the arm is stationary } } void tankDrive() { //put tank drive code here //forward backward }
task main() { handleArm(); tankDrive(); topHat(); //The rest of the main loop code here }
the red area is the error
_________________ ------------------- "She laughs at everything you say. Why? Because she has fine teeth." "Three can keep a secret, if two of them are dead." "Either write something worth reading or do something worth writing."
|
Wed Feb 22, 2012 9:33 am |
|
 |
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 496
|
 Re: robotc error
joy1_Buttons is not a function. It is a variable that returns a bitmap of the buttons on the controller. You should really use joy1Btn() instead.
_________________ sudo rm -rf /
|
Wed Feb 22, 2012 9:43 am |
|
 |
SCOPE
Rookie
Joined: Wed Feb 22, 2012 9:04 am Posts: 20 Location: behind you
|
 Re: robotc error
i switched joy1_Buttons with joy1_Btn and it still didn't work  |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, HTMotor, HTMotor, HTMotor) #pragma config(Hubs, S2, HTServo, HTServo, none, none) #pragma config(Sensor, S1, , sensorI2CMuxController) #pragma config(Sensor, S2, , sensorI2CMuxController) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_1, motorF, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_2, motorG, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C3_1, motorH, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C3_2, motorI, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C4_1, motorJ, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C4_2, motorK, tmotorNormal, openLoop) #pragma config(Servo, srvo_S2_C1_1, claw, tServoStandard) #pragma config(Servo, srvo_S2_C1_2, unkwown, tServoStandard) #pragma config(Servo, srvo_S2_C1_3, servo3, tServoNone) #pragma config(Servo, srvo_S2_C1_4, servo4, tServoNone) #pragma config(Servo, srvo_S2_C1_5, servo5, tServoNone) #pragma config(Servo, srvo_S2_C1_6, servo6, tServoNone) #pragma config(Servo, srvo_S2_C2_1, servo7, tServoNone) #pragma config(Servo, srvo_S2_C2_2, servo8, tServoNone) #pragma config(Servo, srvo_S2_C2_3, servo9, tServoNone) #pragma config(Servo, srvo_S2_C2_4, servo10, tServoNone) #pragma config(Servo, srvo_S2_C2_5, servo11, tServoNone) #pragma config(Servo, srvo_S2_C2_6, servo12, tServoNone) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/////////////////////////////////////////ROBOT/////////////////////////////////////////// /*/////////////////////////////////////////////////////////////////////////////////////// /Controls Description othernames / ///////////////////////////////////////////////////////////////////////////////////////// /topHat------------used to control the claw being open or closed------------topHat / /Button1-----------used to make the arm turn Left---------------------------armleft / /Button2-----------used to make the arm go up-------------------------------armup / /Button3-----------used to make the arm go down-----------------------------armdown / /Button4-----------used to make the arm turn right--------------------------armright / /Joystick1---------uesd to make the robot move------------------------------??????? / /Joystick2---------used to make the robot move------------------------------??????? / /triggerL1---------???????????????????????????------------------------------??????? / /triggerL2---------???????????????????????????------------------------------??????? / /triggerR1---------???????????????????????????------------------------------??????? / /triggerR2---------???????????????????????????------------------------------??????? / *//////////////////////////////////////////////////////////////////////////////////////// const int armup = 2; const int armdown = 3; const int armleft = 1; const int armright = 4; #include "JoystickDriver.c"
void topHat() { if(joy1_TopHat == 0) { //top hat controls claw (claw is closed) } else if (joystick.joy1_TopHat == 1) { //same as 0 } else if (joystick.joy1_TopHat == 2) { //same as 0 } else if (joystick.joy1_TopHat == 3) { //same as 0 } else if (joystick.joy1_TopHat == 4) { //same as 0 } else if (joystick.joy1_TopHat == 5) { //same as 0 } else if (joystick.joy1_TopHat == 6) { //same as 0 } else if (joystick.joy1_TopHat == 7) { //same as 0 } else { //set the servo to 0 (claw is open } } ////////////////////////////////////////////////////////////////// //or make the triggers make the claw open and close instead of the topHat
void triggers() { //trigger controls for claw (the claw is a VEX Robotics claw) } void handleArm() { //up/down if (joy1_Btn(armup)) { motor[motorA] = 25; //motor that lifts the arm goes up } else if (joy1_Btn(armdown)) { motor[motorA] = -25; //motor that lifts the arm goes down } else { motor[motorA] = 0; //motor that lifts the arm is stationary } //left/right if (joy1_Btn(armleft)) { motor[motorB] = 10; //motor that turns the arm moves to the left } else if (joy1_Btn(armright)) { motor[motorB] = -10; //motor that turns the arm moves to the right } else { motor[motorB] = 0; //motor that turns the arm is stationary } } void tankDrive() { //put tank drive code here //forward/backward //turn left/right }
task main() { handleArm(); tankDrive(); topHat(); triggers(); //The rest of the main loop code here } |  |  |  |  |
_________________ ------------------- "She laughs at everything you say. Why? Because she has fine teeth." "Three can keep a secret, if two of them are dead." "Either write something worth reading or do something worth writing."
|
Wed Feb 22, 2012 6:26 pm |
|
 |
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 496
|
 Re: robotc error
Well, it doesn't look like you have a while loop in your main function. The code will only execute once, and the program will terminate.
_________________ sudo rm -rf /
|
Wed Feb 22, 2012 6:52 pm |
|
 |
SCOPE
Rookie
Joined: Wed Feb 22, 2012 9:04 am Posts: 20 Location: behind you
|
 Re: robotc error
i am on the Halestorm robotics team and i mainly do build but my friend is(was) the only programer so i thought i would help him. he didn't tell me i had to have it in a while loop when i asked him
thanks
_________________ ------------------- "She laughs at everything you say. Why? Because she has fine teeth." "Three can keep a secret, if two of them are dead." "Either write something worth reading or do something worth writing."
|
Wed Feb 22, 2012 7:32 pm |
|
 |
SCOPE
Rookie
Joined: Wed Feb 22, 2012 9:04 am Posts: 20 Location: behind you
|
 Re: robotc error
i was also wondering how to program the triggers on the logitech controlers
_________________ ------------------- "She laughs at everything you say. Why? Because she has fine teeth." "Three can keep a secret, if two of them are dead." "Either write something worth reading or do something worth writing."
|
Wed Feb 22, 2012 8:19 pm |
|
 |
SCOPE
Rookie
Joined: Wed Feb 22, 2012 9:04 am Posts: 20 Location: behind you
|
 Re: robotc error
also i would like to know if anyone knows how to fix this error:
**Error**:Undefined procedure 'joy1_Btn'.
_________________ ------------------- "She laughs at everything you say. Why? Because she has fine teeth." "Three can keep a secret, if two of them are dead." "Either write something worth reading or do something worth writing."
|
Wed Feb 22, 2012 8:25 pm |
|
 |
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 496
|
 Re: robotc error
It's joy1Btn(), not joy1_Btn.
_________________ sudo rm -rf /
|
Wed Feb 22, 2012 8:28 pm |
|
 |
SCOPE
Rookie
Joined: Wed Feb 22, 2012 9:04 am Posts: 20 Location: behind you
|
 Re: robotc error
but then how do i chose which button out of the four?
_________________ ------------------- "She laughs at everything you say. Why? Because she has fine teeth." "Three can keep a secret, if two of them are dead." "Either write something worth reading or do something worth writing."
|
Thu Feb 23, 2012 8:51 am |
|
 |
SCOPE
Rookie
Joined: Wed Feb 22, 2012 9:04 am Posts: 20 Location: behind you
|
 Re: robotc error
oh ha sorry, i read that too fast.
_________________ ------------------- "She laughs at everything you say. Why? Because she has fine teeth." "Three can keep a secret, if two of them are dead." "Either write something worth reading or do something worth writing."
|
Thu Feb 23, 2012 8:52 am |
|
 |
SCOPE
Rookie
Joined: Wed Feb 22, 2012 9:04 am Posts: 20 Location: behind you
|
 Re: robotc error
what! i do have joy1_Btn() except i have ei armup, etc inside of it what do you mean i need to put joy1_Btn() instead of joy1_Btn?
_________________ ------------------- "She laughs at everything you say. Why? Because she has fine teeth." "Three can keep a secret, if two of them are dead." "Either write something worth reading or do something worth writing."
Last edited by SCOPE on Thu Feb 23, 2012 8:56 am, edited 1 time in total.
|
Thu Feb 23, 2012 8:54 am |
|
 |
SCOPE
Rookie
Joined: Wed Feb 22, 2012 9:04 am Posts: 20 Location: behind you
|
 Re: robotc error
does anyone know how to program the triggers on the back of the controller???
_________________ ------------------- "She laughs at everything you say. Why? Because she has fine teeth." "Three can keep a secret, if two of them are dead." "Either write something worth reading or do something worth writing."
|
Thu Feb 23, 2012 8:55 am |
|
 |
SCOPE
Rookie
Joined: Wed Feb 22, 2012 9:04 am Posts: 20 Location: behind you
|
 Re: robotc error
actually i found out how so never mind about the triggers
_________________ ------------------- "She laughs at everything you say. Why? Because she has fine teeth." "Three can keep a secret, if two of them are dead." "Either write something worth reading or do something worth writing."
|
Thu Feb 23, 2012 9:26 am |
|
 |
SCOPE
Rookie
Joined: Wed Feb 22, 2012 9:04 am Posts: 20 Location: behind you
|
 Re: robotc error
i started using tele-op catalyst but i still dont know how to program the joysticks
_________________ ------------------- "She laughs at everything you say. Why? Because she has fine teeth." "Three can keep a secret, if two of them are dead." "Either write something worth reading or do something worth writing."
|
Thu Feb 23, 2012 10:28 am |
|
|
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
|
|