Wishful Coding

Didn't you ever wish your
computer understood you?

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

Saving sensors with structural limits

When building a robot with some sort of back-and-forth motion, such as a steering car or a robotic arm, you commonly see touch sensors at the end or center to easily move to that point.

However, the NXT motors have built-in rotation sensors, so with a bit more fiddling, you can get rid of most touch sensors in your system by using the structural limits of the model.

The basic idea is that you move the motor slowly forwards until it doesn’t go any further, record the tacho count, rotate backwards slowly until it stops, record the tacho count. Now you know the center point(the average of the two), and you can move to any point within the limits real quick.

In NXT-G this can very easily be done using the PID block by HiTechnic, but it does not give you the endpoints, which you can notice in the video.

In NXC there is a more powerful absolute position regulation, implemented at firmware level. Flexible, fast, precise, awesome.

NXT on solar power

Just as I was thinking about what it would take to make a mars rover with the NXT, I found the dSolar panels from Dexter Industries. How cool is that, a mars rover that actually runs on solar cells!

However, $100 seems a bit expensive for such a nice-to-have feature. Looking around on eBay revealed you can get more power for half the money, only it doesn’t come in a LEGO friendly package.

I bought them anyway, and documented the customizations. Soldering iron required!

So basically I connected the panels in parallel with a few plugs from an old computer. The whole thing is connects to the NXT via 2 fake batteries made of hot glue cartridges. To prove it really works:

I can’t wait to make a robot with these.