Thursday, June 18th, 2015 at 9:31 am - - Hang-glide

Here’s one of those great two-hour go-nowhere flights I keep having in places like Llangollen on the days when people with some actual talent were scoring hundreds of miles.

nowhererawgps

The GPS gives a direction and velocity in degrees along with the position. If we calculate the average velocity observed in each degree of the compass, like so:

degreesums = [ [0, 0.0]  for i in range(360)]
for degree, velocity in gpsvelocities:
    if velocity > 1.5:
        ideg = int(degree + 0.5)
        degreesums[ideg][0] += 1
        degreesums[ideg][1] += v
degreehistogram = [ sumv/max(n,1)  for n, sumv in degreesums ]

… and graph it radially as the set of points

pts = [ (sin(radians(d))*r, cos(radians(d))*r)  for d, r in enumerate(degreehistogram) ]

you get the yellow circle which is offset from the centrepoint origin by the wind speed.
gpsdriftdirection

In this case, the deflection (wind vector) was has an inverse bearing of 322 degrees at 4.7m/s. The radius of the circle is 12.15m/s, which I guess is the average velocity of the hang-glider if you take away the wind.

To fit a circle (in cyan) to a series of points, I rely on scipy.optimize.minimize using the centrepoint as the parameter vector and the minimization function as the standard deviation of the distances of all the points from that parameter vector.
(more…)

Monday, June 15th, 2015 at 6:07 pm - - Weekends

Last weekend Becka got drafted to play in the the massive canoe polo gala on the docks.
canoepolodocks
They didn’t score many points, and the game is quite different to the no-rules murderball we play on Thursday nights in the dark over the winter.

Meanwhile, a great deal of faffing has been going on with this machine.
resincutting

Yesterday I went on a very long bike ride into Wales to check out Penycloddiau East having missed out on numerous flying days so far. I’m just not getting my act in gear. This is an official site. Some folks have been flying at unofficial sites and making people very very angry.

flintbridge
We did at least go over the Flint Bridge

29mph
…and see the 29mph speed limit sign.

xkcdsignreset
…as well as a board outside another heavy industrial establishment that implemented the XKCD sign reset widget.

Tuesday, June 9th, 2015 at 11:09 am - - Hang-glide

I got a bit depressed with my performance when I look at the GPS track and noticed that I’d inexplicably missed out a complete turn when I was flying. This track is going from west to east downwind.
bradwellgps1

With the power of pyclick() I could plot locations on the GPS against a graph of the barometer values, so the positions of the red vertical pointers correspond to the vertical yellow lines on the barometer graph (in red):
bradwelltmps1

So that explains it. The vario stopped climbing (air pressure ceased declining with altitude) briefly, and I flew downwind briefly to pick it up again.

So that’s not so bad then. I need more confidence that I’m doing it right in a thermal, because I can’t tell the difference between doing badly on an easy thermal and doing well on a difficult one.

Here’s the snipped from the flight video with the positions marked.

The a second curve in the graph above, the one in cyan that wiggles up and down, is the graph of air temperature according to a dallas one wire probe that reads every 0.75seconds. My other temperature devices are generating noise, and the infrared wing thermometer got lost when I broke an upright on Wether Fell.

Let’s look at a similar graph from later on in the flight where I did well and got to cloud-base.
bradwellgps2

The temperature graph is here, declining smoothly without any changes in direction with each turn. (The really wiggly line is the airspeed, which I’ve not worked out how to process yet, although I believe there is a correlation between sudden changes in speed and variations in altitude regarding the trade between speed and height.)
bradwelltmps2

So what’s going on here? Am I dropping in and out of the first thermal with every turn, but managing to remain entirely within the updraft on the second?

Or does the sensor box on the left of the base bar enter and exit the shadow of the wing with every turn in the first thermal, and this doesn’t happen when I’m higher up in the shadow of the cloud?

That seems like a better explanation.

Recommendation: Always point a video camera at your experimental sensor instrumentation so you can get to the truth of any interesting effects that it might be picking up. It could be the sunlight, people walking past, a visiting cat, or other devices switching on or off in the vicinity.

Friday, June 5th, 2015 at 3:39 pm - - Machining

This BNO055 absolute orientation sensor is just the thing I’ve been after for logging the hang-glider direction and heading. It combines the compass and accelerometer sensors into a single package with its own co-processor running proprietary sensor fusion software, so I don’t need to get into the business of decoding making sense of this sensor data.

