Author Topic: ERP'S Blackfin_Axon.c(most recent?) question  (Read 2201 times)

0 Members and 1 Guest are viewing this topic.

Offline thx123Topic starter

  • Jr. Member
  • **
  • Posts: 33
  • Helpful? 0
ERP'S Blackfin_Axon.c(most recent?) question
« on: November 15, 2011, 11:02:13 PM »
Hello,

Hoping Admin might have some input on this being the code is from the ERP..


I have been in the process of porting over this code for a while now to a different processor for my robot and I am trying to figure out some issues I am having with the pan/tilt tracking with the Blackfin camera. I have the Blackfin camera mounted on a pan/tilt assembly and it uses two Hitec HS425 servos. The camera works great when it comes to tracking an object using the pan servo(x-axis), in fact better than I expected. Unfortunately the tilt part does not work so well.

If I have the blackfin camera track an object along the y axis(up/down),  it's almost as if the servo power wires were reversed if you will. If the object being tracked comes into view from the bottom, the camera will move upwards and away from the object, kinda like avoiding the object. I am not sure what the servo setting limits are on the axon (On the setup I use servos can go from position 500(far left) to 2500(far right), with 1500 being center. Part of the code I have been looking at is this:

//moves camera to center on target: low numbers are top left, high are bottom right
//accepts: confidence (min # of pixels to track)
//higher damping ratio numbers reduce cam oscillation, but also slows it down
void Blackfin_HeadTrack(int confidence, int damping_ratio)
   {
   //large numbers allows cam to rotate further, but increases oscillation
   int x_multiplier=19;
   int y_multiplier=23;

   //horizontal 730 is middle
   //vertical 990 straight
   //40 is 1/2 of x resolution
   //32 is 1/2 of y resolution
//track location of camera for robot body rotation, accounts for camera range
   cam_X_location=800 - (40*x_multiplier) + X_old*x_multiplier;
   cam_Y_location=990 - (32*y_multiplier) + Y_old*y_multiplier;


When I started working on this part, I assumed that the 800 for cam_X was the center for that servo, and 990 was for the cam_Y servo. So I set it to match my setup which is 1500 for x and 1500 for y, the x axis part worked okay, however it would not go fully to the left, but did go fully to the right. Changing the value to anything under 1000, x axis will go fully to the left and the right.

Like I mentioned above the y axis part does not work as expected, I tried changing the y_multiplier as well as the damping_ratio with no positive effect. Everything else I have ported over works great, is there something I am missing from this code?

The file that has the Blackfin_axon.c is from Axon Source Code v1.11 (Oct 20th, 2009)

I would appreciate any ideas.

Thank You
 

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #1 on: November 16, 2011, 10:29:17 AM »
That's very very old code . . . it sounds like the camera is upside down when you described the Y issue . . .

It's just a guess here, but change this line:
cam_Y_location=990 - (32*y_multiplier) + Y_old*y_multiplier;
to this:
cam_Y_location=990 + (32*y_multiplier) + Y_old*y_multiplier;

If that doesn't work, scan the code for things that would have wrongly inverted the Y axis. Maybe you accidentally added something when porting the code.

I used HS-311 servos, so they're likely to not work the same as the HS-425's. Likely just the center value and the range needs to be tweaked. I've found some servos respond with signals from 0.5ms to 2.5ms, while others are just 1ms to 2ms.

Offline thx123Topic starter

  • Jr. Member
  • **
  • Posts: 33
  • Helpful? 0
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #2 on: November 16, 2011, 11:58:53 AM »
Hi!

I was hoping you would see this...

Okay, I made changes like you mentioned, but the servo just tilts all the way up and doesn't move, I'm wondering if there's the possbility that the firmware on the blackfin is newer than the one you are running?
I am going through the code to see if there's something else that would change the Y axis, I even flipped the values for y_top and y_bottom which didn't work either.

Is there newer code somewhere I can take a look at as far as the blackfin camera goes?

Thank you


That's very very old code . . . it sounds like the camera is upside down when you described the Y issue . . .

It's just a guess here, but change this line:
cam_Y_location=990 - (32*y_multiplier) + Y_old*y_multiplier;
to this:
cam_Y_location=990 + (32*y_multiplier) + Y_old*y_multiplier;

If that doesn't work, scan the code for things that would have wrongly inverted the Y axis. Maybe you accidentally added something when porting the code.

I used HS-311 servos, so they're likely to not work the same as the HS-425's. Likely just the center value and the range needs to be tweaked. I've found some servos respond with signals from 0.5ms to 2.5ms, while others are just 1ms to 2ms.

Offline thx123Topic starter

  • Jr. Member
  • **
  • Posts: 33
  • Helpful? 0
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #3 on: November 16, 2011, 12:16:48 PM »
I just wanted to add something I just tested and worked for the y axis, but not the x axis

I flipped the image on the blackfin using the 'y' command, the y axis is now working fine, but the x axis obviously doesn't work with this setting.


Offline thx123Topic starter

  • Jr. Member
  • **
  • Posts: 33
  • Helpful? 0
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #4 on: November 16, 2011, 07:46:39 PM »
I just wanted to post an update, I ended up flipping the y-axis servo over to resolve the issue I was having, and now I have both pan and tilt working together tracking an object, now to fine tune some settings...

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #5 on: November 16, 2011, 09:17:54 PM »
I ended up flipping the y-axis servo over to resolve the issue I was having, and now I have both pan and tilt working together tracking an object
yea, I knew something like this was the problem :P

Offline thx123Topic starter

  • Jr. Member
  • **
  • Posts: 33
  • Helpful? 0
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #6 on: November 17, 2011, 02:28:30 PM »
I just found it odd simply because I have my pan/tilt servos mounted in the exact same orientation as you do on your ERP, I have been cleaning up my code and found a few other bugs which I fixed, however I am still trying to figure out one of the problems I am still having with this section of code:

//track location of camera for robot body rotation, accounts for camera range
   cam_X_location=800 - (40*x_multiplier) + X_old*x_multiplier;
   

as before my x servo center is at 1500, so I changed the above to 1500
             cam_X_location=1500 - (40*x_multiplier) + X_old*x_multiplier;

It works, however the x servo no longer goes all the way to the left, but goes all the way to the right

debugging my code I see that it will not send a servo position lower than around 1200, just odd

any ideas?

Thanks again

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #7 on: November 17, 2011, 08:38:24 PM »
It works, however the x servo no longer goes all the way to the left, but goes all the way to the right

debugging my code I see that it will not send a servo position lower than around 1200, just odd
Are you sure you got the camera aligned with the servo center location?

Offline thx123Topic starter

  • Jr. Member
  • **
  • Posts: 33
  • Helpful? 0
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #8 on: November 18, 2011, 08:30:29 AM »
Hello,

I am certain about the  alignment, I am going through my code again and hopefully with fine something else I may have missed.

Thanks again




It works, however the x servo no longer goes all the way to the left, but goes all the way to the right

debugging my code I see that it will not send a servo position lower than around 1200, just odd
Are you sure you got the camera aligned with the servo center location?

Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer ยท Roboticist
    • Index of Oddities
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #9 on: November 18, 2011, 10:36:15 AM »
It can't hurt to post pics of the bot :)
I

Offline thx123Topic starter

  • Jr. Member
  • **
  • Posts: 33
  • Helpful? 0
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #10 on: November 20, 2011, 07:38:39 AM »
@Gertlex - I will be posting pics of my robot, but for now it's just a pan/tilt assy mounted to my test bench(Lynxmotion pan/tilt) with a couple of servos and the BFin mounted to it,

@admin - you mentioned the code was old, is there newer code available or at least were there any changes that might help? I went by the tutorial here: http://www.societyofrobots.com/electronics_blackfin_camera.shtml

Thanks

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #11 on: November 26, 2011, 11:18:59 PM »
I just uploaded the most recent version of code. I verified it compiles properly with v2.08 of WebbotLib, using Project Designer:

http://www.societyofrobots.com/downloads/ERP_code_020110.zip

Offline thx123Topic starter

  • Jr. Member
  • **
  • Posts: 33
  • Helpful? 0
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #12 on: November 27, 2011, 07:59:03 AM »
Thank you for the update.

A few days ago after getting a better understanding of the BlackFin Camera, I decided to try to write my own object tracking code, and I found a few interesting things out while I was doing this.

I am still using 38,400 baud to talk to the BlackFin and also 160x120 resolution. I found that if I enable color segmentation 'g1' on the Blackfin, it runs much better when it comes to tracking objects, in my case a red ball. (it ends up blocking out everything else except the set color blob you want to track)

Just taking a quick look at your code, it looks like you increased the resolution to 320x240 and also the baudrate to 115,200. I was just wondering if these increases has made things work better for your ERP?

Thanks again

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #13 on: November 27, 2011, 09:17:26 AM »
I found that if I enable color segmentation 'g1' on the Blackfin, it runs much better when it comes to tracking objects, in my case a red ball. (it ends up blocking out everything else except the set color blob you want to track)

Just taking a quick look at your code, it looks like you increased the resolution to 320x240 and also the baudrate to 115,200. I was just wondering if these increases has made things work better for your ERP?
hmmmm, I'll have to try out the g1 thing at some point . . .

The higher resolution lets you see things at a further range (useful if you need that), while the higher baud rate makes transferring data faster (more time for your processor to do other things). Depending on what you're trying to do, it may or may not matter, but I didn't see any negative reason not to do it this way.

Offline thx123Topic starter

  • Jr. Member
  • **
  • Posts: 33
  • Helpful? 0
Re: ERP'S Blackfin_Axon.c(most recent?) question
« Reply #14 on: November 27, 2011, 10:20:12 AM »
I might still increase the baudrate, but for the time being it seems to get the responces pretty quickly. I have to look at the 320x240 resolution thing though, might prove useful

 


data_list