Skip to content

Commit c35950e

Browse files
committed
fix
1 parent a87f632 commit c35950e

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# Arduino_Robot_Firmware
1+
# Arduino_Alvik_Firmware
22
firmware

library.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ sentence=Library and firmware for Arduino Alvik
66
paragraph=This library is used to build the firmware used by Arduino Alvik, examples show you how to customize the firmware.
77
category=Robotics
88
url=https://github.com/gbr1/Arduino_Alvik_Firmware
9+
architectures=stm32
910
includes=Arduino_Alvik_Firmware.h
1011
depends=Arduino_APDS9960, Arduino_MAX17332, STM32duino_LSM6DSO, STM32duino_MotionFX, STM32duino_VL53L7CX, AT42QT, ucPack

src/Arduino_Alvik_Firmware.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -620,19 +620,20 @@ void Arduino_Alvik_Firmware::rotate(const float angle){
620620
float initial_angle=kinematics->getTheta();
621621
float error=angle-initial_angle;
622622
unsigned long t=millis();
623-
while(abs(error)>0){
623+
while(abs(error)>2){
624624
if (millis()-t>20){
625625
t=millis();
626626
updateMotors();
627+
kinematics->updatePose(motor_control_left->getAngle(),motor_control_right->getAngle());
628+
error=angle-kinematics->getTheta();
629+
Serial.println(error);
627630
}
628631
if (error>0){
629-
drive(0,90);
632+
drive(0,40);
630633
}else{
631-
drive(0,-90);
634+
drive(0,-40);
632635
}
633-
kinematics->updatePose(motor_control_left->getTravel(),motor_control_right->getTravel());
634-
error=kinematics->getTheta()-initial_angle;
635-
Serial.println(error);
636+
636637
}
637638
drive(0,0);
638639
updateMotors();

src/motor_control/motor_control.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class MotorControl{
4242
float kd;
4343

4444
float travel;
45+
float angle;
4546
float reference;
4647

4748
float trip;
@@ -88,6 +89,7 @@ class MotorControl{
8889
controller_period = _controller_period;
8990

9091
travel=0.0;
92+
angle=0.0;
9193
reference = 0.0;
9294

9395
trip=0.0;
@@ -224,7 +226,8 @@ class MotorControl{
224226

225227
measure = encoder->getCount();
226228
encoder->reset();
227-
travel += measure*conversion_factor_travel;
229+
angle = measure*conversion_factor_travel;
230+
travel += angle;
228231
measure = measure*conversion_factor;
229232

230233
/* experimental
@@ -307,6 +310,10 @@ class MotorControl{
307310
return travel;
308311
}
309312

313+
float getAngle(){
314+
return angle;
315+
}
316+
310317

311318
};
312319

0 commit comments

Comments
 (0)