Изменения кода Vex Robot Moby + улучшения?
Я построил самого простого робота-раздражителя под названием «Моби» и закодировал его так, чтобы он мог выполнять некоторые основные функции, такие как поднимать руки и двигаться вперед, назад и поворачиваться. Я также создал функцию, которая заставляет его двигаться быстрее, но я не совсем уверен, как увидеть, работает ли он, что меня беспокоит, так это как его улучшить? робот довольно простой, и, поскольку я сделал основы, я не совсем уверен, какие еще функции мне следует добавить?
main.cpp(кстати, это внутри шаблона конкурса)
void autonomous(void) {
// ..........................................................................
// Insert autonomous user code here.
// ..........................................................................
}
/*---------------------------------------------------------------------------*/
/* */
/* 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. */
/*---------------------------------------------------------------------------*/
int speed(100);
void speedIncrease(float inc){
leftDrive.spin(fwd, inc + leftDrive.velocity(pct), pct);
rightDrive.spin(fwd, inc - rightDrive.velocity(pct), pct);
}
void drive(int speed, int turn){
if(Controller1.ButtonL1.pressing()){
leftDrive.spin(fwd, speed + turn, pct);
rightDrive.spin(fwd, speed - turn, pct);
}
else if(Controller1.ButtonL2.pressing()){
speedIncrease(100);
} else{
leftDrive.stop();
rightDrive.stop();
}
}
void lift(){
if(Controller1.ButtonX.pressing()){
// ARMS.spinToPosition(1000,degrees);
ARMS.spin(forward);
// leftArm.spinToPosition(100,degrees);
// rightArm.spinToPosition(100,degrees);
}
else if(Controller1.ButtonB.pressing()){
// ARMS.spinToPosition(0,degrees);
ARMS.spin(reverse);
// leftArm.spinToPosition(0,degrees);
// rightArm.spinToPosition(0,degrees);
}
else{
leftArm.stop(hold);
rightArm.stop(hold);
ARMS.stop(hold);
}
}
void usercontrol(void) {
// User control code here, inside the loop
leftDrive.setStopping(hold);
rightDrive.setStopping(hold);
while (1) {
// This is the main execution loop for the user control program.
// Each time through the loop your program should update motor + servo
// values based on feedback from the joysticks.
// ........................................................................
// Insert user code here. This is where you use the joystick values to
// update your motors, etc.
// ........................................................................
drive(Controller1.Axis3.position(pct), Controller1.Axis1.position(percent));
lift();
wait(20, msec); // Sleep the task for a short amount of time to
// prevent wasted resources.
}
}
//
// Main will set up the competition functions and callbacks.
//
int main() {
// Set up callbacks for autonomous and driver control periods.
Competition.autonomous(autonomous);
Competition.drivercontrol(usercontrol);
ARMS.setVelocity(90,pct);
// Run the pre-autonomous function.
pre_auton();
// Prevent main from exiting with an infinite loop.
while (true) {
wait(100, msec);
}
}