The Turtlebot handles this in the Turtlebot Node, which forms the ROS interface to the iRobot Create hardware.
The most relevant bits are:
Line 398 and forward, where if there is a cmd_vel
to be sent to the hardware, it first executes the self.check_bumpers
function at Line 429.
def check_bumpers(self, s, cmd_vel):
# Safety: disallow forward motion if bumpers or wheeldrops
# are activated.
# TODO: check bumps_wheeldrops flags more thoroughly, and disable
# all motion (not just forward motion) when wheeldrops are activated
forward = (cmd_vel[0] + cmd_vel[1]) > 0
if self.stop_motors_on_bump and s.bumps_wheeldrops > 0 and forward:
return (0,0)
else:
return cmd_vel
The actual hardware interaction is taking place in the roomba_sensor_handler.py file or the create_sensor_handler.py file, also in the turtlebot_node
package.