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;
2929uint8_t control_type;
3030uint8_t msg_size;
3131uint8_t ack_required=0 ;
32+ int ack_counter=0 ;
3233
3334
3435unsigned long tmotor=0 ;
@@ -158,13 +159,15 @@ void loop(){
158159 alvik.disablePositionControl ();
159160 alvik.rotate (value);
160161 ack_required=MOVEMENT_ROTATE;
162+ ack_counter=5 ;
161163 break ;
162164
163165 case ' G' :
164166 packeter.unpacketC1F (code, value);
165167 alvik.disablePositionControl ();
166168 alvik.move (value);
167169 ack_required=MOVEMENT_MOVE;
170+ ack_counter=5 ;
168171 break ;
169172
170173 case ' Z' :
@@ -253,14 +256,26 @@ void loop(){
253256 if (millis ()-tack>100 ){
254257 tack=millis ();
255258 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+ }
259271 }
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;
263277 }
278+
264279 alvik.serial ->write (packeter.msg , msg_size);
265280 }
266281
Original file line number Diff line number Diff line change @@ -751,10 +751,11 @@ void Arduino_AlvikCarrier::lockingRotate(const float angle){
751751}
752752
753753void Arduino_AlvikCarrier::rotate (const float angle){
754+ disableKinematicsMovement ();
755+ kinematics_achieved=false ;
754756 rotate_pid->reset ();
755757 rotate_pid->setReference (kinematics->getTheta ()+angle);
756758 kinematics_movement=MOVEMENT_ROTATE;
757- kinematics_achieved=false ;
758759}
759760
760761void Arduino_AlvikCarrier::lockingMove (const float distance){
@@ -784,6 +785,9 @@ void Arduino_AlvikCarrier::lockingMove(const float distance){
784785}
785786
786787void Arduino_AlvikCarrier::move (const float distance){
788+ disableKinematicsMovement ();
789+ kinematics_achieved=false ;
790+
787791 move_pid->reset ();
788792 previous_travel=kinematics->getTravel ();
789793 if (distance<0 ){
@@ -794,7 +798,6 @@ void Arduino_AlvikCarrier::move(const float distance){
794798 }
795799 move_pid->setReference (distance);
796800 kinematics_movement=MOVEMENT_MOVE;
797- kinematics_achieved=false ;
798801}
799802
800803void Arduino_AlvikCarrier::disableKinematicsMovement (){
You can’t perform that action at this time.
0 commit comments