The theory for calculating absolute orientation is as follows.

Absolute orientation is represented by three degrees of freedom: horizontal heading, roll and pitch. At rest (held within a particular orientation), there are two absolute vectors which can be sensed: the gravitational force (downwards) and the earth’s magnetic flux (about 23degrees off the down vector towards the north, if you are in the UK).

Knowing an absolute unit vector relative to your oriented frame constrains two degrees of freedom. Think of this as a fixed pin passing through your object like it’s a beetle on a specimen tray: the bug can only spin its body around the pin. Two such pins could nail down four degrees of freedom, but there’s only three, so the extra information is redundant and can be used to estimate the accuracy of the measurement.

Each of the sensors on the BNO055 device requires calibration, according to the datasheet:

3.10 Though the sensor fusion software runs the calibration algorithm of all the three sensors (accelerometer, gyroscope and magnetometer) in the background to remove the offsets, some preliminary steps had to be ensured for this automatic calibration to take place. The accelerometer and the gyroscope are relatively less susceptible to external disturbances, as a result of which the offset is negligible. Whereas the magnetometer is susceptible to external magnetic field and therefore to ensure proper heading accuracy, the calibration steps described below have to be taken.

I’ve been logging the quaternion heading from this sensor and then trying to relate it to the motions I was making. Unfortunately, sometimes there was a complete sudden reversal of the orientation mid-flow, even though I wasn’t making any sudden motions:
bnocalib

Here’s the log from this moment that occurred at the timestamp=61350

tstamp  qw  qx    qy   qz     mag calibration status
61050 15158 336   41   6208   1
61150 15419 431   103  5522   1
61250 15664 510   164  4774   1
61350 722   234   -654 -16353 2
61450 244   -530  777  16355  2
61550 1460  -929  852  16270  2
61650 2277  -1019 921  16167  2
61750 3023  -1249 1137 16014  2
61850 3509  -1358 1335 15890  2
61950 4023  -1386 1477 15753  2

Funnily enough, for such a complicated packaged system, there are absolutely no configuration settings at all — except for one option known as NDOF_FMC_OFF, which is “the same as NDOF mode, but with the Fast Magnetometer Calibration turned OFF”. (NDOF stands for “9 Degrees of Freedom”, which I guess refers to the fusion of 3 magnetic flux axes, 3 accelerometer axes, 3 gyro axes into a single measurement.)

The fact that you can turn off the so-called “Fast Magnetometer Calibration” mode suggests there is something special about it: ie it might be buggy.

Anyway, I don’t have time to check out what this does otherwise. I’ve wasted enough on this already. I should go look at something else.

Which of course means I’m just putting this off till I have some logged flight data. Which might be complete junk.

Wednesday, June 3rd, 2015 at 12:33 pm - - Machining

This diagram is for reference, made using the 2D constraint editor in OnShape and then annotated with gimp, which I really cannot get along with.

trianglemachineconstraints1

Origin at O with y-axis along Y being the side of the table, because we want to solve this by fixing the job to be machined in the fixed coordinate frame and pretend that the machine and tool are swinging all around it.

The blue lines represent the triangular main frame (with three approximately known lengths of about 745mm), the green lines the arm (with two lengths and an angle). This carries the cutter at point P and its triangle pivots at the movable point A1 due to changes in the length of J1 representing the linear position of the ballscrew.

The entire blue triangular frame pivots around the fixed point A0 due to changes in the length of J0. The absolute offsets on J0 and J1 from their connection to the common vertex are also unknown, which means we have a total of 2+3+3+1=9 dimensions which we can vary in our calculation to calibrate. (That last dimension is the length of the fixed edge between O and A0.)

Given these numbers, the conversion code that is inserted into the controller LinuxCNC is here.

def abanglefromtriangleabc(a, b, c):
    return acos((a*a + b*b - c*c)/(2*a*b)) 

a = 743.5035783400  # sides of mainframe triangle
b = 754.8024952389 
c = 745.4991150306 

d = 697.7062405262  # length of O->A0
e = 695.5193939239  # length A0->"arm" 
f = 583.6487506837  # length A0->P
ah = 0.0764480526      # angle in arm 
tblx = 525.4558306022  # offset in j0 
armx = 396.1544040232  # offset in j1 

