Bayley Wang
/
foc-ed_in_the_bot_compact
robot
Diff: main.cpp
- Revision:
- 74:f10cb573d7ca
- Parent:
- 73:d44bc3a46942
- Child:
- 75:591556ce033d
diff -r d44bc3a46942 -r f10cb573d7ca main.cpp --- a/main.cpp Mon Feb 20 12:37:21 2017 +0000 +++ b/main.cpp Fri Feb 24 13:03:34 2017 +0000 @@ -123,7 +123,12 @@ } void slow_loop() { - control.torque_percent = update_filter(control.torque_percent, th->map(io.throttle_in->get_throttle(), read.w), THROTTLE_FILTER_STRENGTH); + float x = io.throttle_in->get_throttle(); + if (x < THROTTLE_FILTER_THRESHOLD) { + control.torque_percent = update_filter(control.torque_percent, th->map(io.throttle_in->get_throttle(), read.w), THROTTLE_FILTER_STRENGTH_LOW); + } else { + control.torque_percent = update_filter(control.torque_percent, th->map(io.throttle_in->get_throttle(), read.w), THROTTLE_FILTER_STRENGTH_HI); + } dq->map(control.torque_percent, read.w, &control.d_ref, &control.q_ref); } @@ -148,8 +153,9 @@ } void log() { - io.pc->printf("%d,%d,%d,%d,%d,%d,%d,%d\n", (int) read.w, (int) control.d_ref, (int) control.d_filtered, (int) control.q_ref, (int) control.q_filtered, (int) (255 * control.torque_percent), - (int) (255 * foc.vd), (int) (255 * foc.vq)); + //io.pc->printf("%d,%d,%d,%d,%d,%d,%d,%d\n", (int) read.w, (int) control.d_ref, (int) control.d_filtered, (int) control.q_ref, (int) control.q_filtered, (int) (255 * control.torque_percent), + // (int) (255 * foc.vd), (int) (255 * foc.vq)); + io.pc->printf("%d\n", (int) (255 * control.torque_percent)); wait(1.0f / LOG_FREQUENCY); }