please help asap we are in need of robot c help with our whole program it has many errors and cant figure out why mostly the pid loop i dont know how to state the sensorvalue in the code with a pid loop or if you even need one. if you can take a look and fix it ans send it to me that would be amazing thanks
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, dgtl2, pistonleftshooter, sensorDigitalOut)
#pragma config(Sensor, dgtl3, pistonrightshooter, sensorDigitalOut)
#pragma config(Sensor, dgtl4, pistonshooterlevel, sensorDigitalOut)
#pragma config(Sensor, dgtl5, liftleft, sensorNone)
#pragma config(Sensor, dgtl6, leftright, sensorNone)
#pragma config(Sensor, I2C_1, , sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Sensor, I2C_3, , sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Motor, port1, beaterbar, tmotorVex393TurboSpeed_HBridge, openLoop)
#pragma config(Motor, port2, Rightdrivemotor, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port3, Leftdrivemotor, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port4, elevator, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port5, LefttopSMotor, tmotorVex393_MC29, openLoop, encoderPort, I2C_1)
#pragma config(Motor, port6, LeftmiddleSMotor, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port7, LeftbottomSMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, RighttopSMotor, tmotorVex393_MC29, openLoop, reversed, encoderPort, I2C_3)
#pragma config(Motor, port9, RightmiddleSMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port10, RightbottomSMotor, tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#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[port1] = -127;
motor[port10] = 127;
wait1Msec(500);
motor[port1] = 0;
motor[port10] = 0;
wait1Msec(500);
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// 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()
{
// User control code here, inside the loop
bLCDBacklight = true; // Turn on LCD Backlight
string mainBattery, backupBattery;
while (true)
{
clearLCDLine(0); // Clear line 1 (0) of the LCD
clearLCDLine(1); // Clear line 2 (1) of the LCD
//Display the Primary Robot battery voltage
displayLCDString(0, 0, "Primary: ");
sprintf(mainBattery, "%1.2f%c", nImmediateBatteryLevel/1000.0,'V'); //Build the value to be displayed
displayNextLCDString(mainBattery);
//Display the Backup battery voltage
displayLCDString(1, 0, "Backup: ");
sprintf(backupBattery, "%1.2f%c", BackupBatteryLevel/1000.0, 'V'); //Build the value to be displayed
displayNextLCDString(backupBattery);
//Short delay for the LCD refresh rate
wait1Msec(100);
int speed;
int speedx;
speed =66; //Shooter Speed
speedx = 70;
float kp = 1.3;
float ki = 0.1;
float kd = 0.2;
float currentL = 0;
float currentR = 0;
float circ = 5*3.14592653589;
float integralActiveZone = ((1*12/circ)*360);
float errorTl;
float errorTr;
float lastErrorL;
float lastErrorR;
float proportionL;
float proportionR;
float integralL;
float intagralR;
float derivativeL;
float derivativeR;
velocityL=sensorValue(LefttopSMotor);
velocityR=sensorValue(RighttopSMotor);
//proportional value for the speed control
//proportional control of the shooter
float errorL = ((power*12/circ)*360 ) - velocityL;
float errorR = ((power*12/circ)*360 ) - velocityR;
if(errorL <integralActiveZone && errorL != 0)
{
errorTl += errorL;
}
else
{
errorTl = 0;
}
if(errorR < ((integralActiveZone*12/circ)*360) && error != 0)
{
errorTr += errorR;
}
else{
errorTr = 0;
}
if(errorTl > 50/ki)
{
errorTl = 50/ki
}
if (errorTr > 50/ki)
{
errorTr = 50/ki;
}
if(errorL == 0)
{
derivativeL = 0;
}
if(errorR == 0)
{
derivativeR = 0;
}
proportionL = errorL * kp;
proportionR = error R * kp;
intergalL = errorTl * ki;
IntegralR = (errorL - lastErrorL) * ki;
derivativeR = (errorR - lastErrorR) * kd;
lastErrorR = errorL;
lastErrorR = errorR;
/////////////////////////////////////////////////////////////////////////////////////////////////
currentR = proportionR + IIntegralR + derivativeR;
currentL = pproportionL + integralL + derivativeL;
if (power n== 0) (
currentR = 0;
currentL = 0;
}
if(currentL < 0) {
currentL = 0;
}
if(currentR < 0) {
currentR = 0;
}
motor [LeftbottomSMotor] = motor [LeftmiddleSMotor] = motor [LefttopSMotor]=currentL;
motor [RightbottomSMotor] = motor [RightmiddleSMotor] = motor [RighttopSMotor] =currentR;
if (vexRT[Btn6DXmtr2] ==) {
motor[LeftbottomSMotor]=motor[LeftmiddleSMotor] = motor[LefttopSMotor] = motor[RightbottomSMotor] = motor [RightmiddleSMotor] = motor [RighttopSMotor] =0;
}
wait1Msec(20);
//Shooter Speed low shot
//Right side of the robot is controlled by the right joystick, Y-axis
motor[Rightdrivemotor] = vexRT[Ch3];
//Left side of the robot is controlled by the left joystick, Y-axis
motor[Leftdrivemotor] = vexRT[Ch2];
if(vexRT[Btn6UXmtr2] == 1)
{
motor[elevator] = (127);
}
else if(vexRT[Btn5UXmtr2] == 1)
{
motor[elevator] = (-127);
}
else
{
motor[elevator] = 0;
}
if(vexRT[Btn6UXmtr2] == 1)
{
motor[beaterbar] = (127);
}
else if(vexRT[Btn6UXmtr2] == 1)
{
motor[beaterbar] = (-127);
}
else
{
motor[beaterbar] = 0;
}
// Don't hog the cpu
wait1Msec(25);
// end of task main
errors
Warning:Unreferenced function ‘UserControlCodePlaceholderForTesting’
Warning:Unreferenced function ‘AutonomousCodePlaceholderForTesting’
Warning:Unreferenced variable ‘intagralR’
Error:Undefined variable ‘velocityL’. ‘short’ assumed.
Warning:Substituting similar variable ‘SensorValue’ for ‘sensorValue’. Check spelling and letter case.
Error:Undefined variable ‘velocityR’. ‘short’ assumed.
Warning:Substituting similar variable ‘SensorValue’ for ‘sensorValue’. Check spelling and letter case.
Error:Undefined variable ‘power’. ‘short’ assumed.
Error:Undefined variable ‘error’. ‘short’ assumed.
Warning:‘;’ expected before ‘}’. Automatically inserted by compiler
Error:Expected->‘;’. Found ‘R’
Error:Undefined variable ‘R’. ‘short’ assumed.
Warning:Meaningless statement – no code generated
Error:Undefined variable ‘intergalL’. ‘short’ assumed.
Error:Undefined variable ‘IntegralR’. ‘short’ assumed.
Error:Undefined variable ‘IIntegralR’. ‘short’ assumed.
Error:Undefined variable ‘pproportionL’. ‘short’ assumed.
Error:‘)’ missing. Ummatched left parenthesis ‘(’
Error:Expected->‘)’. Found ‘n’
Error:Undefined variable ‘n’. ‘short’ assumed.
Error:Missing ‘;’ before ‘)’
Error:Unexpected ‘)’ during parsing
Warning:‘)’ exepected before ‘;’. Automatically inserted.
Warning:Meaningless statement. Did you mean ‘=’ instead of ‘==’?
Error:Undefined variable ‘currentL’. ‘short’ assumed.
Error:Undefined variable ‘currentR’. ‘short’ assumed.
Error:Unexpected ‘)’ during parsing
Error:Executable statements not valid in ‘main’ declaration block
Error:Executable statements not valid in ‘main’ declaration block
Error:Executable statements not valid in ‘main’ declaration block
Error:Executable statements not valid in ‘main’ declaration block
Error:Executable statements not valid in ‘main’ declaration block
Error:Executable statements not valid in ‘main’ declaration block