How to output the position of the signature in the terminal window when running pixymon

Added by Frank Wang almost 4 years ago

Hi, all,

There is a libpixyusb example that CMUcam5 Pixy has already provides for us, it is hello_pixy, this example running in the terminal window can output the position of the signature like this :

[sig:11 w: 24 h:150 x:292 y:124 ang:-86]

However, I want to output the position of the signature in the terminal window when running PixyMon, do I need to modify the code of the PixyMon application or something else?
Could someone offer me some help?

Thank you,
Frank


Replies (9)

RE: How to output the position of the signature in the terminal window when running pixymon - Added by Scott Robinson almost 4 years ago

Hi Frank,

So you're saying you want both libpixyusb and Pixymon to run at the same time? That might be a bit difficult considering both would need access to the same USB port. If you could get them to communicate and share the port (only one opens the port and shares the data) then it would be possible, but it would also require a lot of changes.

Scott

RE: How to output the position of the signature in the terminal window when running pixymon - Added by G B over 3 years ago

Simple questions, please help:

-How do I receive object information as described above by Frank and how do I find & use this hello_pixy file? All I need is to get Pixy to send me the above object information (via uart, to a Microcontroller) but can't get that (Pixymon set to uart at same baud as controller).

-Do I need a 3v-5v level shifter if my controller's uart receives at 5v?

-Also, when I run default program in Pixymon should Pixymon show above information (x, y ...) of found objects? Both Pixy & Pixymon seem to be working well except for showing me this information anywhere. Why? Signatures S1... seem to be detected well on the video.

-Finaly, is there any description that I can find anywhere for what those files on GitHub do? Or how to use them?

Thanks.

RE: How to output the position of the signature in the terminal window when running pixymon - Added by Scott Robinson over 3 years ago

Hi,

Here is the hello_pixy file we've been referencing. This is a simple example on how to use the libpixyusb library, which gets object information over USB from Pixy.

What is the logic 1/0 cutoff in your UART controller? You might be fine, but it wouldn't hurt to step up the voltage.

Pixymon does not show the (x,y) coordinates of the detected blocks. However, you can get this info directly from Pixy through UART, SPI, etc or libpixyusb.

We don't have a comprehensive description of the files in Github. There are quite a few, so this would take a while. Hopefully it will help by starting with this:

In pixy/src:

  • arduino: The Arduino library and examples
  • hello_pixy: An example project showing how to use libpixyusb
  • libpixyusb: A library for communicating with Pixy over USB
  • libpixyusb_swig: The same library as above, but with a Python wrapper
  • linux: Linux-specific build/configuration info
  • mac: Mac-specific build/configuration/dependencies
  • pixymon: The Pixymon source code
  • windows: Windows-specific build/configuration/dependencies

Hope this helps!

Scott

RE: How to output the position of the signature in the terminal window when running pixymon - Added by G B over 3 years ago

Thanks Scott. My controller is still not receiving anything from pixy.

while pin 4 Tx is directly connected to my Cont. Rx and while this cont. is doing nothing other than reading its buffer that is to be supposedly filled by info from pixy, and while pixy is manually taught a signature, I get nothing. Any ideas?

Wiring, Baud rates, my program, are all ok, and no 3 to 5v shifter required (confirmed by cont. maker). I even tried pixy by itself through a serial to usb converter to my PCs serial terminal, and still got nothing. Could it be faulty? Can I exchange if required?

Also, your Pixy Serial Protocol mentions "2 sync words" while the table there shows one sync word made of byte-0 (0x55) and byte-1 (0xaa), why? Finaly, once able to receive uart info, I believe all objet data sent to my cont. will be in Hex format, and it will be made of packets of 7 words, always starting with the 0xaa55 word, right?

RE: How to output the position of the signature in the terminal window when running pixymon - Added by Scott Robinson over 3 years ago

Hi,

Yes, you can exchange your Pixy if it is defective. Before we go that route I'd like to make sure we're not missing anything on the one you currently have. As for connecting it to your PC, does it work through USB? If it does then I suspect it is a configuration/connection issue with the other comm ports.

Your connections seem to be fine, however. Are you sure you're receiving data correctly on the other end? Are you able to try connecting Pixy to an Arduino to test the communication?

I think the "two sync words" is a typo. It should just be 0xaa55. And yes, you are correct about the rest of the protocol.

Scott

RE: How to output the position of the signature in the terminal window when running pixymon - Added by G B over 3 years ago

Thanks Scott, I was just "lucky" to resolve this issue.

Apparently Pixymon (Default program) and uart do not work together, Exit Pixymon and the data is there.

Very disappointing to have read nowhere about this in the available literature, and had to waste hours on it.

All well now and object data is streaming into my buffer, but I am getting some interruption every 4th or fifth read. For example, while using a delay of 500ms (for observation) between every uart scan, and with a fixed test object and a buffer of size 4 (only interested in 4 bytes) with one uart qualifier, I get for example the expected data 0, 17, 1, 6 about 4 times, then I get -1, -1, -1, -1 wrongly meaning no object (while it is there), then 0, 17, 1, 6 ... again ...etc.

I will work on that myself however if you have any idea as to why this happened, I'll appreciate it.
Also, is there a way to get Pixy to send only X & Y via uart? If this involves modifying firmware, which one is for the default program?

RE: How to output the position of the signature in the terminal window when running pixymon - Added by Scott Robinson over 3 years ago

Hi,

Sorry for your troubles. I'm not sure why you are getting incorrect values every 4th read. Does everything seem to be working normally in Piyxmon? Are you using an Arduino or a different micro?

As for sending just X, Y values, here is where the blob values are placed in to the buffer to send. The method you're looking for is Blobs::getBlock(uint8_t *buf, uint32_t buflen).

Hope this helps!

Scott

RE: How to output the position of the signature in the terminal window when running pixymon - Added by G B over 3 years ago

Thanks Scott, problem solved again. Used another method and it is all fine.

If I was to change the default program, how may I compile & download to Pixy?

Also, looks like Pixy signature detection is upset by shades. Objects are detected well in full sun light but the same object is ignored undetected in shades.

Again, your expert advice might save me time should you have come across this before.

RE: How to output the position of the signature in the terminal window when running pixymon - Added by Scott Robinson over 3 years ago

For now you can use the Keil IDE (project files are in the repo), although we're currently porting gcc to have an open source/free alternative. It should be released soon.

Shadows are tough, thats a big problem with the color detection that we're working on. One idea is to train a few different signatures on different shades of your object to try and cover the full range. Is that an option for you?

Scott

(1-9/9)