X Drive Autonomous

  1. 10 months ago

    Juster

    12 Nov 2017 Edmonton Alberta

    Wondering how to do autonomous for a x drive with four motors. My main goal for autonomous is to stack the pre load in the beginning of the match to one of the mobile goals and bring it back to the 10 or 20 point goal. Here is a my driver control code bellow if that helps #pragma config(Sensor, in1, Pot, sensorPotentiometer) #pragma config(Motor, port1, Claw, tmotorVex393_HBridge, openLoop) #pragma config(Motor, port2, fourLeft, tmotorVex393_MC29, openLoop, driveRight) #pragma config(Motor, port3, fourRight, tmotorVex393_MC29, openLoop) #pragma config(Motor, port4, sixLeft, tmotorVex393_MC29, openLoop, driveRight) #pragma config(Motor, port5, sixRight, tmotorVex393_MC29, openLoop) #pragma config(Motor, port6, FL, tmotorVex393_MC29, openLoop, driveLeft) #pragma config(Motor, port7, FR, tmotorVex393_MC29, openLoop) #pragma config(Motor, port8, BR, tmotorVex393_MC29, openLoop, driveLeft) #pragma config(Motor, port9, BL, tmotorVex393_MC29, openLoop) #pragma config(Motor, port10, Goal, tmotorVex393_HBridge, openLoop) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// // ROBOT SEEN FROM ABOVE // // X FRONT X // X X // X FL FR X // X // XXX // X // X BL BR X // X X // X X // Controller 1/2, Stick L/R, Axis X/Y #define C1LX vexRT[Ch4] #define C1LY vexRT[Ch3] #define C1RX vexRT[Ch1] task main() { while(true) { // Y component, X component, Rotation motor[FL] = -C1LY - C1LX - C1RX; motor[FR] = C1LY - C1LX - C1RX; motor[BR] = C1LY + C1LX - C1RX; motor[BL] = -C1LY + C1LX - C1RX; // Motor values can only be updated every 20ms wait10Msec(2); } { while(true) if (vexRT[Btn6U] == 1) { motor[fourLeft] = 127; motor[fourRight] = 127; motor[sixLeft] = 127; motor[sixRight] = 127; } else if (vexRT[Btn6D] == 1) { motor[fourLeft] = -127; motor[fourRight] = -127; motor[sixLeft] = -127; motor[sixRight] = -127; } else { motor[fourLeft] = 0; motor[fourRight] = 0; motor[sixLeft] = 0; motor[sixRight] = 0; } } if(vexRT[Btn7U] == 1) //If the button is pressed... LIFTS UP { if(SensorValue[Pot] < 900) //If the Potentiometer { //has not reached its maximum point... motor[fourLeft] = 69; //turn the motor on forward. motor[fourRight] = 69; motor[sixLeft] = 69; motor[sixRight] = 69; } else //If the Potentiometer has reached //its maximum point... { motor[fourLeft] = 0; //turn the motor off. motor[fourRight] = 0; motor[sixLeft] = 0; motor[sixRight] = 0; } if(vexRT[Btn7D] == 1) //If the button is pressed... LIFTS DOWN { if(SensorValue[Pot] > 100) //If the Potentiometer { //has not reached its minimum point... /////////////////////////////////////////// motor[fourLeft] = -31; //turn the motor on in reverse. ////////Remember to check this /////////// motor[fourRight] = -31; motor[sixRight] = -31; motor[sixLeft] = -31; ///////////////////////////////////////// } else //If the Potentiometer has reached { //its minimum point.. motor[fourLeft] = 0; motor[fourRight] = 0; motor[sixLeft] = 0; motor[sixRight] = 0; if (vexRT[Btn8U] == 1) { motor[BR] = 127; motor[BL] = 127; wait(2000); motor[port2] = 50; motor[port3] = 50; motor[port4] = 50; motor[port5] = 50; motor[port6] = 50; wait(1000); motor[BL] = 127; motor[BR] = 127; } } } } }

  2. Barin

    12 Nov 2017 Arizona
    Edited 10 months ago by Barin

    @Juster ; Wondering how to do autonomous for a x drive with four motors. My main goal for autonomous is to stack the pre load in the beginning of the match to one of the mobile goals and bring it back to the 10 or 20 point goal.

    Well, first of all, you'll want some sensors on your drivetrain. Shaft encoders are generally the best choice.

  3. Juster

    12 Nov 2017 Edmonton Alberta

    Yah, forgot to say that i have 2 on the robot do i need 4 or 2 would work

  4. Ashwin Gupta

    12 Nov 2017 California FRC 3476
    Edited 10 months ago by Ashwin Gupta

    @Juster ; Yah, forgot to say that i have 2 on the robot do i need 4 or 2 would work

    2 works if you don't plan on strafing in auton. If you plan on fully uitlizing the x-drive's capabilities than it will require 4 (you might be able to get away with 3 also but that would be very OCD invoking) .

  5. Juster

    12 Nov 2017 Edmonton Alberta

    Ok, yah probably want to use all the capabilities of the x drive but now my question how to code it I don't know how to code autonomous for x drive

  6. Team80_Giraffes

    13 Nov 2017 Event Partner Downingtown, PA 80[A-Z]$|81[A-Z]$|90[A-Z]$|91[...

    Think of your axis offset 45 degrees and code up each nw/se & ne/sw pairs as your new x & y axis. So get the ticks per inch or centimeter you want to travel, and use those in your PID. Have one PID for NW/SE and one for NE/SW axis. It will hone in on the one direction sooner and follow a straight line for the remaining axis.

    if you want better path planning, that is a whole other ball of wax.

 

or Sign Up to reply!