Hey all,
My team has a competition this weekend (tomorrow actually), and we can’t get our 15 seconds autonomous to work.
Essentially, the program is supposed to run forward, grab the short neutral goal, and then come back to the home zone.
However, whenever we run the program, the program stops the moment the claw comes down, and the drivetrain simply doesn’t travel back to the home zone.
When we run the program by itself in an open space with no goals to grab, the claw goes down and the drivetrain still travels back.
Are there any solutions to this? Thank you so much!
Here is the full program:
/*----------------------------------------------------------------------------*/
/* */
/* Module: main.cpp */
/* Author: VEX */
/* Created: Thu Sep 26 2019 */
/* Description: Competition Template */
/* */
/*----------------------------------------------------------------------------*/
// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// Controller1 controller
// Claw motor 15
// bclaw motor 21
// bLeft motor 19
// fLeft motor 20
// fRight motor 18
// bRight motor 17
// larm motor 12
// rarm motor 2
// ---- END VEXCODE CONFIGURED DEVICES ----
#include "vex.h"
using namespace vex;
competition Competition;
/*---------------------------------------------------------------------------*/
/* Global Statements */
/*---------------------------------------------------------------------------*/
void dt(int pos, int speed, bool stopping){
bLeft.rotateFor(pos, rotationUnits::deg, speed, velocityUnits::pct, false);
fLeft.rotateFor(pos, rotationUnits::deg, speed, velocityUnits::pct, false);
bRight.rotateFor(pos, rotationUnits::deg, speed, velocityUnits::pct, false);
fRight.rotateFor(pos, rotationUnits::deg, speed, velocityUnits::pct, stopping);
}
void rd(int pos, int speed, bool stopping) {
bLeft.rotateFor(pos, rotationUnits::deg, speed, velocityUnits::pct, false);
fLeft.rotateFor(pos, rotationUnits::deg, speed, velocityUnits::pct, stopping);
}
void ld(int pos, int speed, bool stopping) {
bRight.rotateFor(pos, rotationUnits::deg, speed, velocityUnits::pct, false);
fRight.rotateFor(pos, rotationUnits::deg, speed, velocityUnits::pct, stopping);
}
void Arm(int pos, int speed, bool stopping) {
larm.rotateFor(pos, rotationUnits::deg, speed, velocityUnits::pct, stopping);
rarm.rotateFor(pos, rotationUnits::deg, speed, velocityUnits::pct, stopping);
}
//rotates the claw
void cm(int pos, int speed, bool stopping) {
Claw.rotateFor(pos, rotationUnits::deg, speed, velocityUnits::pct, stopping);
}
void bcm(int pos, int speed, bool stopping) {
bclaw.rotateFor(pos, rotationUnits::deg, speed, velocityUnits::pct, stopping);
}
void dtstop(){
fRight.stop(hold); bRight.stop(hold); fLeft.stop(hold); bLeft.stop(hold); }
void clawhold() {
Claw.setStopping(hold); }
/*---------------------------------------------------------------------------*/
/* Pre-Autonomous Functions */
/*---------------------------------------------------------------------------*/
void pre_auton(void) {
//leave this blank for now
}
/*---------------------------------------------------------------------------*/
/* Autonomous Task */
/*---------------------------------------------------------------------------*/
void autonomous(void) {
dt(800, 45, true);
dt(78, 20, true);
cm(600, 70, true);
dt(-920, 45, true);
vex::task::sleep(500);
}
/*---------------------------------------------------------------------------*/
/* User Control Task */
/*---------------------------------------------------------------------------*/
void usercontrol(void) {
// User control code here, inside the loop
//settings
while (1) {
//Drivetrain
fLeft.spin(vex::directionType::fwd, Controller1.Axis3.position(), vex::velocityUnits::pct);
bLeft.spin(vex::directionType::fwd, Controller1.Axis3.position(), vex::velocityUnits::pct);
fRight.spin(vex::directionType::fwd, Controller1.Axis2.position(), vex::velocityUnits::pct);
bRight.spin(vex::directionType::fwd, Controller1.Axis2.position(), vex::velocityUnits::pct);
//Claw Controls
if (Controller1.ButtonL1.pressing()){
cm(800,90,false);
}
else if (Controller1.ButtonL2.pressing()){
cm(-800,90,false);
}
else{
Claw.setStopping(hold);
}
if (Controller1.ButtonUp.pressing()){
bclaw.spin(directionType::fwd, 95, velocityUnits::pct);
}
else if (Controller1.ButtonDown.pressing()){
bclaw.spin(directionType::rev, 95, velocityUnits::pct);
}
else{
bclaw.setStopping(hold);
}
if(Controller1.ButtonR1.pressing()){
larm.spin(directionType::fwd, 90, velocityUnits::pct);
rarm.spin(directionType::fwd, 90, velocityUnits::pct);
}
else if(Controller1.ButtonR2.pressing()){
larm.spin(directionType::rev, 90, velocityUnits::pct);
rarm.spin(directionType::rev, 200, velocityUnits::pct);
}
else if(!Controller1.ButtonR1.pressing() && !Controller1.ButtonR2.pressing() && !Controller1.ButtonB.pressing() && !Controller1.ButtonX.pressing()){
larm.stop(brakeType::brake);
rarm.stop(brakeType::brake);
}
wait(20,msec);
}
}
/*---------------------------------------------------------------------------*/
/* Competition Callback */
/*---------------------------------------------------------------------------*/
int main() {
// Set up callbacks for autonomous and driver control periods.
Competition.autonomous(autonomous);
Competition.drivercontrol(usercontrol);
// Run the pre-autonomous function.
pre_auton();
// Prevent main from exiting with an infinite loop.
while (true) {
wait(100, msec);
}
}