summaryrefslogtreecommitdiff
path: root/digital/mimot/src/dirty/motor_model.host.c
diff options
context:
space:
mode:
authorNicolas Schodet2010-05-04 02:24:57 +0200
committerNicolas Schodet2010-05-04 02:24:57 +0200
commit50b8abe7f025cd2a4a498c24da37826a6e2b585a (patch)
tree3ba509df73b2b209000d50b8e704b7a23f45dec9 /digital/mimot/src/dirty/motor_model.host.c
parente8f1654b1ebd70c67c4e22067221cc3d76739e68 (diff)
digital/mimot/src/dirty: add motor hardware limits
See r1069.
Diffstat (limited to 'digital/mimot/src/dirty/motor_model.host.c')
-rw-r--r--digital/mimot/src/dirty/motor_model.host.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/digital/mimot/src/dirty/motor_model.host.c b/digital/mimot/src/dirty/motor_model.host.c
index 37171c32..f87e7db6 100644
--- a/digital/mimot/src/dirty/motor_model.host.c
+++ b/digital/mimot/src/dirty/motor_model.host.c
@@ -77,6 +77,18 @@ void motor_model_step (struct motor_t *m)
+ h * m->m.i_G * m->m.i_G * m->m.ro_G / m->m.J
* (m->m.Kt * m->i - m->m.Rf * m->o);
th_ = m->th + h * m->o;
+ /* Test for limits overflow, I have no proof it works right for the
+ * moment, only suspicions. */
+ if (th_ < m->m.th_min)
+ {
+ th_ = m->m.th_min;
+ o_ = 0.0;
+ }
+ else if (th_ > m->m.th_max)
+ {
+ th_ = m->m.th_max;
+ o_ = 0.0;
+ }
/* Ok, now store this step. */
m->i = i_;
m->o = o_;