Skip to main content

Welcome to Geoff Hayward's Weblog

Commenting on Java, JavaFX, Java EE, Joomla, and IoT.

In this post I will describe how you can make a 4 wheel drive robot car that can be controlled by HTTP GET requests. HTTP GET requests are what you use to request webpages. The types of requests will be 'stop', 'forward', 'left', etc..

This post outlines how to make the car itself. You can send HTTP GET request via any web browser using the browser's address bar. Or, you can even make a simple webpage if you like. I will be keen to hear about the controllers you make.

I made the car for the local FabLab Edison and BlueMix Hackathon. During the Hackathon the car's controller I made was with JavaFX and is a voice controller. The voice controller uses BlueMix's Watson voice-to-text service. The car controller I made is outside the scope of this post. But you can see it in action in the video bellow.



To Build the Robot Car You Will Need

Step 1 Build the Car Kit

​The Car Kit will arrive in a bag. The bag contains 4 wheels, 8 wires (4 red and 4 black), 4 motors, the chassis, and the fittings. The instructions that I received were in Chinese (I assume Chinese). I cannot read Chinese, but the diagrams on the instructions were very easy to follow.

Begin by stripping the paper off of the chassis.This took me about 20 minutes to do as it was quite fiddly.

Next attach the motors using the fixings that are provided in the kit. Then attach the wheels to the motor shafts. Attaching the motors did not take very long, there are 2 bolts per motor.

Slide a wheel onto the shaft of each of the motors.

Once the motors are attached, you can solder the wires to the motors (1 black negative wire and 1 red positive wire per motor).

Before fitting the top of the chassis; fit the h-bridges (Step 2). Once the h-bridges are fitted and wired up you can fit the top of the chassis.

Step 2 Attach the H-bridges

The h-bridges are not supplied in the car chassis kit; they have to be purchased separately.

First you will need to wire the 4 motors to the 2 L298N H-bridges, one motor per h-bridge output A & B respectively.

Then for each L298N H-bridges connect one 4 AA battery holder. Connect the positive wire from the battery holder to the 5+ vault h-bridge in. As well as connecting the battery holder's negative wire to the h-bridge's ground you will need a second ground wire. The second ground wire will take a common ground out from the Edison's breakout board.

I found the following video from LessonStudio to be very helpful (this car, we are making, does not use pulse width modulation - leave the jumpers in place):



Step 3 Set up the Edison

First Connect your Edison to your PC. If you have not connected your Edison to a PC before, I recommend watching this 'step-by-step guide to windows' by Carlos Montesionos.



Next connect your Edison to your local WiFi (if you haven't already). The WiFi will let you send commands to the car wireless. SSH into the Edison and run configure_edison --wifi; then follow the prompt. If you get stuck, I can recommend Connecting your Intel Edison board using Wi-Fi by Intel (the Edison's maker).

Next add Node-RED to the Edison. Node-RED will give you the functionality to receive the boundary HTTP GET requests. Node-RED can then take these requests to signal to the h-bridges to drive the motors. In other words Node-RED will manage the car's business logic.

To set-up Node-RED, SSH into the Edison and issues the following commands:

npm install -g --unsafe-perm node-red 
npm install -g --unsafe-perm pm2
npm install node-red-node-intel-gpio 
pm2 start /usr/bin/node-red --node-args="--max-old-space-size=256"
pm2 save
pm2 startup

Step 4 Wire the Edison to the Car

Once you have wired the car's power and h-bridges and set up the Edison, it's time to attach the Edison to the car. The Edison Arduino breakout board comes with legs. I attached the legs so that the breakout board stands over the top of the 4 AA battery holders.

Begin by wiring jumper cables from the Edison Arduino breakout board's digital outs to the h-bridge's ins. There are 2 jumper cables per motor. This means you will need to use 8 digital outputs in total.

Next, from each h-bridge take the common ground and wire it into one of the spare grounds on the Edison Arduino breakout board. The grounds are marked 'GND'. An Edison Arduino breakout board has 3 grounds available.

Connect the 9 volt battery once you have programmed Node-RED. In the meantime, power the Edison Arduino breakout board from the mains. I found the 9 volt battery only lasted 3-4 hours before the Edison could no longer boot.

Step 5 Program Node-RED to Handle the HTTP requests

Begin by navigation to Node-RED. Node-RED has a web browser based user interface. You may find the following address works; if it doesn't work, change 'edison.local' to the IP address. 1880 is Node-RED's default port.

http://edison.local:1880

