Hi, any one can share some help on a autonomous in Vex C++? For some reason the program that my son is writing does not integrate the command on the robot and reads commands line by line instead of reading them as a whole function.
If it’s trying to go forward, it turns on only one motor in the base. Its as if each command only takes control of a certain motor and then does this to another one in the next command, it just cycles between the four motors on the base. We don’t know what’s causing this problem or how to fix it.
The program is using blocking functions, meaning that the program is waiting for the function to finish before moving on. You want to use the non-blocking versions of the motor control. This article may help:
https://help.vex.com/article/120-how-to-use-blocking-vs-non-blocking-code
It would help in the future to copy and paste a few line of the program as an example of the problem.
It doesn’t work… Do you have other idea? Can we share the autonomous to be evaluate by you?
void driveForward(double speed,double rotations){
RightDrive.rotateFor(-rotations,rotationUnits::rev,speed,velocityUnits::pct,false);
LeftDrive.rotateFor(-rotations,rotationUnits::rev,speed,velocityUnits::pct,false);
RightDrive2.rotateFor(-rotations,rotationUnits::rev,speed,velocityUnits::pct,false);
LeftDrive2.rotateFor(-rotations,rotationUnits::rev,speed,velocityUnits::pct);
Try doing something like this in the void pre auton if you’re using the competition template.
having the ,false at the end will stop allow all motors to move.
hope this’ll help
I’ll try it!!
I know whats going on. You cant have the moters run in time units
You have do
Motor.spin(vex::directiontype::fwd);
2Motor.spin(vex::directiontype::fwd);
Vex::task::sleep(1000);
Motor.stop();
2Mtoor.stop();
vex::task::sleep(1000); thats one second
You can use “fwd” or “rev”