User Tools

Site Tools


turtlebot:adventures:sensing101_hints

This is an old revision of the document!


Sensing 101 Hints

Bumper Events

The button callback code should be pretty self-explanatory. The main thing is to create your own subscriber, then to use rostopic echo and rostopic type to understand the structure of the bumper events enough to create a properly modified version of the button callback function. This code should then be re-used and modified for the next learning task.

Bumper Events for Safe Forward Motion

What this requires is two variables to be added to your goforward class. One for the bumper state in the finite machine, and one to keep track of the bumpers that are hit. Call the first one bstate and the second one bhit.

Use the bits in bhit to keep track of which bumpers were hit. The first bit can be the left bumper, the second bit the middle bumper, and the third bit the right bumper. The bits toggle based on the event message for the bumpers.

The bump state then should have three states, let's order them as 0, 1, and 2. In state 0, the robot should be moving forward so long as (bhit is equal to 0). Having any bumper be hit (so that bhit > 0) should immediately trigger state 1. If the bumpers cease to be hit when in state 1 (bhit equals 0 again) should trigger state 2. Pausing fully without hits in state 2 should then return to state 0. Some of this logic gets implemented in the bumper callback function (the hit part), some of it is in the infinite loop for the robot forward motion (the finite state machine logic).

Drawing a state diagram for the finite state machine should clarify what is involved. If you do so, then you should see that the main logic is predicated on a boolean value that checks the hit and drop statuses (you can even go crazy and add in the cliff sensor status).

Gyro-Based Square Drawing

Coming Soon (hopefully) …

Gyro-Based Forward Motion

Coming Soon (hopefully) …


Sensing 101

turtlebot/adventures/sensing101_hints.1441754274.txt.gz · Last modified: 2024/08/20 21:38 (external edit)