turtlebot3_obstacle_detection

This file is ai generated. Do not edit this file directly. Instead, edit the node source code and run the generate-node-docs command to update this file.

Description

An obstacle detection node that automatically stops the TurtleBot3 when obstacles are detected in front of it. The node monitors laser scan data and prevents the robot from colliding with obstacles within a specified distance threshold. It allows teleoperation commands to pass through unless an obstacle is detected.

Publishers

  • cmd_vel (geometry_msgs/Twist)

    • Final velocity commands after applying obstacle avoidance logic

Subscribers

  • scan (sensor_msgs/LaserScan)

    • Laser scan data for obstacle detection

    • Uses sensor data QoS profile

  • cmd_vel_raw (geometry_msgs/Twist)

    • Raw velocity commands from teleoperation or other controllers

    • Uses sensor data QoS profile

Parameters

The node uses hardcoded parameters (can be modified in source):

  • Stop distance: 0.5 meters

  • Stop angle range: -90° to 90° (front hemisphere)

  • Default linear velocity: 0.2 m/s

  • Timer period: 0.1 seconds (10 Hz)

Example Usage

Launch the obstacle detection node:

ros2 run turtlebot3_example turtlebot3_obstacle_detection

Use with keyboard teleoperation:

# Terminal 1: Start obstacle detection
ros2 run turtlebot3_example turtlebot3_obstacle_detection

# Terminal 2: Send raw velocity commands
ros2 topic pub /cmd_vel_raw geometry_msgs/msg/Twist "{linear: {x: 0.2}}" 

Behavior

  • The node monitors a 180° arc in front of the robot (±90° from forward)

  • When an obstacle is detected within 0.5 meters:

    • Linear velocity is set to 0.0 (stops forward motion)

    • Angular velocity is preserved (allows turning in place)

    • A warning message is logged (throttled to once per 2 seconds)

  • When no obstacle is detected:

    • The raw velocity commands are passed through unchanged

  • The node publishes filtered commands at 10 Hz

Notes

  • Requires a working laser scanner (e.g., LDS-01, LDS-02)

  • The stop distance and detection angle can be modified in the source code

  • Compatible with any teleoperation or navigation node that publishes to /cmd_vel_raw