ab = abanglefromtriangleabc(a, b, c) 
ac = abanglefromtriangleabc(a, c, b) 

def convertJ0J1toXY(j0, j1):
    tbl = j0 + tblx
    arm = j1 + armx

    aTBL = abanglefromtriangleabc(b, d, tbl)
    aARM = abanglefromtriangleabc(c, e, arm) 
        
    avec = ab - aTBL; 
    pvec = avec + ac - aARM + ah 

    return (0 - a*sin(avec) + f*sin(pvec),  
            d - a*cos(avec) + f*cos(pvec))

The game we’ve been playing for the last few weeks is to probe a perfectly circular disk mounted on the table with a known diameter, read out a series of joint values J0 and J1 from about 60 different positions, write a function that uses the 9 unknowns to project these measurements into cartesian space relative to O and the axis Y and provide a value of how close we are to having the right circle, and then use scipy.optimize.minimize to pick the values which minimizes this geometric constraint.

Unfortunately, this doesn’t seem to constrain it well enough, for we are getting good fitting solutions where the lengths of the main frame triangle are far from 745mm.

So that’s where we are at this week. I think we’re going to sod the calibration for a little while and just machine some stuff anyway, even if it isn’t perfectly right.

Monday, June 1st, 2015 at 11:05 am - - Hang-glide

The word went out on the facebook groups (relayed by email to a refusenik like me) that Bradwell Edge was the place to go instead of the Long Mynd. Got up at 6am, left house at 7:15 with Becka in the car because she wanted to be dropped off at the Stockport Decathlon to replenish the shoe mountain.

I was first on the hill. The wind was strong enough to blow out all the paragliders, like other irritations like midges and farts, so the slope was reserved for just us hangies — or “stiffies” as those para-wafters often call us. I don’t happen to know the derogatory terms used for those big white “sailplane” things that were skimming along the ridge like flying canoes from the gliding club next door.

clippinginbradwell

As usual, I delayed launching because it felt too windy and the first people up had shouted that it was a bit rough. Then, as I stood ready on take-off, there was not enough wind.

“I’m going to go down,” I whinged as I took off and was lifted about 500m by the first big thermal of the day. I was flying with a radio and heard a couple of the pilots above me saying that they were going to take it over the back and downwind.

I wasn’t ready to do this, still without any bearings, so I dived forwards and sped back to ridge for another one later. This put me at the level of the flying canoes, which was fine as long as they didn’t want to kill me. They must have been beginners as these are high performance machines, so I should not be able to get above them.

Weeeee, this is fun, spinning around in tight circles, riding a convective plume skywards.

I never spoke on the radio. All I heard was Gordon Rigg’s cattle-auction style monologue about the heights of each thermal he’d reached:

“I’ve got 4200 feet. Do I hear a 4-up? I’m now at 4600 feet. Going. Going. Cloud. Sold to the man with the tidy beard and brown dark glasses.

hathersage

I had no idea at all where he was. He could have been flying from the Long Mynd with an antenna the size of a king-post, for all I knew. We have got to get an air-to-air universal simultaneous live-tracking system invented soon to put a stop to this.

As usual, I lost the thermal, even though I circled wider and wider to look for it. The peak district moors were all alike. The second time I looked at the town of Hathersage and the apartment block where Becka’s aunt and uncle lived, I had already passed over it downwind and towards the east.

And it was there I finally caught a good one and actually rode it to within kissing distance of the clouds.

“Come to daddy!” I shouted.

And I was finally there. 1550m above sea level.

cloudbasepeaks

Downwind was the city of Sheffield, a great grey wheel of little ant boxes with a crunch of spiky twigs at its centre that were the skyscrapers. It was like a space station.

“Oh dear. I don’t want to be blown onto that,” I said to myself.

I headed cross-wind to the next cloud, prepared for the brutal sink by Gordon’s unending monologue. It felt like riding a 45 degree slope ski-run where you lose a lot of height very quickly, except it wasn’t enjoyable and you couldn’t buy a lift pass.

At this point I realized I had no clue about tactics or strategy. Had I been provided with some air charts and terrain maps unfolded onto a really big desk, my track-log so far, a pencil, node paper, ruler, calculator, a cafetiere of really good coffee and an inch thick chocolate brownie for afters, I might have correctly weighed up my options over the course of the next couple of hours.

tracklogbrad

