two color tracking code

I have been trying to program the camera to track the colors since 9 this morning and havent been able to figure it out…i have looked at the sample code but am still having trouble…any help would be appreciated

              ~Fighting Rednecks~

Have you tried running the sample code?
It assumes a gimbal, but it is a good learning experience even if you won’t use it later.

Greg McKaskle

I can’t get the sample code to run…I get a failed to connect to real time target error

Labview or windriver?

The sample code does track so did you not get a successful run? What happened?

Its in labview, the code doesn’t even load, need help please thanks.:frowning:

Does anyone know were i can find the Gimble Control icon in the labview palette

The steps should be open the lvproj file, change the target IP address using the properties dialog to match yours – I think it defaults to 10.0.0.2.

Then open the top VI and it should download. As a smaller step, you can right click on the target and choose to simply connect. If that doesn’t work, start pinging stuff to find which element is unreachable.

Hopefully it loads and runs.

As for a Gimbal control icon in the palette, there is a Gimbal control subVI in that example, but it isn’t in the palette. That subVI is built on top of the servo stuff and some math. It is OK as an example, but really difficult to generalize a gimbal control to put into WPI.

Greg McKaskle

we can get the camera to work but it dosent track the colors…can anyone help us

Hi,

When you say you have gotten the camera to work, to what extent is it working? In the Two Color tracking example, are you able to see the camera view in the Image block on the front panel?

If we know more specifically what you have been able to do, we can recommend the steps that come next to getting the camera tracking part to work.

Good luck!

Evan

Yes…the image comes up in the image block and it locks onto the color but the camera dosent follow it if we move the colors

Are your servos hooked up? Remember, you need to put the jumpers on the two pins next to where you plug the servo PWMs in or they wont get power. You can check if the servos are being powered when the programs running by physically trying to turn them a bit. The servo should resist and correct itself.

we can manually move the servos from the front panel but they wont work when we need them to track

If the know and slider move the servos, the code should move them too. There is a switch on the front panel to change from camera view to servo control.

Do the servos move but aren’t moving correctly? If that is the case, you may have built the gimbal different than the one the SW was written for. Disconnect them one at a time and see if the movement makes sense for either dimension. When you find a dimension that is backwards, you can open the Gimbal control and negate the proportion for that dimension.

If you don’t get it working, please be more detailed. It shouldn’t take this many posts to fix the problem.

Greg McKaskle

This may sound stupid, but have you tried flipping the colors?

I ran the 2-color tracking code and you select your friendly color, and then when you test it at the camera you flip it because it wants to track the “enemy” color.

Yes it is a bit confusing at first to wonder why it didn’t track the color we selected because it’s not specifically stated that it will only track the “enemy color.” Then again maybe I was just having an off day :stuck_out_tongue:

I’ve been working with our students on the two color servo tracking example in Labview.

One thing we seem to be stuck on is the “Friend Color” enum on the block diagram and front panel. We can’t seem to add more entries to it, or modify it in anyway.

What our goal really is is to replace the “Friend Color” enum with a GetAlliance.VI and based on that send the appropriate “friend color” value on.

This should be really simple, but we can’t seem to figure out what data being sent by the enum “friend color” is, so we don’t know what to replace it with.

Any help would be greatly appreciated.
Thanks

I believe what you are trying to do is to convert from one enumerated type (red, blue, invalid) to another (pink over green, green over pink). I don’t have all the code in front of me, so I could have the order wrong.

Anyway, the easiest thing to do is to compare the first to a known quantity and set the second such as – if alliance is red use pink over green.

I have no idea what alliance will use what target, this is just an example.

To do this in LV, right click on the Get Alliance output and create a constant. Set the constant to red. Drop an equals from the function palette and wire up.
This produces a Boolean output. Next I’d drop a Select function which takes a Boolean and returns one of two possible values. Drag the Friend Colors control and to your diagram to create a constant, copy-drag another using the ctl key, and set them to the two choices. Wire one to the top and the other to the bottom.

By the way, enums are really good for documenting, but LV will automatically convert most numbers, so if you happen to use 0 and 1 as your constants, that works too but is way harder to read.

Greg McKaskle

i thinks it becuase the focus of the camera … move the focus while the camera is working