Starting from:

$25

ROS -   Laboratory exercise 5 -Publishers-Subscribers   - Solved

Task 1: Mouse Tracker
a)    In this laboratory exercise, we will upgrade the mouse tracker package and use it to navigate the trutlebot from the turtlesim package. First, run track mouse.launch file created in the previous exercise and list the published topics. Copy the obtained list and paste it in the text box.
b)    Write a ROS node, turtle control.py, that will control the position of the first turtle in order to follow the mouse. You need to control both the angle and the distance towards the mouse. Make sure to use classes. Two following code snippets might help you get going.
def get  distance ( self , goal x , goal  y ): distance = sqrt (pow(( goal x − s e l f . pose . x) , 2)
+ pow(( goal  y − s e l f . pose . y) ,    2)) return    distance
    def    get ang distance ( self ,    goal x ,    goal  y ):
ang distance = atan2 ( goal pose . y − s e l f . pose .y , goal pose . x − s e l f . pose . x) − s e l f . pose . theta return    ang  distance
Keep in mind the difference between the screen coordinate system, with the origin in the top left corner of the monitor, and the turtlesim coordinate system, with the origin in the bottom left corner of the turtlesim window. You should also address the difference between you screen resolution and the turtlesim screen resolution (the turtle should follow the relative position of the mouse on your screen, i.e. it should not hit the wall if you did not reach the edge of your screen).
c) Add your node to the track mouse.launch file and expose the screen resolution as ROS parameter using <param> tag. You are not allowed to use hard coded screen resolution within the turtle control.py node

More products