Wishful Coding

Didn't you ever wish your
computer understood you?

NXT model of Twente One Solar Racer

I wrote earlier about the solar panels I bought from eBay, and how I connected them to the NXT. The next logical step was of course to build a robot, so why not start out with a solar racer?

I’m Dutch, so I started to look at the cars of the 2 Dutch competitors for the World Solar Challenge, the universities of Twente and Delft. Delft has won for several years in a row, but I still decided to go for the Twente car from 2007, called the Twente One.

I had several reasons for choosing the Twente one. Emotional ones, like a team member that gave a presentation about the car at my old school. Technical ones, like that the powered wheel is not also the steering one. But maybe the most interesting reason is that they have a tilting solar panel, for which they won the innovation price in 2007.

With my LEGO model of the Twente One, I tried to add all the same features as the original model, including:

  • Direct drive on the rear wheel, although the NXT motors are in fact geared down
  • Double wishbone suspension on the front wheels
  • Trailing beam suspension on the rear wheel
  • Tilting solar panels

Winter probably isn’t the best time to try to build a solar racer, but I still made a video of it driving around.

Besides of course the solar panels, this model also requires these motorcycle wheels and 4 springs of the strong variety. I had to buy these myself as well, totally worth it IMO.

I did not include building instructions for the solar panel, as they are easy to make and yours might be different. You could also just use a piece of cardboard instead(but that would be cheating). The panel connects to 3 pivot points at the top of the car.

Download building instructions

Explorer robot without sensors

Usually the first robot you make when you get the NXT is the wheelbase with a bumper, you know, make it run into a wall, turn back and repeat.

To really get my point about saving sensors across, I made a robot like that without any sensors.

It works by turning the motors in regulated mode(constant speed, varying power) and measuring the actual power applied. If the robot runs into a wall, the firmware will apply extra power to the motors to keep them turning. With some tweaking, you can even detect which wheel hit the wall.

The commented code:

// define 2 variables for containing the actual speed
dseg segment
  aaspeed byte
  caspeed byte
dseg ends

thread main
Start:
  // turn the motors on, regulated
  OnFwdReg(OUT_AC, 50, OUT_REGMODE_SPEED)
  // wait for the robot to accelerate
  // it will apply full power here
  wait 1000
Forever:
  // get the actual power used
  getout aaspeed OUT_A ActualSpeedField
  getout caspeed OUT_C ActualSpeedField

  // print the power to the screen
  NumOut(0, LCD_LINE1, aaspeed)
  NumOut(0, LCD_LINE2, caspeed)

  // if one of the motors uses more than 75 power
  // jump to either LResistance or RResistance
  brcmp GT LResistance aaspeed 75
  brcmp GT RResistance caspeed 75

  // repeat forever
  jmp Forever

LResistance:
  // reverse, turn right, jump to start
  OnRevReg(OUT_AC, 50, OUT_REGMODE_SPEED)
  wait 2000
  OnFwdReg(OUT_A, 50, OUT_REGMODE_SPEED)
  wait 500
  jmp Start

RResistance:
  // reverse, turn left, jump to start
  OnRevReg(OUT_AC, 50, OUT_REGMODE_SPEED)
  wait 2000
  OnFwdReg(OUT_C, 50, OUT_REGMODE_SPEED)
  wait 500
  jmp Start
endt

Lat/Lon to Meter

Easy, 1 Latitude is the circumference of the earth divided by 360: 111 km

1 Longitude depends on your Latitude, so… copy-paste

math.radians(6378137.0 * math.cos(math.radians(lat)))

Now, I know this all breaks down horribly when you consider large distances or require high precision(it also upsets mathematicians), but I don’t care(much).

All I1 am interested in is, if I stand at 42° Latitude and I walk North 10 meter, about what is my new Latitude?

  1. And probably half the googlers and questioners on Stack Overflow. 

Published on