|
Page 1 of 1
|
[ 2 posts ] |
|
Motor Errors in RobotC Programming
| Author |
Message |
|
roboticubs
Rookie
Joined: Wed Jan 23, 2013 10:55 am Posts: 3
|
 Motor Errors in RobotC Programming
I am trying to create a program for autonomous and manual control mode and I keep having the following errors: **Error**:Undefined variable 'motorA'. 'short' assumed. **Error**:Undefined variable 'motorB'. 'short' assumed. **Error**:Undefined variable 'leftMotor'. 'short' assumed. **Error**:Undefined variable 'rightMotor'. 'short' assumed.
Here is my code below: #pragma platform(VEX)
//Competition Control and Duration Settings #pragma competitionControl(Competition) #pragma autonomousDuration(20) #pragma userControlDuration(120)
#include "Vex_Competition_Includes.c" //Main competition background code...do not modify!
///////////////////////////////////////////////////////////////////////////////////////// // // Pre-Autonomous Functions // // You may want to perform some actions before the competition starts. Do them in the // following function. // /////////////////////////////////////////////////////////////////////////////////////////
void pre_auton() { // Set bStopTasksBetweenModes to false if you want to keep user created tasks running between // Autonomous and Tele-Op modes. You will need to manage all user created tasks if set to false. bStopTasksBetweenModes = true;
// All activities that occur before the competition starts // Example: clearing encoders, setting servo positions, ... }
///////////////////////////////////////////////////////////////////////////////////////// // // Autonomous Task // // This task is used to control your robot during the autonomous phase of a VEX Competition. // You must modify the code to add your own robot specific commands here. // /////////////////////////////////////////////////////////////////////////////////////////
task autonomous() { motor[motorA] = 100; //motor A is run at a 100 power level motor[motorB] = 100; //motor A is run at a 100 power level wait1Msec(4000); //the program waits 4000 milliseconds before running further code
motor[motorA] = -100; //motor A is run at a 100 power level motor[motorB] = -100; //motor A is run at a 100 power level wait1Msec(4000); //the program waits 4000 milliseconds before running further code }
///////////////////////////////////////////////////////////////////////////////////////// // // User Control Task // // This task is used to control your robot during the user control phase of a VEX Competition. // You must modify the code to add your own robot specific commands here. // /////////////////////////////////////////////////////////////////////////////////////////
task usercontrol() {
while(true) { motor[leftMotor] = vexRT[Ch3]; // Left Joystick Y value motor[rightMotor] = vexRT[Ch2]; // Right Joystick Y value
if( vexRT[Ch3] == 1) { motor[leftMotor] = 100; } if(vexRT[Ch2] == 100) { motor[rightMotor] = 1; }
} }
-Thank you
|
| Tue Feb 12, 2013 10:40 am |
|
 |
|
JohnWatson
Site Admin
Joined: Thu May 24, 2012 12:15 pm Posts: 386
|
 Re: Motor Errors in RobotC Programming
You are confusing the NXT and VEX platforms. Unless specifically designated in the Motors and Sensors Setup, motorA, motorB, and motorC are the default names for the respective motor ports on the NXT. You are using a VEX competition template, though, so you should use the motor[port1]....motor[port10] commands instead. Alternatively, you can set custom names for your motors (such as leftMotor and rightMotor) through the Motors and Sensors Setup page; I would recommend this solution, as you will then be able to use the short, descriptive names you assign to the motor ports instead of trying to remember what each individual port is assigned to.
_________________Check out our Blog! And our Facebook page! Need help? Take a look at our Wiki and our Forums.I just met you, And this is crazy, But here's my code now, So fix it, maybe? ~ Carly Rae Jepsen parody
|
| Tue Feb 12, 2013 10:48 am |
|
|
|
Page 1 of 1
|
[ 2 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
|
|