Log in

View Full Version : CMUCam, Easy C, and Labview


JJMax7
13-02-2006, 18:04
I can't seem to get the camera to track the target through the code. It works fine in Labview, so I get the best image I can and save the config for Easy C. Than in easy C I initialize the camera, start the camera, and than just try to gather feedback to see if its working properly. I was able to get it working once, but now I can't seem to duplicate it. If anyone could give me any insight on something I may be overlooking, I would greatly appreciate it. Or if someone could possible give me a config that they got to work I could try that.

BradAMiller
13-02-2006, 19:21
I can't seem to get the camera to track the target through the code. It works fine in Labview, so I get the best image I can and save the config for Easy C. Than in easy C I initialize the camera, start the camera, and than just try to gather feedback to see if its working properly. I was able to get it working once, but now I can't seem to duplicate it. If anyone could give me any insight on something I may be overlooking, I would greatly appreciate it. Or if someone could possible give me a config that they got to work I could try that.
The default configuration in EasyC should be pretty close. That is any of the "slots" in the table where you don't set values should get you tracking the target.

Chris_Elston
14-02-2006, 00:19
I can't seem to get the camera to track the target through the code. It works fine in Labview, so I get the best image I can and save the config for Easy C. Than in easy C I initialize the camera, start the camera, and than just try to gather feedback to see if its working properly. I was able to get it working once, but now I can't seem to duplicate it. If anyone could give me any insight on something I may be overlooking, I would greatly appreciate it. Or if someone could possible give me a config that they got to work I could try that.


First thing I would do is make sure you can grab a frame, then track the color in the tracking window with Labview. If that looks good, then save your ECC file to EasyC.

Stop Labview, unconnect your RS-232 from your camera, and plug your TTL port back into RC. Make sure you have a FULLY CHARGED backup battery. Not a ¾ charged battery…FULLY CHARGED, 7.2 volts. Not 7.0 volts, not even 7.1 volts…. .lol….

Next, we need to know if your tracking with your ONBOARD camera PWM ports, or if you are planning on connecting your pan and tilt servos to the robot controller PWMs?

If you are using the onboard tracking. Make sure you read the CMU2Manual, place the lens in the upright position, so when you do a frame grab, the image is correct. (Right side up)

Plug the tilt and pan servo directly onto the CMU2 camera board. Refer to the documentation on where they connect. Your tracking might be backwards. If it is, there is a jumper you need to install to reverse the tilt or pan tracking on the camera board. We had to install the TILT jumper. We use an old hard drive MASTER/SLAVE jumper to reverse the direction of the TILT seek function.

Next is initializing your camera, load the ECC file from lab view with this. Then you need to START your camera. Then you need to capture data from your camera. Finally you need to Set Camera to "Tracking" and put a 1 in pan and a 1 in tilt. This will enable the onboard tracking feature.

You'll need to update your capture data with variables to populate and away you go.

We wasn't happy with the onboard tracking, so we borrowed Kevin's camera code to track the color by connecting the pan and tilt servos to the robot controller, rather than using the on-board servo PWMs. This way the update and servo "tracking" is 100% handled by the robot controller, and it's not so jerky, smooth and fast.....If you do this, then make sure you DISABLE the Set Camera tracking from 1 to 0 for both pan and tilt. This will disable or turn of onboard tracking.

JJMax7
14-02-2006, 15:05
Did you convert Kevin's code into Easy C?

If I run the servos for the camera off the RC will the back up battery still need to be fully charged?

I was planning on running the servos off for ease of programming, since I don't have much time to test, but I can try to do it. I don't think I've been running the camera off a full back-up, I'll try that. I had thought that since it worked fine in Labview, and I had given the robot power via the RC and the back-up. I don't have any problem keeping a full back-up battery since we have a few, as well as chargers.

We set-up the camera properly. I made sure of that. I had it running once, so it could be the power problem. But thanks for all the help.

Chris_Elston
14-02-2006, 23:09
Did you convert Kevin's code into Easy C?


Yes, we did convert the "simple" one to EasyC. It works great.
http://www.kevin.org/frc/frc_camera_s.zip




-

JJMax7
15-02-2006, 15:37
I got it tracking so the power was the problem. Now ALL I have to do is integrate it into the code. And get it mounted.

P1h3r1e3d13
28-02-2006, 21:23
Yes, we did convert the "simple" one to EasyC. It works great.
http://www.kevin.org/frc/frc_camera_s.zip
That seems a daunting and very time-consuming task. Congrats on getting it to work.
Would you by chance be willing to share?
Pretty please?:D

Team 562
11-01-2007, 16:17
I am having problems trying to get kevins mp lab code transfered into easy c. If you could be kind enough could you please post how to transfer the code.:confused:

