Robotics StackExchange | Archived questions

ros pkg for mouse click?

Is their any ros pkg where i can use all the functionalities of a mouse like right click, scroll, left click and mouse movement? I want this kind of pkg so that can move the camera in similar way, zoom it, and take photo etc.

i'm using ros melodic with windows 10.

Asked by dinesh on 2019-11-13 13:02:26 UTC

Comments

Answers

There is the package teleop_tools that have simple scripts that you can use and adapt for your own application. For you that would be the script mouse_teleop.py. It is using Tkinter to create a GUI where you can record events like the mouse click and publish data accordingly.

Asked by Delb on 2019-11-14 08:08:08 UTC

Comments

I tired than but it is only publishing mouse movements not mouse clicks. when i ran that node i had to first left click mouse button than move the move than only the twist msg was been published.

Asked by dinesh on 2019-11-14 08:53:27 UTC

I'm sorry I'm not sure to have understood your comment.

Yes it is publishing when you click and move, but it's just how the example is made, they just initialize the data when clicking on the window. If you add your publisher (or any call to another function) directly in the function _start (which is bind to the left click) then you can trigger whatever you want. Can you clarify what you want to achieve please ?

Asked by Delb on 2019-11-14 09:11:42 UTC

ok... looks like i need to understand its source code properly then. well its for 2 axix robot which has camera on it end. the axis rotation should be controlled from mouse movement and the shoot, zooming should be done from left and middle buttons of the mouse.

Asked by dinesh on 2019-11-14 10:55:58 UTC

To do that you would need to bind the different mouse button to some functions that would publish on the corresponding topic like this :

self._canvas.bind('<Button-1>', self._start)

This will call the function _start with the left click of the mouse (defined as Button-1). The mouse wheel click is <Button-2>, and the right click is <Button-3>, mouse wheel up is <Button-4> and mouse wheel down is <Button-5>. So you just need to call self._canvas.bind() for each button with their corresponding function.

Asked by Delb on 2019-11-15 05:51:09 UTC

ok. but is it possible to use the rviz windows instead of the windows it creates? Cas i want to use the mouse and keypress while viewing the robot and image window in rviz.

Asked by dinesh on 2019-11-15 06:18:45 UTC

If it's with rviz you should have a look at the visualization_tutorial package, there are examples on how to add plugins for rviz, and even an example for teleoping with the mouse.

Asked by Delb on 2019-11-15 08:48:59 UTC