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

Motor Errors in RobotC programing
http://www.robotc.net/forums/viewtopic.php?f=53&t=5477
Page 1 of 1

Author:  roboticubs [ Mon Feb 11, 2013 10:41 am ]
Post subject:  Motor Errors in RobotC programing

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 [ Mon Feb 18, 2013 11:00 am ]
Post subject:  Re: Motor Errors in RobotC programing

This question was answered in this thread: viewtopic.php?f=63&t=5483&p=22797#p22797 ; the issue was that none of the motors were assigned aliases (names) and that the program was using NXT motors (motorA, motorB, etc) in a VEX competition template. In the future, please refrain from posting the same question multiple times as it divides the conversation and can cause confusion. Thank you!

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