Kingofl337
11-01-2007, 16:35
1.)In easyC PRO Click on the project tab.
2.) Right Click on "C Source Files"
3.) Select Existing .c files
4.) Find the .c file you are looking for
5.) Right Click on "Header Files"
6.) Select Existing .h files
7.) Find the .h file you are looking for
8.) Start calling functions in user code blocks.

In the camera code if you want to drive the servos you may have to
convert pwm01=Value; to SetPWM(1,Value);
Where 1 is the port number and Value is the variable of what the angle should be.

In the Initialize Function call: InitCamera ( 1 ) ; and StartCamera ( ) ;
Any place that polls the camera you need to call CaptureTrackingData ();
You can drag the blocks right into the C code.

Have you tried the 07 demo code we posted that tracks very well.

sparks-1784
13-01-2007, 14:51
can you include a link to the 07 code?

Kingofl337
13-01-2007, 19:15
http://www.intelitekdownloads.com/easyCPRO/easyc_2007_demo.zip

itsme
14-01-2007, 12:14
What is the difference between connecting the servos onboard the camera to connecting the servos to the RC?
And how is it possible to connect onboard?

Bharat Nain
14-01-2007, 16:53
What is the difference between connecting the servos onboard the camera to connecting the servos to the RC?
And how is it possible to connect onboard?
You cannot, not this year atleast. FIRST had onboard pins last year for the camera. This year, the switched boards. You cannot use last years board as it would be considered illegal - it was custom made for FIRST.

hal
16-01-2007, 17:24
You cannot, not this year atleast. FIRST had onboard pins last year for the camera. This year, the switched boards. You cannot use last years board as it would be considered illegal - it was custom made for FIRST.
Does that mean that the EasyC CMUCam code cannot control the camera servo motors when they are connected to the RC? If so, does that mean one must import the MPLAB camera code so that the camera can track the light source?

MattD
16-01-2007, 18:01
Does that mean that the EasyC CMUCam code cannot control the camera servo motors when they are connected to the RC? If so, does that mean one must import the MPLAB camera code so that the camera can track the light source?

