This code implements a control node for a robot simulation. The speed of the robot can be increased or reduced using services and user input. You can also reset the robot's position.
Copy the 2 packages in your ros workspace src folder.
Compile with catkin_make.
Run using the command roslaunch robot_control robot_launch.xml
To change speed you can call the /reduce_speed and /increase_speed empty services.
You can also input 1 to increase speed, 2 to reduce it and 3 to reset the robot's position.
This node takes a range as parameters and returns the laserscan /base_scan filtered on this range on a chosen topic.
/base_scanrobot laserscan.
/scan_topicfiltered laserscan.
min_angle(double)minimum angle of the chosen range.max_angle(double)maximum angle of the chosen range.scan_topic(string)topic name for the published scan.
This node publishes the desired twist of the robot on the /cmd_vel topic.
This node also implements the /increase_speed and /reduce_speed services.
/right_scanrobot right laserscan./left_scanrobot left laserscan./front_right_scanrobot front right laserscan./front_left_scanrobot front left laserscan./current_speedcurrent linear speed.
/cmd_veldesired velocities.
/increase_speed(Empty) increase speed by 20%./reduce_speed(Empty) reduce speed by 20%.
The node gets the difference in minimum distance between the front left and front right scans. Then it turns the robot away from the wall, with the current velocity as linear speed. If the robot is too close to the front wall then the node gets the difference between right and left distances, slows down the robot and turns away from the closest wall. The different services add or reduce the current speed by 20%.
This node implements the /increase_speed, /reduce_speed and /reset_positions service clients.
The node waits for a user input (between 1 and 3) and calls the corresponding service (add or reduce speed and reset).