Here's how this looks in action:
It's a bit dicey without the cover on. Unfortunately the cover is part of what holds the bumper in place. So it pops off quite easily. But I managed to at least take that video.
Here's a diff for the additional code:
https://github.com/meatheadmike/robie_motor_control/commit/9e3fbd31e4923b0f36f065001d1aed07679bfb31
As you can see there's not really much to it. I set up the pins for the bumper and the other switches (which don't really do anything yet). Then I set up 2 global variables to specify when the bumper is tripped. Why two? Because I want to ensure both motors are stopped individually. That way I know both have gone in reverse so I can reactivate the forward motion.
The main work is done in the bumper_pressed_callback function. The callback is triggered by an interrupt. So the code will continue looping until the bumper is pressed. Then the callback gets triggered and does its magic.
No comments:
Post a Comment