필터 지우기
필터 지우기

Ev3 mindstorm going back and forward in a straight line

조회 수: 1 (최근 30일)
Karl-Axel Ruuth
Karl-Axel Ruuth 2017년 12월 17일

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개)

카테고리

Help CenterFile Exchange에서 ROS Toolbox Supported Hardware에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by