Skip to content

Commit 4f0eaca

Browse files
committed
Add distance to MotorData
1 parent fa01097 commit 4f0eaca

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

src/motor_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void motor_data_init(MotorData *m) {
3131
ema_init(&m->abs_erpm_smooth);
3232

3333
m->speed = 0.0f;
34+
m->distance = 0.0f;
3435

3536
m->current = 0.0f;
3637
m->dir_current = 0.0f;
@@ -121,6 +122,7 @@ void motor_data_update(MotorData *m, float dt) {
121122
// when motor config changes, there's no way to know, we'll have to poll).
122123
// And it's only possible on 6.05+.
123124
m->speed = VESC_IF->mc_get_speed() * 3.6;
125+
m->distance = VESC_IF->mc_get_distance();
124126

125127
m->current = VESC_IF->mc_get_tot_current_filtered();
126128
m->dir_current = VESC_IF->mc_get_tot_current_directional_filtered();

src/motor_data.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ typedef struct {
3535
EMA abs_erpm_smooth;
3636

3737
float speed;
38+
float distance;
3839

3940
float current; // "regular" motor current (positive = accelerating, negative = braking)
4041
float dir_current; // directional current (sign represents direction of torque generation)

0 commit comments

Comments
 (0)