-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Incorrect motor loop time for ev3dev #955
Comments
This makes it a lot better: diff --git a/bricks/ev3dev/pbinit.c b/bricks/ev3dev/pbinit.c
index b5bc099d2..46674bd85 100644
--- a/bricks/ev3dev/pbinit.c
+++ b/bricks/ev3dev/pbinit.c
@@ -39,7 +39,7 @@ static pthread_t task_caller_thread;
static void *task_caller(void *arg) {
struct timespec ts;
ts.tv_sec = 0;
- ts.tv_nsec = PBIO_CONFIG_CONTROL_LOOP_TIME_MS * 1000000;
+ ts.tv_nsec = 1000000;
while (!stopping_thread) {
MP_THREAD_GIL_ENTER();
diff --git a/lib/pbio/src/motor_process.c b/lib/pbio/src/motor_process.c
index d258f4742..1d7719b76 100644
--- a/lib/pbio/src/motor_process.c
+++ b/lib/pbio/src/motor_process.c
@@ -28,6 +28,9 @@ PROCESS_THREAD(pbio_motor_process, ev, data) {
for (;;) {
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER && etimer_expired(&timer));
// Update battery voltage.
pbio_battery_update();
@@ -36,9 +39,6 @@ PROCESS_THREAD(pbio_motor_process, ev, data) {
// Update servos
pbio_servo_update_all();
// Reset timer to wait for next update
- etimer_restart(&timer);
+ etimer_reset(&timer);
}
PROCESS_END(); And there is also |
This has a huge impact on performance (in a good way - motors work way better) and may even fix #953. It also fixes speed estimation. |
For the observer model, it is more important for the loop time to be constant on average. This reverts commit 2174461. See pybricks/support#955
Linked PR in pybricks/pybricks-micropython#146 |
For the observer model, it is more important for the loop time to be constant on average. This reverts commit 2174461. See pybricks/support#955
For the observer model, it is more important for the loop time to be constant on average. This reverts commit 2174461. See pybricks/support#955
pybricks/pybricks-micropython#146 is now merged, so closing. |
Describe the bug
Variation is expected, but it would be good to match the model, on average.
If we can't get the loop time down to 5 ms, we should instead discretize the model constants to match the average, e.g. 8 ms.
To reproduce
pybricks-micropython
to override the default.Screenshots
The text was updated successfully, but these errors were encountered: