@@ -90,8 +90,9 @@ public void travel(float distance, boolean immediateReturn) {
90
90
91
91
}
92
92
93
- public void travelDegrees (int degrees ) {motor1 .setSpeed (0 );
94
- setSpeed (speed );
93
+ public void travelDegrees (int degrees ) {
94
+ stop ();
95
+ setSpeed (speed );
95
96
synchronizeMotors ();
96
97
motor1 .rotate (degrees , true );
97
98
motor2 .rotate (degrees , true );
@@ -136,8 +137,6 @@ public void backward() {
136
137
// Starts backward movement of the robot
137
138
setSpeed (speed );
138
139
synchronizeMotors ();
139
- motor1 .setSpeed (0 );
140
- motor2 .setSpeed (0 );
141
140
if (inverted ) {
142
141
motor1 .forward ();
143
142
motor2 .forward ();
@@ -322,7 +321,6 @@ public void close() {
322
321
323
322
public void setSpeed (float speed ) {
324
323
// Sets the speed of the robot
325
- stop ();
326
324
this .speed = speed ;
327
325
synchronizeMotors ();
328
326
motor1 .setSpeed (speed );
@@ -350,8 +348,11 @@ public int getRightMotorSpeed() {
350
348
public void startRotate (boolean right ) {
351
349
// Starts a rotating motion
352
350
// If right is true, the robot will rotate right, otherwise he will rotate left
351
+ stop ();
352
+ synchronizeMotors ();
353
353
motor1 .setSpeed (rotateSpeed );
354
354
motor2 .setSpeed (rotateSpeed );
355
+ motor1 .endSynchronization ();
355
356
synchronizeMotors ();
356
357
if (right ) {
357
358
if (inverted ) {
@@ -482,6 +483,8 @@ public void rotate(float angle, float friction, boolean immediateReturn) {
482
483
synchronizeMotors ();
483
484
motor1 .setSpeed (rotateSpeed );
484
485
motor2 .setSpeed (rotateSpeed );
486
+ motor1 .endSynchronization ();
487
+ synchronizeMotors ();
485
488
motor1 .rotate ((int ) (degreesToTravel * friction ), true );
486
489
motor2 .rotate ((int ) (-degreesToTravel * friction ), true );
487
490
motor1 .endSynchronization ();
@@ -675,15 +678,19 @@ public void resetRightTachoCount() {
675
678
}
676
679
677
680
public void quickStop () {
681
+ synchronizeMotors ();
678
682
motor1 .setAcceleration (QUICK_ACCELERATION );
679
683
motor2 .setAcceleration (QUICK_ACCELERATION );
684
+ motor1 .endSynchronization ();
680
685
stop ();
681
686
setAcceleration (acceleration );
682
687
}
683
688
684
689
public void quickStop (boolean immediateReturn ) {
690
+ synchronizeMotors ();
685
691
motor1 .setAcceleration (QUICK_ACCELERATION );
686
692
motor2 .setAcceleration (QUICK_ACCELERATION );
693
+ motor1 .endSynchronization ();
687
694
stop (immediateReturn );
688
695
setAcceleration (acceleration );
689
696
}
0 commit comments