Society of Robots - Robot Forum
Software => Software => Topic started by: wootwootman on March 29, 2010, 09:02:10 PM
-
hi, i had previously posted here about my first project ( http://www.societyofrobots.com/robotforum/index.php?topic=10710.msg81557#msg81557 (http://www.societyofrobots.com/robotforum/index.php?topic=10710.msg81557#msg81557) ) and was wondering if someone can point me in the direction of finding out how to directly control two servos using a standard ps/2 mouse. nothing that requires it running through a pc, I'd like to have the mouse directly connected to my board (which by the way is an arduino duemilanove). I know the connections would work out something like this http://www.arduino.cc/playground/ComponentLib/Ps2mouse (http://www.arduino.cc/playground/ComponentLib/Ps2mouse) but i dont know how the programming would go.
In short: how do i translate a mouse's x,y coordinates into servo positions?
-
That link includes the code. The mouse basically reports velocity changes, so scale that to suit the servo.
-
the first download right? which file is it and do i use it? and does it output position or "velocity"?
-
If you think about it, how does a mouse know its position? Does it have a high accuracy GPS chip inside?
-
no.....theres a little ball that moves around. the x y movements are picked up and sent through the wire, but im not sure how its decoded.
-
Do you try googling "PS2 mouse interface"?
Lots of hits with complete explanations of how a mouse works and how to interface a mouse.
It should be no problem to connect a PS2 mouse to any uController and write code for reading the mouse and using it for control.
-
x y movements
Note that that's velocity, not position.
-
x y movements
Note that that's velocity, not position.
It's relative position.
-
No, to get relative position, you need to integrate velocity over time.
-
i dont have a ucontroller, its an arduino. but that sketch doesnt return mouse values as x y positions? then how do i control the servos?
-
No, to get relative position, you need to integrate velocity over time.
http://www.computer-engineering.org/ps2mouse/ (http://www.computer-engineering.org/ps2mouse/)
-
No, to get relative position, you need to integrate velocity over time.
http://www.computer-engineering.org/ps2mouse/ (http://www.computer-engineering.org/ps2mouse/)
i dont understand any of that............
-
Ah, relative position to the previous reading.
That IS velocity.
Velocity is the derivative of position, which is the change in position over some period of time (between 2 readings).
-
oh its calculus. i recognize it from junior year of high school. so the sketch returns "velocity" and not position? how would i change it?
-
Just add all readings together ("integration"). It will give you the mouse's position, relative to the starting point.
-
you know which sketch im talking about right?
-
Hi,
Ah, relative position to the previous reading.
That IS velocity.
Velocity is the derivative of position, which is the change in position over some period of time (between 2 readings).
No, the mouse only gives number of tics in X and Y direction respectively. The mouse doesn't give any timing information whatsoever. Some mouse driver software add the timing to get a velocity reading for nonlinear mouse speed (often called acceleration in the driver setup).
But, in short, NO, relative position alone is NOT velocity.
-
To get velocity we need delta position and delta time. The mouse only sends delta position because the host knows delta time already.
Anyways, we all know what we are talking about. This is just terminology/interpretation. Let's leave it at that.
-
Nah, Mouse have two incremental encoders, for every axes it has one. So when you move your mouse in x axis it only gives you impulse per encoder gradation (depends on mouse resolution). Than OS calculates that movement with "absolute - on screen" position. So you will not have either position or velocity but only interrupt that position has been changed. You will need to measure time between impulses to get velocity and integrate those values to get relative position.
-
Hi,
Anyways, we all know what we are talking about. This is just terminology/interpretation. Let's leave it at that.
Interpretation doesn't cover mixing up reality ;) and you didn't seem to keen on letting it fly a while ago? (http://www.societyofrobots.com/robotforum/index.php?topic=10773.msg81873#msg81873 (http://www.societyofrobots.com/robotforum/index.php?topic=10773.msg81873#msg81873)) ::)
-
When the mouse is not changing position, value returned is always 0.
If you move the mouse some distance, then stop, value returned will be some value for some time, then 0 when you stop it.
If you move the mouse at a constant velocity, value returned will be constant non-zero.
If you move the mouse at a constant acceleration, value returned will be linear.
All those behaviours match that of velocity.
If it smells like, feels like, and looks like velocity... I'm gonna call it velocity.
-
Hi,
If you move the mouse at a constant velocity, value returned will be constant non-zero.
You really need to read up on how a mouse communicates.
There is nothing constant about it, it's polled packets.
That's how, when the OS is too busy to read the mouse, it may suddenly "jump", when it gets around to reading a larger accumulated X/Y set.
All those behaviours match that of velocity.
If it smells like, feels like, and looks like velocity... I'm gonna call it velocity.
A bicycle have similar behaviours of a motorcycle if you look at it as superficial as that, but I still know the difference ;)
And however you call the world ain't gonna change it the least bit... It's just making it harder to do cyberfish comms when you disagree with the world at large ;D
-
Ah, I was under the assumption that people would poll it at constant intervals, in which case it would be velocity.
-
so if i hooked it up, and used some random mouse sketch, moved the mouse forward along the mouse axis would it return y+1 ? and if i pulled it back y-1? or would it be 1,2,3,4,5,6,7.....?
-
If you move it at a constant speed in a constant direction and read it at a constant interval, you'll get a constant. eg. 3,3,3,3,3,3,3
-
what if i had something like
pseudocode:
servo1.write("formerXval"+"returnedXval")
servo2.write("formerYval"+"returnedYval")
of course a negative x or y would be subtracted. can something like this be done?
-
That would depend on what you want it to do.
-
i want to use a mouse to control a turret like contraption with two servos
actually, i think i may just use a ps2 controller. i just read that theyre arduino compatible
-
Then that will work.