Using a USB mouse as a free position sensor

조회 수: 6 (최근 30일)
Pouya Jamali
Pouya Jamali 2017년 1월 22일
댓글: Pouya Jamali 2017년 1월 23일
Hi,
I'm trying to use a usb mouse as a position sensor in my mobile robot. The robot should be able to move freely in 2D space on a smooth surface appropriate for the optical sensor of the mouse to sense the motion. I tryied using x=get(0,'pointerlocation') to read the position. It works as I expect until the pointer reaches a corner on the PC's screen and when the robot moves beyond that boundary the position will not be reported correctly. So please advise if you know of a solution.
Is there a way I connect two USB mice to my PC and use one of them as the normal device for operation on the OS and the other as the position sensor of my robot?
  댓글 수: 1
Jan
Jan 2017년 1월 23일
Which OS are you using? Obtaining the mouse positions is not trivial, because the OS tries to impede keyboard tracking.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2017년 1월 23일
You can reset the mouse position to avoid a collision with the border:
Pos = get(groot, 'ScreenSize');
robot = java.awt.Robot;
robot.mouseMove(Pos(3) / 2, Pos(4) / 2);
  댓글 수: 1
Pouya Jamali
Pouya Jamali 2017년 1월 23일
Hi Jan.
Nice solution! The next challenge I face now is how to exploit full precision capacity of the mouse. For example if I have a 1200 dpi mouse and I want it sense 1200 intervals per each inch of movement how should I do that? I need a sensing accuracy of less than 0.05 mm.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 ROS Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by