-
Notifications
You must be signed in to change notification settings - Fork 5
Controlling Turtlebot using Ultrasonic sensor
A script is written such that if the distance of the object from ultrasonic sensor is less than 10 cm,the the Turtlebot will move forward.Following wiki consists of the steps to achieve this. Follow the previous wiki to integrating ROS and arduino and publish HC-SR04 ultrasonic sensor data on a rostopic.
Follow Turtlebot tutorial:http://learn.turtlebot.com/2015/02/01/10/
The example goforward.py has been used as refrence.
If your followed the previous wiki,then the sensor data is used to calculate distance and is being published on topic 'chatter' with message type 'Float64'.Hence,the node must subscribe to the topic 'chatter'.
The velocity(linear and angular) is published on topic 'cmd_vel_mux/input/navi' with message type as 'Twist'.Twist is a ROS message type in geometry_msgs.geometry_msgs provides messages for common geometric primitives such as points, vectors, and poses.For more details,refer:http://wiki.ros.org/geometry_msgs
As our robot works in 2D space,hence we are concerned with linear.x and angular.z velocities only.
The code can be download from:https://github.com/surabhi96/libbot
The code is such that id the distance measured id less than 10 cm,then the robot move forward.
To run the script from terminal,move to the location where the file exists and run command 'python move.py'
Note:the code is to understand the concepts and test the working.
The reference distance is set.The error is calculated based on the reference and measured distance.The value of kp is set as 0.1 and the angular velocity is calculated as kp*error. Download the code from:https://github.com/surabhi96/libbot/tree/Turtlebot
The error starts accumulating and the robot maloperates.The graph of angular velocity vs time is as seen from:
https://github.com/surabhi96/libbot/blob/Turtlebot/graphs/kp_0.1.png