PDA

View Full Version : Discussion Rotating the IR-sensor head 45 degrees


skogsvargen
Mar 22, 2009, 03:45 AM
Connected to the Co-pilot, the IR-sensors can be rotated 45 degrees. Has anyone written som code or formulas to get roll and pitch values in this position? If so are you willing to share this?

It shouldn't be that complicated. But i got lost trying to figuring it out.

/Magnus

Buzz_Lightyear
Mar 22, 2009, 10:46 AM
Paparazzi has the code for this already written.

zlite
Mar 22, 2009, 11:14 AM
Connected to the Co-pilot, the IR-sensors can be rotated 45 degrees. Has anyone written som code or formulas to get roll and pitch values in this position? If so are you willing to share this?

It shouldn't be that complicated. But i got lost trying to figuring it out.

/Magnus

Yes, we have that in the 2.1 version of ArduPilot, out in a week or two. I'll post here when the code is ready to share.

skogsvargen
Mar 22, 2009, 07:33 PM
Zlite: Thanks . Looking foreward to it.

Buzz: Thanks. Looked for it in the Paparazzi code for a while but couldn't find it. Its not the most well documented project. Or was i looking at the wrong place?

/Magnus

clolson
Mar 22, 2009, 10:27 PM
Connected to the Co-pilot, the IR-sensors can be rotated 45 degrees. Has anyone written som code or formulas to get roll and pitch values in this position? If so are you willing to share this?

It shouldn't be that complicated. But i got lost trying to figuring it out.

/Magnus

There is probably a fancier way to do this, but for pitch, could you just take the average of the front two sensors versus the average of the rear two sensors ... similar for roll?

Even without the sensor rotated, you probably are going to need to do some experimentation to derive a roll and pitch based on the sensor value differences, so you could apply that same approach with the averages of the sensors.

I've never done this before ... just posting off the top of my head since no one else has offered the correct answer. :-)

zlite
Mar 22, 2009, 10:38 PM
There is probably a fancier way to do this, but for pitch, could you just take the average of the front two sensors versus the average of the rear two sensors ... similar for roll?

You don't have access to the individual sensors, just the delta between them. So you just get an X and a Y value.

Buzz_Lightyear
Mar 23, 2009, 03:19 AM
Buzz: Thanks. Looked for it in the Paparazzi code for a while but couldn't find it. Its not the most well documented project. Or was i looking at the wrong place?
The problem is that it is a very robust project, for multiple hardware configurations. So most likely you just didn't come across it. The flag to tell the software that you have a rotated IRH sensors is "HORIZ_SENSOR_TILTED". grep the code for that and it should point you in the right direction.

small_rcer
Mar 23, 2009, 06:58 AM
You have just pointed out one of the difficulties of working in an international arena. Anyone whose first language is English would think that meant the sensor was tilted instead of being placed horizontally and rotated.

In English a possibly more accurate term would have been 'rotated', instead of 'tilted' for the variable name. If one had been looking for code referring to rotated you would never have thought that 'tilted' was the term you were looking for. The code works. Just not clear in English what the term is being applied to.

Jim H

Buzz_Lightyear
Mar 23, 2009, 12:18 PM
You make a good point. The term tilted always made sense to me, but I understand where you are coming from. I guess the best remedy is just good documentation (we're working on it)

danstah
Mar 23, 2009, 12:54 PM
The documentation is right here http://paparazzi.enac.fr/wiki/Airframe_Configuration#Infrared. The project may not be documented perfectly but given a little inspection its not very hard to find.
Here is the infrared.c (great name eh?) http://cvs.savannah.gnu.org/viewvc/paparazzi3/sw/airborne/infrared.c?revision=1.42&root=paparazzi&view=markup

skogsvargen
Apr 03, 2009, 01:13 PM
Some things just need a good nights sleep. One morning i woke up and just realized how simple it is:

// sensor mounted 45 deg
PitchActual=(a2dConvert10bit(0)+a2dConvert10bit(1) )/2;

// sensor mounted 45 deg
RollActual=(a2dConvert10bit(0)+(1023-a2dConvert10bit(1)))/2;

After a few testflights to tune the PID values its flies like it should.


Thanks!

Magnus

zlite
Apr 03, 2009, 01:34 PM
Some things just need a good nights sleep. One morning i woke up and just realized how simple it is:

// sensor mounted 45 deg
PitchActual=(a2dConvert10bit(0)+a2dConvert10bit(1) )/2;

// sensor mounted 45 deg
RollActual=(a2dConvert10bit(0)+(1023-a2dConvert10bit(1)))/2;

After a few testflights to tune the PID values its flies like it should.


Yes, that's what we implemented in ArduPilot 2.1. To put it more simply:

x = (x+y)/2
y = (-x+y)/2