thank you! my partner in robotics wrote our driver code, but neither of us really understand it so i’m re-doing it on my own. code gets frustrating, (especially c++ in my opinion) so thanks for the thorough explanation.
Yes. Thank you so much! I looked for a long time to find a video that was simple and easy to follow. This was just what I needed. It is my first year of robotics and we qualified for state based on skills score (thanks to your autonomous video) and then we qualified for worlds. None of that would have been possible without this video so thank you.
Good tutorial playlist. If you are looking to not use the built in ability to add arcade drive to drivetrain the following method will give you arcade drive. I maybe could have added left and right inversion parameters(you can see my one motor is inverted) and a speed and brake style parameter but I thought I would keep it simple: void arcadeDrive(controller Controller, motor_group LeftMotor, motor_group RightMotor) { if(Controller.Axis3.position(percent) != 0 || Controller.Axis4.position(percent) != 0) { int RightSpeed = (Controller.Axis3.position(percent) - Controller.Axis4.position(percent))/2; int LeftSpeed = (Controller.Axis3.position(percent) + Controller.Axis4.position(percent))/2; LeftMotor.spin(forward,LeftSpeed,percent); RightMotor.spin(reverse,RightSpeed,percent); } else { LeftMotor.stop(brake); RightMotor.stop(brake); } }
if you are still a begineer and want to know a simplified version of this you can do something as simple as this /*--------------------------------This section gets the raw joystick values from the user input----------------------------------*/ /*-------------------------------------------------------------------------------------------------------------------------------*/ /*Rear Right motor, once axis3 is used it will move fwd or rev, if axis1 is used it will move the motor in a - or + direction*/ rRight.spin(fwd, +Controller1.Axis3.position(pct) -Controller1.Axis1.position(pct), pct); /*Front Right motor, once axis3 is used it will move fwd or rev, if axis1 is used it will move the motor in a - or + direction*/ fRight.spin(fwd, +Controller1.Axis3.position(pct) -Controller1.Axis1.position(pct), pct); /*Front Left motor, once axis3 is used it will move fwd or rev, if axis1 is used it will move the motor in a - or + direction*/ fLeft.spin(fwd, +Controller1.Axis3.position(pct) +Controller1.Axis1.position(pct), pct);
/*Rear Left motor, once axis3 is used it will move fwd or rev, if axis1 is used it will move the motor in a - or + direction*/ rLeft.spin(fwd, +Controller1.Axis3.position(pct) +Controller1.Axis1.position(pct), pct); /*-------------------------------------------------------------------------------------------------------------------------------*/ explanation to this: So looking at this it is a lot of simple math and basic understanding of coding. So for example I want rLeft(rear Left motor) to spin forward unpon the user using Axis3 on the controller. Then calling position(pct) tells the robot to move well the Axis3 is in use, and the turning is pretty simple just take a look at your motors and look for the spinning circles. to turn right i would want my right drive side to go negative direction while the left side goes positive. Not the best explanation but a basic one.
for a beginner in Vex coding, this video helps me a lot
thank you! my partner in robotics wrote our driver code, but neither of us really understand it so i’m re-doing it on my own. code gets frustrating, (especially c++ in my opinion) so thanks for the thorough explanation.
Yes. Thank you so much! I looked for a long time to find a video that was simple and easy to follow. This was just what I needed. It is my first year of robotics and we qualified for state based on skills score (thanks to your autonomous video) and then we qualified for worlds. None of that would have been possible without this video so thank you.
Good tutorial playlist. If you are looking to not use the built in ability to add arcade drive to drivetrain the following method will give you arcade drive. I maybe could have added left and right inversion parameters(you can see my one motor is inverted) and a speed and brake style parameter but I thought I would keep it simple:
void arcadeDrive(controller Controller, motor_group LeftMotor, motor_group RightMotor)
{
if(Controller.Axis3.position(percent) != 0 || Controller.Axis4.position(percent) != 0)
{
int RightSpeed = (Controller.Axis3.position(percent) - Controller.Axis4.position(percent))/2;
int LeftSpeed = (Controller.Axis3.position(percent) + Controller.Axis4.position(percent))/2;
LeftMotor.spin(forward,LeftSpeed,percent);
RightMotor.spin(reverse,RightSpeed,percent);
}
else
{
LeftMotor.stop(brake);
RightMotor.stop(brake);
}
}
Thanks bro
if you are still a begineer and want to know a simplified version of this you can do something as simple as this
/*--------------------------------This section gets the raw joystick values from the user input----------------------------------*/
/*-------------------------------------------------------------------------------------------------------------------------------*/
/*Rear Right motor, once axis3 is used it will move fwd or rev, if axis1 is used it will move the motor in a - or + direction*/
rRight.spin(fwd, +Controller1.Axis3.position(pct) -Controller1.Axis1.position(pct), pct);
/*Front Right motor, once axis3 is used it will move fwd or rev, if axis1 is used it will move the motor in a - or + direction*/
fRight.spin(fwd, +Controller1.Axis3.position(pct) -Controller1.Axis1.position(pct), pct);
/*Front Left motor, once axis3 is used it will move fwd or rev, if axis1 is used it will move the motor in a - or + direction*/
fLeft.spin(fwd, +Controller1.Axis3.position(pct) +Controller1.Axis1.position(pct), pct);
/*Rear Left motor, once axis3 is used it will move fwd or rev, if axis1 is used it will move the motor in a - or + direction*/
rLeft.spin(fwd, +Controller1.Axis3.position(pct) +Controller1.Axis1.position(pct), pct);
/*-------------------------------------------------------------------------------------------------------------------------------*/
explanation to this: So looking at this it is a lot of simple math and basic understanding of coding. So for example I want rLeft(rear Left motor) to spin forward unpon the user using Axis3 on the controller. Then calling position(pct) tells the robot to move well the Axis3 is in use, and the turning is pretty simple just take a look at your motors and look for the spinning circles. to turn right i would want my right drive side to go negative direction while the left side goes positive.
Not the best explanation but a basic one.