You are browsing as a guest. Sign up (or log in) to start making projects!

Open comments for this post

46m 28s logged

Today i ported the parking function from the old robot over to the new one. the new robot is alot faster so before anything i had to write a function to drive at a specific rpm instead of just slamming a fixed pwm duty like before. first try was a plain P controller off the encoder feedback but that failed, at low rpm the motor just sits there and stalls because it needs a bigger push to break free. so i added an I term, basically if the encoder says the wheel isnt moving the integral keeps winding up the duty till it hits the cap and that shoves the robot forward, then once its actually rolling the controller eases the power back down to hold the target rpm. after i got it moving (slowly at first) i swapped all the old set_speed() calls in parking for start_rpm_control() and stop_rpm_control() so the rpm loop runs in the background while the main code does the steering.then because the camera sits at a diffrent angle on this robot i had to retune the wall following distances too. last year doing wall follow off the distance sensor dint work well so this time im doing it from the camera, which means the numbers from before were all off.debugging wise there was a couple of annoying ones. one time i forgot to start the motor in reverse and it drove forward instead of back, took me ages to find because the encoder was reading distance as a absolute value so going the wrong way still looked like “progress” to the controller. there was also a issue when i hit ctrl c, the thread that runs the rpm loop wasnt closing cleanly so it kept re commanding the motor and the robot would keep going for like 2-3 sec after i killed it, fixed that by stopping the thread first before the gpio gets torn down.lastly once the whole thing actually worked end to end i went back and tuned the stop distances so it parks cleanly and doesnt clip the walls. robot finally parked.

0
2

Comments 0

No comments yet. Be the first!