wall_follow_service module
Wall Follower ROS Node
This module implements a ROS node that enables a mobile robot to follow a wall using a laser scanner. The robot switches between different states based on the detected distance to obstacles.
The finite-state machine consists of: 1. Find the Wall: Moves forward while slightly turning right. 2. Turn Left: Rotates left when an obstacle is detected in front. 3. Follow the Wall: Moves forward while staying parallel to the wall.
The node listens to laser scan data, determines the robot’s surroundings, and adjusts its movement accordingly.
Dependencies:
rospy: Python client library for ROS.
sensor_msgs.msg.LaserScan: Provides laser scan data.
geometry_msgs.msg.Twist: Message type for velocity commands.
std_srvs.srv.SetBool: Service to start/stop wall-following behavior.
- wall_follow_service.active_ = False
Boolean flag to enable/disable the node.
- wall_follow_service.change_state(state)[source]
Changes the robot’s state in the finite-state machine.
Parameters: state : int
The new state (0: Find the wall, 1: Turn left, 2: Follow the wall).
- wall_follow_service.clbk_laser(msg)[source]
Callback function for the laser scan subscriber.
This function processes laser scan data and updates the regions_ dictionary with the minimum distance readings from different sections around the robot.
Parameters: msg : LaserScan
The received laser scan message.
- wall_follow_service.find_wall()[source]
Generates a velocity command to search for a nearby wall.
The robot moves forward while slightly turning right.
Returns: Twist
The velocity command.
- wall_follow_service.follow_the_wall()[source]
Generates a velocity command to follow a detected wall.
The robot moves forward while staying parallel to the wall.
Returns: Twist
The velocity command.
- wall_follow_service.main()[source]
Main function to initialize the node, handle subscriptions, and control the robot.
- wall_follow_service.pub_ = None
Publisher for velocity commands.
- wall_follow_service.state_ = 0
Current state (0 Find the wall, 1 Turn left, 2 Follow the wall).
- wall_follow_service.take_action()[source]
Determines the robot’s next action based on laser scan readings.
The function analyzes the distances to obstacles and selects the appropriate state (find wall, turn left, or follow wall).