Ev3 mindstorm going back and forward in a straight line
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to write a code for my Ev3 robot with two motors. I want it to be able to go a certain distance, in this case forward until the motors have turned a maximum of 2500 degress for four seconds. Then I want the robot to go back the same distance. But the problem is that sometimes only one motor spins while the other does nothing and sometimes a motor will continue to spin long after it has returned to its original position. I wonder if there is any way I can improve the code I have. I have tried it on several different Ev3 equitment so it is most likely not a hardware problem. Any help would be appreciated :)
b = Brick('ioType','usb'); b.outputStepSpeed(0,Device.MotorA,60,0,2500,0,Device.Brake); b.outputStepSpeed(0,Device.MotorD,60,0,2500,0,Device.Brake); pause(4) b.outputStop(0,Device.MotorA,Device.Brake); b.outputStop(0,Device.MotorD,Device.Brake); tacho = b.outputGetCount(0,Device.MotorA); disp(['> Tachometer: ' num2str(tacho)]); b.outputClrCount(0,Device.MotorA); b.outputClrCount(0,Device.MotorD); pause(0) b.outputStepSpeed(0,Device.MotorA,-60,0,tacho,0,Device.Brake); b.outputStepSpeed(0,Device.MotorD,-60,0,tacho,0,Device.Brake); pause(4) b.outputStop(0,Device.MotorA,Device.Brake); b.outputStop(0,Device.MotorD,Device.Brake); tacho = b.outputGetCount(0,Device.MotorA); disp(['> Tachometer: ' num2str(tacho)]); b.outputClrCount(0,Device.MotorA); b.outputClrCount(0,Device.MotorD); clear
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu ROS Toolbox Supported Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!