Skip to content

21coolkarni/Flytbase_assisment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 

Repository files navigation

Flytbase Assisment

Created by: - Ramprasad Anand Kulkarni

setting up the development environment

  1. Install ros noetic desktop

http://wiki.ros.org/noetic/Installation/Ubuntu

  1. Create local workspace

mkdir -p catkin_ws/src && cd catkin_ws

  1. Build the workspace

catkin_make

  1. Clone the repository

git clone https://github.com/21coolkarni/Flytbase_assisment.git

  1. Copy and pase the turtle package folder to catkin_ws/src

  2. Build the workspace

catkin_make

  1. Source the workspace

source devel/setup.bash

  1. Open another terminal and run roscore

roscore

  1. Run turtlesim node

rosrun turtlesim turtlesim_node

  1. Run the code using

rosrun turtle assisment.py

  1. Enter your testcase choice from 1 to 5 to run the specific testcase

Case 1

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:

Case 2

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:

Case 3

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:

Case 4

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:

Case 5

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:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published