summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--n/line-follower/src/main.c12
-rw-r--r--n/line-follower/src/speed.c9
2 files changed, 15 insertions, 6 deletions
diff --git a/n/line-follower/src/main.c b/n/line-follower/src/main.c
index 91b5a8b..134ba79 100644
--- a/n/line-follower/src/main.c
+++ b/n/line-follower/src/main.c
@@ -258,16 +258,16 @@ proto_callback (uint8_t cmd, uint8_t argc, proto_arg_t argv[])
speed_kd = argv[0] << 8 | argv[1];
break;break;
case c ('I', 6): // set lInefol pid coefs : "!Ippppiiiidddd"
- speed_kp = argv[0] << 8 | argv[1];
- speed_ki = argv[2] << 8 | argv[3];
- speed_kd = argv[4] << 8 | argv[5];
+ line_kp = argv[0] << 8 | argv[1];
+ line_ki = argv[2] << 8 | argv[3];
+ line_kd = argv[4] << 8 | argv[5];
break;
case c ('I', 4): // set lInefol pid coefs : "!Ippppiiiidddd"
- speed_kp = argv[0] << 8 | argv[1];
- speed_ki = argv[2] << 8 | argv[3];
+ line_kp = argv[0] << 8 | argv[1];
+ line_ki = argv[2] << 8 | argv[3];
break;
case c ('I', 2): // set lInefol pid coefs : "!Ippppiiiidddd"
- speed_kp = argv[0] << 8 | argv[1];
+ line_kp = argv[0] << 8 | argv[1];
break;
case c ('f', 2):
postrack_set_footing (argv[0] << 8 | argv[1]);
diff --git a/n/line-follower/src/speed.c b/n/line-follower/src/speed.c
index ea31286..861fac8 100644
--- a/n/line-follower/src/speed.c
+++ b/n/line-follower/src/speed.c
@@ -28,6 +28,9 @@
// C'est porc :
extern uint8_t motor_mode;
+/** couunter for the sequence of zeros. */
+uint16_t zeroCnt;
+
/** Statistics about pid components. */
int16_t pid_pid,pid_p,pid_i,pid_d;
@@ -203,6 +206,7 @@ speed_compute_linefol_pwm (void)
e_old = e;
if(lineActiveBits > 1)
{
+ zeroCnt = 0;
if(pwm > 0)
{
speed_left = linefol_saturate (((linefol_max_pwm * PWM_MAX) >> 8) - pwm);
@@ -216,9 +220,14 @@ speed_compute_linefol_pwm (void)
}
else
{
+ zeroCnt++;
+ if (zeroCnt > 22)
+ {
motor_mode = 2;
speed_left_aim = 0;
speed_right_aim = 0;
+ }
+
// pwm_left = 0;
// pwm_right = 0;
}