<< return to Pixycam.com

Retrieving the servo position values (angle of rotation)


#1

I’m trying to retrieve the servos’ (pan and tilt) respective rotation angles based on the x and y coordinates of the object detected by the pixy cmucam5. Can anyone please help me out?

By the way, I intend to place this camera on a robot platform (with gripper and omni wheels). Once the x and y coordinates of the “taught object” is identified, the entire platform will align itself in such a way that the entire robot will rotate to the direction of the object and move forward to collect it with the gripper.

As for now, I have managed to get the x and y coordinates of the “targeted object” with respect to the centre of the camera view after running the pan/tilt demo code. However, I still have no idea on how can I retrieve the rotation angle of the pan/tilt servos, which will be used to determine how many rounds should my omni wheels rotate to face the direction of the “targeted object”.

Thanks in advance.


#2

Hello Lim,
Did you mean to start a new topic? Please see

http://cmucam.org/boards/9/topics/5565?r=5590#message-5590

Edward


#3

Hello,
I am wondering about this as well. I read the old post, but I am still looking for some info. I am a mentor on an FRC team, and we are looking into the options with our pixy. We can get the pan/tilt demo running, but am wondering how you reccommend adding the servo angles to the output?

The options as we see it are, I2c directly to our roborio (we are currently running two cameras on it.
Use a raspberry pi and network tables.

If we use I2c, is it possible to get the servo info, if so how?
If we use the raspberry pi, how do we add the servo info to the exported array (tuple?) that is outputted by the pixy software?

We are using Python as that is the language we understand best.
Thank you.
~Mr. R^2
P.S. I realize I have asked similar questions here and on CHief Delphi, but this is specifically regarding the Pixy2 and servos.


#5

Hello,
You can send the servo command positions over i2c. Are you using Pixy2?

Here is the ccc_pantilt code for Arduino:

The pixy.setServos() function sets the pan and tilt servo angles.

And here is the same program for Raspberry Pi:

You can take values in panLoop.m_command, tiltLoop.m_command and put them in a tuple if you like.

Edward


#6

This is exactly what we were looking for. I assume that is probably the same as the following…

pixy.set_servos (Pan_PID_Controller.Command, Tilt_PID_Controller.Command)

From the python library, yes?

We are using the Pixy2.


#7

That is correct – they are the same.

Edward