Embedded and Real-time Systems1 Exercise 0 – Compilation and Deployment Start Eclipse and import (with copy) the project at /afs/ms.mff.cuni.cz/u/k/kitm/BIG/erslabs/example/DummyPlotter to your workspace. The project is written for the nxtOSEK environment (http://lejos-osek.sourceforge.net/), which itself is a compound of an OSEK-style realtime operating system and of the ECRobot library, which provides drivers for the devices of Lego Mindstorms. For reference, you can find the nxtOSEK installation in /afs/ms.mff.cuni.cz/u/k/kitm/BIG/ers-labs/nxtOSEK. The examples are located in the samples_c subdirectory. Inspect the three files of the project. The C-file contains two tasks – one for updating the display, another for controlling the robot. The scheduling parameters for the tasks, along with other specification of the system are in the OIL-file. (OIL-files are standardized by OSEK. You can find the documentation to OIL-files here: http://portal.osek-vdx.org/files/pdf/specs/oil25.pdf.) Build the project using “make all”. The build process compiles the OIL-file to a couple of Clanguage files, then compiles the project files and links them with the ECRobot library and with the operating system. The result is a *_rom.bin file. Upload the .rom file to the NXT-brick. This is done in the following steps: (i) (ii) (iii) (iv) (v) (vi) Switch on the NXT-brick by pressing the orange button. Press the orange button and the left button simultaneously. This should switch off the brick. Switch on the brick again by pressing the orange button. The brick should start this time in the firmware upload mode. Connect it via a USB-cable to the computer and start appflash.sh located in the project folder by typing “sh appflash.sh”. (The file is generated by the build process.) You should get a message “Upload finished”. Switch off the brick using the button below the orange one. Disconnect the USBcable. Start the application in the NXT-brick by pressing the orange button and then by pressing the right button. The application in the robot does not move it, however it senses revolutions of wheels and the value of the touch-sensor and of the light-sensor. All these values are displayed on the LCD panel on the NXT brick. Switch off the robot by pressing the button below the orange one. 1 Inovace tohoto kurzu byla v roce 2011/12 podpořena projektem CZ.2.17/3.1.00/33274 financovaným Evropským sociálním fondem a Magistrátem hl. m. Prahy. Evropský sociální fond Praha a EU: Investujeme do vaší budoucnosti Exercise 1 – Calibrate the Robot Let the head of the robot go to one side long enough to surely reach it. Then move the head to the center and stop there. In order to do this, you have to experimentally determine the length of the left-right axis in terms of the units returned to you by the motor revolution sensor. The data displayed on the LCD panel may help you in this. Calibrate the vertical axis of the head (i.e. lowering and raising the head) in a similar way by raising the head. Then keep it raised. Determine the length of the vertical axis. Exercise 2 – Ensuring Safety Add an emergency feature to your application, which at any point during the application run reacts to pressing the touch sensor by stopping the forward-backward and the left-right motors and by raising the head. The motors are kept shut-down until the application is restarted. Integrate this emergency feature to each of the subsequent exercises. Exercise 3 – Simple Controller Draw a rectangle with the robot. Do it by first calibrating the head, then move the head to the position where you want to start drawing, lower the marker. After drawing the rectangle raise the marker again. Exercise 4 – Simple Fixed-point Arithmetic Draw a circle a circle with the robot. To do so, use the fixed-point arithmetic and the tabulated sin function located at http://d3s.mff.cuni.cz/~bures/ers-files/lectures/sin-table.txt. You will have to implement sin and cos functions by transforming it to evaluation of sin function in its first quadrant (as given by the snippet). Then you will draw the circle by connecting coordinates obtained by evaluating <cos(alpha) * radius ; sin(alpha) * radius> for alpha going in 1-degree steps from 0 to 360. Note that you should use only fixed point arithmetic with integer variables with maximum size of 32 bits. Exercise 5 – The Robotic “Hello World” Example Implement a controller, which follows a line. (You will be provided with a printout of the line for easier recognition by the robot. If you have not received it, ask your lecturer.) The robot has only one light sensor, which means that to follow the line, it has to stay centred at ¼ of the line width. That way it can recognize if it is steering towards the line or away from it. Evropský sociální fond Praha a EU: Investujeme do vaší budoucnosti Since the positioned by moving along the x- and y-axis, you will have to adjust the absolute angle of the head movement to keep the head centred at ¼ of the line width, and use the trigonometric functions from Exercise 4 to translate the absolute angle to relative movement on x- and y-axis. Bonus Team Exercise 6 – Copy Machine Implement two controllers that mutually communicate over Bluetooth. (The Bluetooth communication is provided by ECRobot library. There are a couple of examples in the samples directory.) Use one robot to follow the line and send out coordinates over Bluetooth to the other robot. Make the other robot receive the coordinates and make a plot according to them. Since the Bluetooth stack in the robot does not implement resending, you may have to implement a simple flow-control protocol that would pause the movement of the sender and resend the data if the data sent have not been acknowledged. Preferably team up with your colleague who has also finished and split the implementation work between yourselves. Evropský sociální fond Praha a EU: Investujeme do vaší budoucnosti
© Copyright 2024