setting up the development environment
- Install ros noetic desktop
http://wiki.ros.org/noetic/Installation/Ubuntu
- Create local workspace
mkdir -p catkin_ws/src && cd catkin_ws
- Build the workspace
catkin_make
- Clone the repository
git clone https://github.com/21coolkarni/Flytbase_assisment.git
-
Copy and pase the turtle package folder to
catkin_ws/src
-
Build the workspace
catkin_make
- Source the workspace
source devel/setup.bash
- Open another terminal and run roscore
roscore
- Run turtlesim node
rosrun turtlesim turtlesim_node
- Run the code using
rosrun turtle assisment.py
- Enter your testcase choice from 1 to 5 to run the specific testcase
Algorithm:
- Find Euclidian distance from the current point to the desigred point and calculate the speed by multiplying it with a constant p value, as the distance decreases speed decreases and eventually becomes zero.
- Find Desigred angle by using a tan2 function which gives the angle of the disired goal and multiply it with a constant p value, as the angle decreases turning speed decreases and eventually becomes zero.
- Publish these values with twist msgs.
- Accept a certain ammount of error while reaching the distance to avoid infinite loop.
Output:
Algorithm:
- Spawn the turtle at the start of the grid position.
- Rotate and move functions will move the turtle into desired grid.
- Turtle will accelerate till it reaches the mid point of the total distance and then it will decelerate again it reaches the final destination
Output:
Algorithm:
- Spwn the turtle at a position which is suitable for drawing the circle.
- Using circle position publish twist msgs which publishes the twist msgs with linear.x as radius and angular,z as speed.
- Multithreading : Create a timer object with rosspy duration of 5 seconds to publish /rt_real_pose and tr_noisy_pose msgs
Output:
Algorithm:
Multithreading : Create a timer object with very short rospy duration for controlling the police turtle to chase down the robber turtle with fast speed.
- Fast_pt_publisher function will spawn the police turtle after 10 seconds with pt_spawn_bool tag
- Then it will subscribe to the /rt_real_pose msgs
- Then after getting the position of the thief police turtle will catch the thief with '/rt_real_pose' with faster speed than robber turtle
Output:
Algorithm:
- Algorithm is similar to case4 but this time speed of the turtle is slow so we need to predict the future co-ordinates of the turtle where its going to be at perticular point of time after getting its location and then reach on that position before the robber turtle to catch it.
- We will use predict function which will give the future predicted points of the robber turtle and then use slow_pt_publisher funciton to reach at that perticular location with slower speed than robber turtle.
- First of all go to the center of the turtle window as every point on the turtle window is at equal distance from the center position which is easy to catch the robber turtle.
- Then record the 3 positions of the robber turtle within 15 seconds.
- Calculate the center of the circle and radius of the circle in which the robber turtle is rotating with define_circle function.
- Wait for the new '/rt_real_pose' msgs and as soon as the msg arrives calculate the theta of the predicted position of the turtle using atan2 function and then add a constant theta value to the desigred theta which will compensate for slow speed.
- Go to the predicted position and catch the thief.
Output: