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

Motor Errors in RobotC Programming
http://www.robotc.net/forums/viewtopic.php?f=63&t=5483
Page 1 of 1

Author:  roboticubs [ Tue Feb 12, 2013 10:40 am ]
Post subject:  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

Author:  JohnWatson [ Tue Feb 12, 2013 10:48 am ]
Post subject:  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.

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