Right, as far as I can tell the easyC code depends on having the servos controlled via the camera board and not the RC. However, the 2007 kickoff demo (http://www.intelitekdownloads.com/easyCPRO/easyc_2007_demo.zip) could be a good starting point, as it does have tracking code that controls the servos via the RC.

Since my team has opted to use easyC, we ended up porting Kevin's streamlined tracking code rather than basing from the aforementioned demo code, however. It still needs to be tweaked a bit, but it seems to work fine.

Kingofl337
17-01-2007, 08:41
easyC doesn't use the camera servo ports it uses PWM ports 10 & 11 in the 2007 kickoff code which are defines so you can easily change the port number. We are getting ready to release an update for PRO that fixes a few issues and we will probably remove the servo block from the camera stuff.
I'm also working to add searching to my drive code and dual light targeting. But, Team 40 took apart my kitbot :( so I'm currently without a test bed.
Hopefully we will have a new chassis ready to test on today. :D

Right, as far as I can tell the easyC code depends on having the servos controlled via the camera board and not the RC. However, the 2007 kickoff demo (http://www.intelitekdownloads.com/easyCPRO/easyc_2007_demo.zip) could be a good starting point, as it does have tracking code that controls the servos via the RC.

Since my team has opted to use easyC, we ended up porting Kevin's streamlined tracking code rather than basing from the aforementioned demo code, however. It still needs to be tweaked a bit, but it seems to work fine.

MattD
17-01-2007, 09:33
easyC doesn't use the camera servo ports it uses PWM ports 10 & 11 in the 2007 kickoff code which are defines so you can easily change the port number. We are getting ready to release an update for PRO that fixes a few issues and we will probably remove the servo block from the camera stuff.
I'm also working to add searching to my drive code and dual light targeting. But, Team 40 took apart my kitbot :( so I'm currently without a test bed.
Hopefully we will have a new chassis ready to test on today. :D

Yes, I know that the 2007 kickoff code uses PWM outputs 10 and 11 on the RC to control the servos by default, but I'm talking about the functions built into easyC, like SetServoTracking(). Does that one control the servos via the RC also? If so, how do you set which PWM outputs to use? It seems to me like that was intended for use with the servos connected to the camera.

Kingofl337
17-01-2007, 10:25
The SetServoTracking command is the same as SetPWM but for the camera servos. If you want to have the camera auto target like it would if the servos were plugged into the camera then do this.


void Initialize ( void )
{
InitCamera ( 1 ) ; //Initialize camera for target color
SetServoTracking ( 1 , 1 ) ; // Sets camera servos to autotrack target
StartCamera ( ) ; // You need to restart the camera if you change camera servo settings
}



void OperatorControl ( void )
{
unsigned char ServoPan;
unsigned char ServoTilt;

SetServoTracking ( 1 , 1 ) ; // Sets camera servos to autotrack target
StartCamera ( ) ; // You need to restart the camera if you change camera servo settings

while ( 1 )
{
// Checks the where the camera wants the servos to be pointed.
CaptureTrackingData ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , &ServoPan , &ServoTilt ) ;
SetPWM ( 1 , ServoPan ) ; // Moves the servo for Pan
SetPWM ( 2 , ServoTilt ) ; // Moves the servo for Tilt
}
}

sniggel
24-01-2007, 14:55
our easy c demo 2007 code does not work. are there steps we are missing? Kevin's code works fine. I saw a post about setting the robot to autonomous, but we are using a testbed, not a robot. We do have the servos connedted to pwm 10, 11 so this is not it. Any thing else we need to do?

Kingofl337
24-01-2007, 15:56
Do you have the OI in Autonomous mode?

sniggel
24-01-2007, 16:10
If i read correctly we set the team number to zeros and that would set the oi to autonomous, is there something else we missed. The team number was the only jumpers we changed

Kingofl337
24-01-2007, 16:14
Yes, your team should have a dongle. It plugs into the competiton port and selects between autonomous and operator control. It also allows you to disable the robot.

Here is the unit AndyMark Makes: http://www.andymark.biz/am-0016.html

Setting the team number to zero may work as well, but I've never tested that.

sniggel
24-01-2007, 22:50
is the dongle the only way to get the code working? It looks like it could take some time to get that in, and I saw the alternative is to make one, which I will have our electronics team look at. I thoght I saw somewhere a mention about manually changing jumpers on the Interface unit to get the autonomous to work. Can it be done without the dongle?
thank-you

Kingofl337
25-01-2007, 10:11
They are pretty easy to make the hardest thing to find is a DB15 connector because Radio Shack doesn't normally stock them anymore.

Well you could just copy the block from autonomous to operator control.

sniggel
25-01-2007, 22:52
thankyou were were able to get the autonomous connection up and running
The autonomous code is being called, but since we dont have our motors hooked up nothing is happening. The camera stays at red, which I figure means it finds the light but cant do anything till we get our motors hooked back up. I do have a question, I thought I saw something about needing a graphics emulator for the code to work, now I cant find where I saw that. Do we need to download and emulator somewhere to get the graphics display running correctly?

Kingofl337
25-01-2007, 22:55
No, if you downloaded the code from Http://www.intelitekdownloads.com/easyCPRO

You use the graphics display. Just open the terminal window and check off "Graphics Display"

Also in Sample Programs we have a neat camera test program. That shows you the box of what the camera sees.

K.Porter
07-02-2007, 15:03
When porting Kevin Watson's streamlined code... did you import every file, or only the ones pertaining to the camera?

hal
07-02-2007, 15:55
I've come back to this thread after about 3 weeks, and I think I see something here that I didn't realize before. Are you saying that SetServoTracking can control the camera servos connected to PWM1 and PWM2 and thereby cause the camera to track the green light, just like Kevin's MPLAB code does? If that is do, and I convert the values returned by CaptureTrackingData to degrees, I should be able to control the robot drive motors. Is that correct?

The SetServoTracking command is the same as SetPWM but for the camera servos. If you want to have the camera auto target like it would if the servos were plugged into the camera then do this.


void Initialize ( void )
{
InitCamera ( 1 ) ; //Initialize camera for target color
SetServoTracking ( 1 , 1 ) ; // Sets camera servos to autotrack target
StartCamera ( ) ; // You need to restart the camera if you change camera servo settings
}



void OperatorControl ( void )
{
unsigned char ServoPan;
unsigned char ServoTilt;

SetServoTracking ( 1 , 1 ) ; // Sets camera servos to autotrack target
StartCamera ( ) ; // You need to restart the camera if you change camera servo settings

while ( 1 )
{
// Checks the where the camera wants the servos to be pointed.
CaptureTrackingData ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , &ServoPan , &ServoTilt ) ;
SetPWM ( 1 , ServoPan ) ; // Moves the servo for Pan
SetPWM ( 2 , ServoTilt ) ; // Moves the servo for Tilt
}
}

Kingofl337
07-02-2007, 22:20
The servos just center the camera on the object its tracking they don't drive the robot. So, you can use the servo's to figure out distance and turn angle they don't drive the robot directly.

And yes this will have the servo's autotrack for the camera. You can also look at the code used at kickoff at www.intelitekdownloads.com/easyCPRO