<< return to Pixycam.com

Looking for guidance in unique setup (C#, EV3)

Hello, I tried to find if my exact question was already posted and I’ve already dug into the source code.
I’m using a unique setup and am a software engineer, so digging through source or rebuilding it is an option, but I dont think its needed.

I have found the key function in the Pixy software that could lead to my desired goals. Before brute forcing my way through and possibly rebuilding the firmware I figured maybe some guidance could save me time.

My setup:

  1. Ev3 w/ PixyCam 2
  2. Controlling EV3 over USB (right now) using C# https://github.com/mvanderelsen/Lego.Ev3.Framework (not pluggingi in the pixy usb connector )
  3. I’ve added a custom class in this framework to deal with the Pixy2 and it actually works using a similar call as the UltraSonicSensor

Remarkably this actually works out of the box by calling the subcode READY_RAW. It seems to return the x-centroid of the largest signatured block. Very awesome and useful, but I want to start trying to get other data. It doesn’t have any other data in the remaining buffer, no matter how many detected signatures or blocks are found. So clearly the default setting is not enough. My knowledge of the subop isnt strong and trying to tweak a few parameters didnt lead to any new return data from this call.

I found the C function lego_getData which seems to be the meat of everything and can see how opcodes are driving the logic, but it does not seem obvious to me how to trigger the ‘c’ code with my current subop technuique. I think i’m close and possibly just need to tweak a few parameters or possibly call an entirely different protocol.

In another post there was a question about which code to use to get certain data from the lego system, but there’s no consolidated listing of these ops other than digging through code. I also feel like im close enough that i just need to figure out how to trigger that right condition where more data comes back than just the x-centroid .

Quick update:

I wasn’t getting any progress just monkeying blindly with variables so I decided to rebuild the firmware and just force it todo what I want for now. Since 1 mode gives me what I need for a few months.

I know this isnt the forum or place for this stuff, I’ve visited the firmware google group, but can’t post until im accepted to join.

I successfully rebuilt, deployed and ran the firmware and got pixymon and my lego EV3 to detect and work with pixycam.

I have an issue im trying to work through where the camera view in pixymon looks very jacked up and I’m trying to work on that now.

IF anyone has any insights on either topic, its appreciated. Otherwise I will push through and hope the Firmware google group accepts me so i can post this :slight_smile:image3

Tagging @edge because I think this is his department!

I’ll see if I can get somebody to approve your join request.

Thanks for your patience!

Cheers,
Jesse

Thanks for the note Jesse :slightly_smiling_face:
This is a wonderful product and the price unreal for what it can do.
Your forums are an amazing source of help!

General Update:
I’m bouncing between each approach as i hit issues and get more understanding of the 2 systems.
Lego wise, I’m learning how to navigate their opCodes and I believe the ‘datasets’ piece is what i need to trigger. Trying to wrap my head around how the visual scripting systems work as I suspect this will unlock what im seeking without having to use modified firmware

Hello,
Nice work getting things working (or close) :slight_smile: Some questions – Are you using Pixy2? Are you using Keil or LPCExpresso toolchain? If you rebuild the firmware without any modifications, do you get image artifacts?

I think you should be approved for the SDK group. (Let me know if you are not.)

Edward

Really appreciate the response! I’ll followup in the group with more details so we can keep it in there for others, but quick I’m using the Pixy2, LPCExp (version called out in the group) with the ‘Code Red’ toolchain. I’ve tried just about all the other toolchains to different degrees of success generating the actual .hex file. Getting it to actually flash and then run lead me to this path. The image above is the result of me compiling the firmware with as few changes as possible just to get it to build and successfully flash.

FWIW pix1 firmware compiled out of the box (although i never ran it), pixy2 had some hurdles like fixing up file includes and case sensitivity with the SPIFI/spifi folder, also the hard dependency on the falcon_drv lib which i chased forever needlessly haha. Also any pixy2 toolchain i managed to get close enough to generate the hex file often failed due to size errors and I often #if 0 a bunch of programs i dont plan to use like Line or Chase. See you in the google group where I’ll provide more details.

Hi Lee_N,
I should say that the LPCExpresso hasn’t been well tested with the Pixy2 source code I don’t think. The Pixy2 used some optimizations for the line detection algorithm that made it difficult to get working in LPCExpresso. I haven’t been able to get a straight answer on this topic, only that “it’s difficult”, so I’m passing this info along… (sorry!)

Edward

Interesting, i actually tried just building everything from commandline initially, when i hit issues I wound up in LPCEx land and now I’m clearly in uncharted territory hah!

I’ll give Keil a shot before my lengthy post to the group. Really appreciate you guys and the tech!

1 Like

Sure thing – let us know how it goes :slight_smile:

Edward

Update on both fronts, complete success! Thanks for reminding me to use Keil, that worked much much more smoothly and had no artifacts, so I was able to work with real data on both sides. I have no need to push on the LCPX side anymore (or ever again).

To my initial issue, how to interface with pixycam using this C# USB interface system, I managed to figure out the appropriate steps for any future Lego owners.

The key goal is to trigger the lego_getData function in pixy’s serial.cpp with the proper flags/params going through the serial channel.

The solution was as easy as simple as I had hoped, just took a while to get there:
Direct Reply Command (maps to mind storms bytecodes)
OP. - pINPUT_DEVICE
SubOP - INPUT_DEVICE_SUBCODE.SETUP

Among other parameters, you must pass a byte array similar to this: [1, 0x50, 1] (different pixy ops expect other parameters, the 0x50 represents the code i wanted for extra data on my detected blob)

1 Like

That’s great news! I must admit that I don’t quite understand what you’re doing. Are you trying to to control the EV3 brick via PC? (Like (I think) the Scratch environment does?)

Edward