3.3 Robot Car - Makeblock mBot
Makeblock - mBot
1. Requirements
The CPSs (Cyber Physical Systems) of this class should be small and moveable robots. The possibility to recognize changes on the ground and obstacles in front of them should be given in the standard version. Furthermore, it should be possible to easily extend the functionality of the robots by adding additional equipment. The CPSs should belong to the moveable and the online group.
2. Actor
In the OMiROB environment there is one Makeblock mBot available as CPS of this class. Original mBots are are small cars with two bigger wheels in the back and one mini caster wheel in the front. For each of the big wheels an individual motor is available, so that they can be controlled separately. The standard version of the car possesses a Me Ultrasonic Sensor and a Me Line Follower sensor. The first allows measuring the distance to obstacles in front of it and the second is available to sense if the car stands on a dark or a light surface. Because there are two sensor units on the Me Line Follower, they can also recognise if it stands on the edge of different undergrounds. A detailed description for the original mBot can be found from the link below.
Two kinds of battery sources for the car are possible. There can either be used 4 AA batteries or a LiPo battery pack. For testing purpose, rechargeable batteries were used, but it was noticeable that common Duracell batteries enabled a more stable usage of the car.
The cars can be controlled by using an external device (laptop, tablet, mobile phone), which will be connected to the CPS over a USB-cable or via Bluetooth. In the OMiLAB environment there exists a REST interface for a Raspberry Pi, which can be used to connect to the car and allows the user to call different functions. The given functions can control the motors of the wheels, generate a tone, activate the LED matrix and control a stepper motor. The prepared functions for the sensors can read the values of an ultrasonic or a line follower sensor for instance, in the standard version of the mBot, two motors for the big wheels, an ultrasonic and a line follower sensor are mounted. But additional equipment is available within the OMiLAB laboratory. For example, Raspberry cameras, temperature, humiture and various other sensors can be added. For using these, two empty ports are available on the standard version of the car.
To further enhance the communication capabilities of the car, an extension by means of a Raspberry Pi can be used. The single-board computers are stored in blue LEGO© boxes, which can be mounted onto the controller unit of the mBot. On the Raspberry Pi, a REST service is implemented, which is callable over the Internet. The interface offers different functionalities of the car to a user, currently reachable inside the physical laboratory network. A Raspberry Pi camera is also connected to the Raspberry Pi and faces the front of the car. This allows receiving a live stream for controlling the movements of the car over the Internet. The single-board computer is connected to the standard controller of the mBot over a USB cable.
The main addresses of the REST service offered by the Raspberry Pi is reachable within the local OMiLAB network and follows the structure: [http://
/config
- /getPort: This GET request gives back the used USB ports of the Raspberry Pi. This includes also the USB port where the mBot board is connected.
- /getAvailablePorts: This GET request gives back all available ports.
- /setUSPort: This POST request sets a new value for the ultrasonic distance sensor. The new port value as integer must be included as parameter.
- /getUSPort: This request gives back the set port value for the ultrasonic distance sensor.
- /setLFPort: This POST request sets a new value for the line follower sensor. The new port value as integer must be included as parameter.
- /getLFPort: This request gives back the set port value for the line follower sensor.
- /getmBotType: This GET request gives back the mBot type. As there is the original mBot car and other devices, like the Ranger available from Makeblock. CLASSIC means that the device is an mBot car.
- /getMbotConfiguration: This GET request gives back the current configuration as string.
- /status: This GET request delivers a status message as text.
/operation_matrixled
- /drawString: This GET request offers the possibility to draw a string on the LED matrix. this is done by adding a string parameter that should be printed on the matrix.
- /clearScreen: This GET request is the opposite of /drawstring and deletes the text on the LED matrix.
/operation
- /moveBackward: This GET operation allows to add the parameters speed and secs (seconds) as integer. The car then moves back for the given time.
- /honk: This GET request tells the car to make a sound with the built in sound sensor.
- /playTone: This GET request requires the parameters hertz and millisecs (milliseconds) as integer and plays a tone based on the inserted values.
- /emergencyTone: This GET request outputs a predefined emergency tone, like the common SOS.
- /light: This GET request tells the car to output a light on the built in light sensors of the mBot board. Therefore, the required parameters are the ledid, red, green, blue and secs (seconds) all values as integer. The RGB color system can be used to define the color output. The secs defined the duration and the ledid makes sure, which of lights should be used.
- /moveForward: This GET operation allows to add the parameters speed and secs (seconds) as integer. The car then moves straight forward for the given time.
- /turnLeft: This GET operation allows to add the parameters speed and secs (seconds) as integer. The car then turns left for the given time by using only one of the two motors.
- /turnRight: This GET operation allows to add the parameters speed and secs (seconds) as integer. The car then turns right for the given time by using only one of the two motors.
/linefollowing_operation
- /turnLeft: This GET request requires a speed as integer and then it turns left until both line following sensor parts can see a black surface.
- /jumpGap: This GET request requires a speed and drives straight until both line following sensor parts reach a black surface.
- /moveStraight: This GET request requires a speed and follows a black line on the surface until both line following sensor parts reach a white surface.
- /turnRight: This GET request requires a speed as integer and then it turns right until both line following sensor parts can see a black surface.
/obstacle_operation
- /turnLeft: This GET request requires two parameters. A speed given as an integer and a minDistance (minimum distance) provided as float. The mBot turns left with a certain distance and stops when there is an obstacle within the minDistance value.
- /moveStraight: This GET request requires two parameters. A speed given as an integer and a minDistance (minimum distance) provided as float. The mBot drives straight with a certain distance and stops when there is an obstacle within the minDistance value.
- /turnRight: This GET request requires two parameters. A speed given as an integer and a minDistance (minimum distance) provided as float. The mBot turns right with a certain distance and stops when there is an obstacle within the minDistance value.
/sensor
- /readUSSensor: This GET request gives back the current value for the distance sensor. A range between 3 and 400 cm can be measured. Outside this range, 400 will be returned.
- /readLFSensor: This GET request gives back the current value for the line follower sensor. Values from 0 to 3 are possible. If both sensor parts measure a dark surface, 0 is returned. Vice versa, if both sensor parts are white, 3 is given back. If either the left or the right part is black, 1 or 2 is delivered.
- /readSensor: This GET request can be used to read one specific sensor value by inserting the string sensorIdentifier as parameter.
- /readAllSensors: This GET request delivers the values and ports for all available sensors.
The web interface for using the mBot is simple and intuitive to use. It is implemented with Swagger, allows the input of parameters, shows an example output and gives back a HTTP response code after the execution of an operation. As the robot is currently only connected via the Raspberry Pi to the local OMiLAB network and a moveable router, the laptop must be connected to the same alternative as the car for using the operations. Furthermore, a nice user interface allows playing around and getting familiar with the mBot: [http://