Ask Your Question
0

ros pkg for mouse click?

asked 2019-11-13 12:02:26 -0500

dinesh gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-11-14 07:08:08 -0500

Delb gravatar image

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.

edit flag offensive delete link more

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.

dinesh gravatar image dinesh  ( 2019-11-14 07:53:27 -0500 )edit

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 ?

Delb gravatar image Delb  ( 2019-11-14 08:11:42 -0500 )edit

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.

dinesh gravatar image dinesh  ( 2019-11-14 09:55:58 -0500 )edit

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.

Delb gravatar image Delb  ( 2019-11-15 04:51:09 -0500 )edit

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.

dinesh gravatar image dinesh  ( 2019-11-15 05:18:45 -0500 )edit

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.

Delb gravatar image Delb  ( 2019-11-15 07:48:59 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-11-13 12:02:26 -0500

Seen: 208 times

Last updated: Nov 14 '19