But I didn’t, and instead I wound up looking out over the infinitely vast expanse of Chesterfield with absolutely no way round, and decked it in a field of fresh stubble, which I was certain was the finest landing field for miles around. Once you get fixated on something like that, there’s no turning back.

I parked by the gate and lay on the ground half out of my harness, gazing at the beautiful wings of my glider, savouring the fact that I had finally lost my UK XC virginity, until I was rudely interrupted by a car driver who had stopped to poke her head over the hedge to say, “Are you all right? Are you hurt?”

“No. Everything’s fine,” I said, standing up, composing myself.

“Okay then.” She got back in her car and sped away. There’s very little public curiosity in hang-gliding these days. It will probably only get popular when some famous celebrity gets into it instead of wasting their time and money on flash cars or extremely boring jetskis and speed boats.

I phoned Becka’s uncle who came and fetched me back to Hathersage. Then Becka and friend showed up after lunch and lent me her bike so I could peddle up to Bradwell Edge to collect the car, return the bike so they could carry on while I drove off the other way to collect my glider from the field.

I would now dearly love to look at the 74Mb of data which this flight has dumped on my SD card, but I better get back to work calibrating the machine tool instead of having any more fun this morning.

Friday, May 29th, 2015 at 3:53 pm - - Hang-glide

Five days of a hang-gliding competition in rainy Yorkshire, and nothing went amazingly right either. Where was that easy XC soaring conditions that we were promised? Even so, the proper champions managed to fly 60, 70, 80kms on days when I got too low and had to land.

windbanktoolow

In this instance, I packed up, carried the glider back up to the top of the hill for a back-breaking two hours of frustration, rigged alone, did a dodgy self-launch into late in the day filthy conditions and only then noticed that the base-bar was sticky. I was bleeding all over it from a slashed flap of skin on my forefinger with no recollection of how it got that way. No one can fault me for lack of effort.

Becka joined me for the last few days, including one where competition was canceled and there was some free-flying. I missed the one chance in a decade to persuade her to take a tandem flight that was available. Bugger.

wethercrowd

Then there was another day of competition, where I spent 3 hours in the air among a wheeling massing gliders, failing the get anywhere, though quite surprised I didn’t hit anything. The crop thinned out towards the end when I was forced to land by the strengthening wind.

haweslanding

And then, on the final day, when the wind was completely off and the clouds were dark and low, three of us club-class competitors realized we had to do at least something, and all came off the end of the hill (seen on the horizon on the right) and bee-lined right across the valley to a field by a road.

Turned out not to be scary at all. Should have done it earlier.

Thursday, May 21st, 2015 at 10:33 pm - - Hang-glide

The question is: Is it be possible to measure the temperature of the air in a thermal from a hang-glider?

A really good fast responsive thermometer that isn’t degraded by noise is probably going to be useful.

I have been entertaining the unconventional notion that one ought to observe the character of the noise before attempting to filter it out — particularly if it appears that all the errors are on one side due to voltage drops as other sensor circuits take readings on their own independent schedules. (No I do not believe there is any way to synchronize every one of them simultaneously.)

adccircuit
(more…)

Friday, May 15th, 2015 at 12:17 pm - - Hang-glide

Last year I discovered interference issues with the barometric sensor, which I solved by stashing the sensor on a separate board with its own microcontroller and power supply and communicating back via an optocoupler in a way no electrical engineer would find acceptable.

Now I have finally got an understanding of the noise visible on my accurate temperature sensing system based on an analog TMP36 wired to a 16 bit analog-to-digital converter.

Those fridge temperature samples were smoothed by filtering for the maximum value across a sample window, owing to the observation that all the errors occurred downwards.

I had thought that this was an artifact of the ADC device where it would tend to get the final bits of the conversion undervalues.

But it’s clearly due to various other sensor devices switching on briefly many times a second, causing a voltage drop as they draw their power, and my ADC detecting these fluctuations rather than any changes in temperature.

The experiment which isolated this effect was a hack to the main loop to make it switch off or on sets of devices every 30 seconds, like so:

