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

Can someone explain this compiler error to me?
http://www.robotc.net/forums/viewtopic.php?f=69&t=10992
Page 1 of 1

Author:  TehEndieMC [ Sat Apr 25, 2015 3:28 pm ]
Post subject:  Can someone explain this compiler error to me?

I recently got a VEX IQ kit for my birthday and I downloaded ROBOTC. I know some things from my STEM class, but I am new to the VEX IQ version of it. I selected natural language, and I tried to use commands "waitUntil(getColorName(colorOrange));" and "waitUntil(getColorName(colorNone));". And there was a compiler error saying "**Error**:Expression does not fit parameter. Call to 'getColorName'. Parameter: 'tSensors nDeviceIndex' is 'colorOrange' of type 'TSimpleColors'.
**Error**:Expression does not fit parameter. Call to 'getColorName'. Parameter: 'tSensors nDeviceIndex' is 'colorNone' of type 'TSimpleColors'.
" So I need help. I was very excited about making this until I came across this error. Please help!

Author:  mightor [ Sun Apr 26, 2015 1:48 am ]
Post subject:  Re: Can someone explain this compiler error to me?

Could you please paste the whole program?

Thanks!

= Xander

Author:  TehEndieMC [ Sun Apr 26, 2015 1:00 pm ]
Post subject:  Re: Can someone explain this compiler error to me?

mightor wrote:
Could you please paste the whole program?

Thanks!

= Xander

Okay. Here is the whole code.
#pragma config(Sensor, port7, colorSensor, sensorVexIQ_Color12Color)
#pragma config(Motor, motor1, leftMotor, tmotorVexIQ, PIDControl, reversed, driveLeft, encoder)
#pragma config(Motor, motor6, rightMotor, tmotorVexIQ, PIDControl, reversed, driveRight, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
while (true)
{
setMotor(motor1, -100);
waitUntil(getColorName(colorOrange));
stopAllMotors();
setMotor(motor6, 100);
waitUntil(getColorName(colorNone));
stopAllMotors();
}
}
Also I was trying to make a line follower.

Author:  mightor [ Mon Apr 27, 2015 1:07 am ]
Post subject:  Re: Can someone explain this compiler error to me?

Hi there,

I made some changes to your program and added some comments. I hope this helps make things a little clearer.

= Xander
Code:
#pragma config(Sensor, port7, colorSensor, sensorVexIQ_Color12Color)
#pragma config(Motor, motor1, leftMotor, tmotorVexIQ, PIDControl, reversed, driveLeft, encoder)
#pragma config(Motor, motor6, rightMotor, tmotorVexIQ, PIDControl, reversed, driveRight, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
  while (true)
  {
    // I have changed it from motor1 to leftMotor, so it's more
    // obvious which motor is being powered.  Same goes for motor6
    // further below.
    setMotor(leftMotor, -100);
    // getColorName expects a sensor, not a color
    // It will return the colour that is currently detected
    waitUntil(getColorName(colorSensor) == colorOrange);
    stopAllMotors();
    setMotor(rightMotor, 100);
    waitUntil(getColorName(colorSensor) == colorNone);
    stopAllMotors();
  }
}

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