Next, drag an 'HTTP' input onto the Node-RED canvas. It is important to send an 'HTTP' response back to whatever sent the request (otherwise the request will block the client). Therefore, drag a 'HTTP' output onto the canvas. Join the 'HTTP' input to the 'HTTP' output. Double click the input and set the address to /forwared. Then, using the address bar of your browser, send http://edison.local:1880/forwared. If everything works, you will see { } printed inside your web browser.

Next, drag 2 functions onto the canvas. Name one function 'low' and the other one 'high'. In each function set msg.payload = 0 and msg.payload = 1 respectively (0 being low, 1 being high).

// example high
msg.payload = 1;
return msg;

Next, drag 8 GPIO digital outputs onto the canvas. You will need to work through each GPIO digital output to match up with the motors. For each motor there are 2 GPIO outputs and 2 h-bridge inputs. Once you have each motor GPIO connected, you can send the highs and lows functions respectively.

You will need to repeat these steps until /left, /left, /back, and /stop can be processed by Node-red. Tip, don't try and reuse the high/low funciton blocks add 2 more for each command.

Here is a video of me testing what I had programmed (wired) Node-RED correctly .



Would you like to take a short cut? Just import this Node-RED Edison Car Configuration Node-RED via its import option. The file is a JSON array that I exported from my own configuration (The configuration is mostly as it was when tested in the video above).

Step 6 Have fun

That's it. If you follow the steps closely, you will have created a working HTTP controlled Edison Car. Good luck and I hope you enjoy making it. You can, also, find more fun project to do with the Edison over at Intel's Instructables page.



Read

During this coming Thursday's Edison Hackathon, at the FabLab, I am hoping to control a robot car by voice. In preparation I have made a JavaFX voice controller UI. And I have put together a 4-wheel drive robot car chassis kit.

The voice controller uses the IBM Watson Speech to Text service. Since recording the video below I have tried commands with context such as "turn left", "reverse the car ". This has had better results. Using phrases, I added regex (word matching) to pull out the commanding verb from the phrase. The commands are then sent as HTTP GET request to whatever IP address and port is given. The Edison will be on the car processing the GET requests via WIFI and acting upon them.



The video below is the running 4-wheel drive robot car chassis kit. To get it working I used an Arduino. I will, of course, swap the Arduino for the Edison before Thursday. The motors are powered by battery, I think the Edison will still be powered by mains (but I am going to seek advice on the day).



As you can see I am all set ready for the FabLab Edison Hackathon: very excited.



Read

Last night I went along to the first session of the Edison board class that is being run by the local FabLab. This class will, hopefully, take me from a novice to a maker on the Edison board in six weeks. The class will end on a huge high as the final session is going to be a day's Hackathon. How awesome is that?

In last night's session two very knowledgeable and friendly volunteers, Ian and Simon, talk the class through the features of an Edison Board. They also showed us how to set-up a PC so that it can work with the Edison board.

The session began with an introduction to the features of the Edison board. The Edison boards features include:

  • Dual-core CPU
  • WiFi
  • Bluetooth 4.0
  • 1 GB DDR
  • 4 GB FLASH memory
  • Runs Yocto Linux

Ian and Simon also give us an idea of what the board and its features can do. An idea such as, controlling outside lights using the whereabouts of a connected GPS device.

Next we learnt about expansion boards. We learnt that there are several expansion boards for the Edison, such as the ones made by Sparkfun. And that you can create your own expansion board, if you plan to attach an Edison board to your own product. During this FabLab class we are using the Arduino Edison Kit (expansion board). Here, in the following video, is an overview of the Arduino Edison Kit we are using.



Once Ian and Simon had bought us up-to-speed on the Edison board and the Arduino kit's features they showed us how to connect them up. Just like in the un-boxing and assembly video from Intel (below).



Finally, we set-up the drivers on our laptops so that next week we can start coding and attaching sensors. Our homework, for the week, is to set-up the Edison Eclipse for C/C++ IDE, set-up the Arduino IDE, and to set-up the Intel XDK IDE.

Sadly, I don't think I am going to get to use Java with the Edison board for the time being. However, I can make do with C/C++ and or JavaScript. I think the idea behind installing the three IDEs is to let us try out the different ways to code for an Edison board.

If you are interested in how the class is going keep an eye out on this blog because, I am planning to add an update post after each of sessions.


While looking for the other two video's I found the 'step-by-step guide to windows' by Carlos Montesionos to be very good. So I thought I would add it to the end of this post.



Tags: EdisonFabLab

Read

Mailing List

Responsive Media

With the ResponsiveMedia plugin for Joomla it is easy to add 3rd party content from YouTube, Vimeo, and Instagram right in to any Joomla! article.

ResponsiveMedia