void WholeSdOledBle::LoopWhole()
{
  int mstamp = millis(); 
  int icyc = (mstamp/1000/30+5) % 8; 
  if (adctmp36)       FetchADCtmp36(100, 80); 
  if (icyc>=2)  {
    if (jeenodeserial3) FetchJeenodeserial3(); 
    if (consoleserial)  FetchConsoleSerial(); 
    if (BTLEserial)     FetchBLE(); 
    if (gpsdata)        FetchGPS(); 
    if (wr)             FetchWind(); 
    if (lightsensor)    FetchLight(); 
    if (baroreceiver)   FetchBaro(); 
    if (dst)            FetchDallas(); 
  }
  if (icyc>=3) {
    if (irthermometer)  FetchIRtemp(200, 30);
    if (compassdata)    FetchCompass(); 
  }
  if (icyc>=4) 
    if (gyrodata)       FetchGyro(); 
  if (icyc>=5) 
    if (humiditydata)   FetchHumidity(); 
  if (icyc>=6) 
    if (tbarometer)     FetchTBarometer(); 
}

Here is the graph of my temperature readings over part of this window. See how my yellow line of accurate readings (at the precision of 0.003degC) gains a 0.5degC of noise when I switch all the sensors on.

adcnoise

This is going to be of no use if I’m trying to detect the subtle temperature change due to flying through a thermal.

(more…)

Monday, May 11th, 2015 at 11:44 am - - Hang-glide

I picked up on the Chicago Array of Things by this clip at the BBC.

Here’s a screen grab of the circuit as the guy is showing off his hardware kit.

click1

I was struck by the similarity with the kit I’ve been working with and taking on my (frustratingly infrequent) hang-gliding flights.
palvario1

It shouldn’t be a surprise that they look the same. All we’ve done is bought all the cheap mini sensors we can buy and soldered them together onto one board.

The Chicago group make a big thing about the beauty of their hardware box design, which it is. But what do you DOOOO with the data? This is the question I posed to the Barcelona SmartCitizen Sensor Kit whom I saw at the MakerFaire in Newcastle a couple of weeks ago.

The answer was the usual: we put the data on the internet so that anyone can download and do whatever they want with it.

Like WHAT?

And so on.

I have to harangue because I am on constantly on the lookout for techniques and people who are where I’m at with this type of sensor data. There are no adequate tools. I am constantly hacking different trials and plots of the data using bare Python and discovering all sorts of things that are important.

For example, I don’t think these sensors are quite right. The digital compass needs calibration every time you plug it in, and the accelerometer was biased in one of its planes.

And here is the graph of the humidity in RED, windspeed is the horizontal green squiggly line, and barometric pressure is the white line.
humidbarow
The humidity only got to 90%, having started at 70%, which means I only got 2/3rds of the way to cloudbase. Note how as the barometric readings go down (with altitude), humidity is going up, because the air temperature (not displayed) is getting colder and approaching the dewpoint.

The humidity value is waving about all over the place, and then it settles down as soon as I take off (at the vertical yellow line). Then it begins waving around everywhere before I come in to land 50minutes later (the vertical lines are at 5minute intervals).

I don’t know the reason for this. Is it the windspeed? Is it the proximity to the ground?

My experiments on a bicycle have been inconclusive, not least because the vibration of the road tends to shake many of the components loose. And I can’t peddle fast enough.

You can tell immediately that there’s a lot more to getting something useful from these devices than simply taking the digital readings and assuming it’s the truth.

We had this problem in cave surveying when digital compasses and clinos came about, and people made totally buggered up mistakes and wildly out of calibration cockups that they never would have done with a mechanical instrument. Just because it’s an electronic number you tend to want to write it down to two decimal places in degrees. But if you were using the analog compass you might have actually noticed the way it swings when you hold your helmet light or steel karabiner too close enough to it to affect the magnetic field.

We like these digital devices because we don’t need to think. Just put the uncalibrated values on the internet and hope that someone else can do the thinking for you.

I will only know that these sensor folks are on the same page as me when they get desperate and one day nail every single sensor node they own onto the same lamp-post in order to see to what extent they agree at all. And then I’d like to see the existence of some software that is actually able to correlate the measurements between the different devices to account for their variability.

That’s my demand. It’s what I call “Test Driven Development”, except the Tests are lavished on actual real things that matter which you don’t know about (such as the repeatability of these measurements), not on pointlessly obvious-when-they-fail bits of self-contained code. That’s the kind of TDD I won’t truck with when I am lost in a sea of uncertainty as to what is to be done. For months I am having to do the equivalent of programming doodling and sketching of ideas. Not possible to produce any finished artwork design.