This project is still very much in the proof-of-concept phase. It is a prototype with a lot of rough edges. The keyfob cameras are very temperamental and difficult to mount into standard LEGO dimensions.
Here are some quick facts and figures:
- Chassis is based on the Land Rover chassis made by Sariel. Pendular suspension, four wheel drive, rack-and-pinion steering on front wheels only.
- One NXT controls entire car.
- One dGPS from Dexter Industries to capture current coordinates.
- One PSPNx sensor from Mindsensors to receive commands from a PSP controller.
- One NXTBee sensor from Dexter Industries to transmit telemetry to a base station.
- One PFMate from Mindsensors to control the PF motors.
- Four 808 type 3 cameras ordered from China to capture the images around the car.
- One NXT motor for steering.
- One NXT motor to activate the shutter release mechanism on the cameras.
- Two PF XL motors to drive the front and rear wheels independently.
- One PF batter box, and one PF receiver.
- Control program written in NXC on the NXT using John Hansen’s enhanced 1.31 firmware, and NXC 1.2.1 r4 on Mac OS.
- The chassis can drive over grass carrying the full weight of all the components and batteries. That is one major achievement!
- The dGPS works well when outdoors
- I can record GPS waypoints in KML format.
- The keyfob cameras are securely mounted
- The NXTBee will send telemetry (battery level, GPS coordinates) to a receiver.
Yet to be done
- Obviously there is no live streaming of video or pictures from the car to a receiver base-station. I have a design in mind to achieve this.
- The keyfob cameras are very sensitive to incorrect placement. Aligning the tiny shutter button with a LEGO piece requires a lot of fine tuning. Not every camera fires concurrently. For now I can reliably capture images from the front-facing camera.
- The process to copy the images from the car is manual and not yet automated.
- I don’t have a way to stitch the pictures together into a panorama that you can explore in 3D. I can do a 2D panorama, but again it’s a manual process.
- The car can’t drive itself – yet!
The LEGO Street View Car is controlled manually using a PSPNx sensor to receive commands from any standard PSP controller. The PSPNx sensor has the advantage of being simple to program against and supports both analog joystick input for steering and boolean button presses to activate the camera. Press the triangle button on the PSP controller to capture an image and log the GPS coordinates.
Each time an image is captured the current latitude and longitude are recorded from the dGPS. The NXT creates a KML format file in the flash filesystem which is then uploaded from the NXT to a PC. Opening the KML file in Google Earth shows the path that the car drove, and also has placemarks for every picture you took along the way. Click on the placemark to see the picture.
For each GPS coordinate I create a KML Placemark entry that embeds descriptive HTML code using the CDATA tag. The image link in the HTML refers to the last image captured on disk. The 808 camera starts with the filename EKEN0001.jpg for the first picture captured. The second picture captured is EKEN0002.jpg, and so forth.
The example KML file below provides shows how the photos are related to the GPS coordinates:
<name>LSVC Snapshot 1</name>
<description><![CDATA[<img src=’DCIM/100MEDIA/EKEN0001.jpg’ width=640 height=480> ]]></description>
<coordinates> -6.185952, 53.446190, 0</coordinates>
<name>LSVC Snapshot 2</name>
<description><![CDATA[<img src=’DCIM/100MEDIA/EKEN0002.jpg’ width=640 height=480> ]]></description>
<coordinates> -6.185952, 53.446190, 0</coordinates>
The snippet from the KML file gives you an idea of what each placemark should look like.
Once the car has finished driving press the orange button on the NXT to save the KML file. This writes a <pathstring> entry which records the actual path of the car. A path string is simply a list of coordinates that define a path in Google Earth along the Earth’s surface. For example:
-6.185952, 53.446190, 0
-6.185952, 53.446180, 0
Is a path two coordinates not far from where I live.
From the NXT to Google Earth
How do we get the pictures and KML file from the NXT and into Google Earth? First of all we need to get all the data in one place. The KML file refers to the relative path of each image, so we can package the KML file and the images into a single directory.
An example of the output produced is shown below. In this test case I started indoors in my house and took a few pictures. As you can see the dGPS has trouble getting an accurate reading and so the pictures appear to be scattered around the map. I then drove the car outside and started to capture pictures as I drove. From Snapshot 10 onwards the images become more realistic based on where the car actually is.
You can see sample pictures captured by the car below:
The process flow to use the car is manual at the moment:
- Attach the keyfob cameras to the PC using 4 USB cables
- Delete all of the images on the cameras
- Detach the cameras
- Start the program on the NXT
- Wait for the orange light to illuminate on the dGPS indicating a satellite fix is obtained.
- The NXT display will show the current GPS coordinates.
- Set the PSP controller to manual mode
- Control the forward/reverse direction of driving with the left joystick, turn right/left with the right joystick.
- Press the triangle button to take a picture and record the GPS coordinates
- When done, press the orange button on the NXT.
- Attach the NXT to the PC
- Copy the Path.kml file from the NXT into an empty folder on the PC.
- Attach each of the 4 USB cameras.
- Take a group of 4 pictures across the cameras and merge into a panorama (STILL TO BE SOLVED).
- Store the panorama into the folder containing the Path.kml
- Open the Path.kml file in Google Earth and enjoy!
How does it all work? I used NXC to program the LSVC, building on many available code libraries to control the third-party sensors. The code is pretty straightforward, after all the car does little more than start up and wait for commands from the PSP controller. One task is used to monitor the PSP controller and send commands to the motors, and the main task just runs a busy loop waiting for the orange button to be pressed to close the KML file.
The source files used are:
- lsvc.nxc. This is the main source file that includes all of the other files used. It contains the constants for the sensors and motors, and the main loop. Also includes functions to communicate with the NXTBee to send/receive data.
- logger.nxc. A helper set of functions for recording debug information with timestamps into a text file in the FLASH.
- KMLCommon.nxc. Functions to create and write to the KML file.
- DGPS-driver.nxc. Driver functions for the dGPS adapted from Xander’s original RobotC code.
- PFMate-lib.nxc. The library from Mindsensors to control the PFMate sensor to send commands to the PF motors.
- PSP-Nx-lib.nxc. The library from Mindsensors to read commands from the PSPNx sensor.
Simply copy all of these files into a directory and compile the lsvc.nxc file using the latest NXC compiler.
Below you can see a video of the car in action at the Google Zeitgeist event in London. Martyn Boogarts, a fellow MCP4, was at the event and kindly shot the video as we drove around outside the Grove Hotel in London. I captured some on-board video as the car drove around, giving you an “ankle height” view of the world!
This video shows more details on the design and construction of the car, and you can watch it driving: