File tree Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ uint8_t label;
29
29
uint8_t control_type;
30
30
uint8_t msg_size;
31
31
uint8_t ack_required=0 ;
32
+ int ack_counter=0 ;
32
33
33
34
34
35
unsigned long tmotor=0 ;
@@ -158,13 +159,15 @@ void loop(){
158
159
alvik.disablePositionControl ();
159
160
alvik.rotate (value);
160
161
ack_required=MOVEMENT_ROTATE;
162
+ ack_counter=5 ;
161
163
break ;
162
164
163
165
case ' G' :
164
166
packeter.unpacketC1F (code, value);
165
167
alvik.disablePositionControl ();
166
168
alvik.move (value);
167
169
ack_required=MOVEMENT_MOVE;
170
+ ack_counter=5 ;
168
171
break ;
169
172
170
173
case ' Z' :
@@ -253,14 +256,26 @@ void loop(){
253
256
if (millis ()-tack>100 ){
254
257
tack=millis ();
255
258
msg_size = packeter.packetC1B (' x' , 0 );
256
- if (ack_required==MOVEMENT_ROTATE){
257
- msg_size = packeter.packetC1B (' x' , ' R' );
258
- Serial.println (" R" );
259
+
260
+ if (alvik.isTargetReached ()){
261
+ if (ack_required==MOVEMENT_ROTATE){
262
+ msg_size = packeter.packetC1B (' x' , ' R' );
263
+ // ack_counter--;
264
+ Serial.println (" R" );
265
+ }
266
+ if (ack_required==MOVEMENT_MOVE){
267
+ msg_size = packeter.packetC1B (' x' , ' M' );
268
+ // ack_counter--;
269
+ Serial.println (" M" );
270
+ }
259
271
}
260
- if (ack_required==MOVEMENT_MOVE){
261
- msg_size = packeter.packetC1B (' x' , ' M' );
262
- Serial.println (" M" );
272
+
273
+
274
+ if (ack_counter<=0 ){
275
+ ack_counter=0 ;
276
+ ack_required=MOVEMENT_DISABLED;
263
277
}
278
+
264
279
alvik.serial ->write (packeter.msg , msg_size);
265
280
}
266
281
Original file line number Diff line number Diff line change @@ -751,10 +751,11 @@ void Arduino_AlvikCarrier::lockingRotate(const float angle){
751
751
}
752
752
753
753
void Arduino_AlvikCarrier::rotate (const float angle){
754
+ disableKinematicsMovement ();
755
+ kinematics_achieved=false ;
754
756
rotate_pid->reset ();
755
757
rotate_pid->setReference (kinematics->getTheta ()+angle);
756
758
kinematics_movement=MOVEMENT_ROTATE;
757
- kinematics_achieved=false ;
758
759
}
759
760
760
761
void Arduino_AlvikCarrier::lockingMove (const float distance){
@@ -784,6 +785,9 @@ void Arduino_AlvikCarrier::lockingMove(const float distance){
784
785
}
785
786
786
787
void Arduino_AlvikCarrier::move (const float distance){
788
+ disableKinematicsMovement ();
789
+ kinematics_achieved=false ;
790
+
787
791
move_pid->reset ();
788
792
previous_travel=kinematics->getTravel ();
789
793
if (distance<0 ){
@@ -794,7 +798,6 @@ void Arduino_AlvikCarrier::move(const float distance){
794
798
}
795
799
move_pid->setReference (distance);
796
800
kinematics_movement=MOVEMENT_MOVE;
797
- kinematics_achieved=false ;
798
801
}
799
802
800
803
void Arduino_AlvikCarrier::disableKinematicsMovement (){
You can’t perform that action at this time.
0 commit comments