Équipe AVR - Automatique Vision et Robotique

NXT CESAR

De Équipe AVR - Automatique Vision et Robotique
(Redirigé depuis CESAR-OSEK)
Sauter à la navigation Sauter à la recherche

Presentation

NXT CESAR is a project aiming at porting an open-source generic controller called "CESAR" to the Lego NXT platform using the excellent operating system "NXT OSEK".

Features

  • Toolchain and flashing utilities run 100% on the latest Ubuntu 32 or 64 bits (OO at the time of writing)
  • The controller runs at 100Hz
  • Positions loops are controlled with 3 RST controllers. They were tuned after carefull identification of the NXT motors dynamics. The target reference used for the tuning is of class 2 (no error to a constant acceleration position reference=parabolic reference).
  • The binary of the controller takes around 50Ko, thus fitting into the rather tiny flash memory of the NXT brick.
  • A custom bios has to be used : the standard Lego bios is replaced.
  • The controller can be distantly controlled through Bluetooth communication thanks to a linux program called "xserial". Possible commands (among others) :
    • on/off
    • cal : calibration of the robot
    • goto q1 q2 q3 with q1,2,3 the desired positions. Trapezoidal velocity path is generated.
    • status : displays the current robot status including the current positions
    • batch : reads a batch file with successive position references. The file is editable.
  • Many securities :
    • Sensor error check
    • Lagging error to detect obstacles
    • Power check : to detect low battery

Authors

Installation

Installing the toolchain

The CPU of the NXT brick is an ARM 7 from ATMEL. Below, the step-by-step procedure to install the cross-compilation environment (called toolchain) for this target platform under a standard Ubuntu distribution (tested on 11.10, 32 bits and 64 bits).

  • Install build-essential (sudo apt-get install build-essential)
  • Install texinfo (sudo apt-get install texinfo)
  • Install development versions of libgmp, libmpfr, libppl, cloog-ppl. For details see http://gcc.gnu.org/install/prerequisites.html.
  • Download the script build_arm_toolchain-1.sh.gz
  • Run the script. Have a coffee break.
  • Install wine (sudo apt-get install wine)
  • Download and extract the latest version of NXT-OSEK at http://lejos-osek.sourceforge.net/. Version tested : 2.161.
  • Download sg.tgz
  • Extract the file sg.exe into the directory "toppers_osek/sg"
  • In directory "ecrobot" modify file "tool_gcc.mak" so that "GNUARM_ROOT" points on the directory "gnuarm" of the toolchain you compiled before.
  • Go into directory "samples_c/helloworld".
  • Type "make all" in the shell.
  • You should obtain the following :
Compiling ../../ecrobot/../toppers_osek/kernel/alarm.c to alarm.o
Compiling ../../ecrobot/../toppers_osek/kernel/event.c to event.o
Compiling ../../ecrobot/../toppers_osek/kernel/interrupt.c to interrupt.o
Compiling ../../ecrobot/../toppers_osek/kernel/osctl.c to osctl.o
Compiling ../../ecrobot/../toppers_osek/kernel/resource.c to resource.o
Compiling ../../ecrobot/../toppers_osek/kernel/task.c to task.o
Compiling ../../ecrobot/../toppers_osek/kernel/task_manage.c to task_manage.o
Compiling ../../ecrobot/../toppers_osek/config/at91sam7s-gnu/cpu_config.c to cpu_config.o
Compiling ../../ecrobot/../toppers_osek/config/at91sam7s-gnu/lego_nxt/sys_config.c to sys_config.o
Generating OSEK kernel config files from ./helloworld.oil
Compiling kernel_cfg.c to kernel_cfg.o
Compiling ../../ecrobot/../ecrobot/c/syscalls.c to syscalls.o
Compiling ../../ecrobot/../ecrobot/c/ecrobot_bluetooth.c to ecrobot_bluetooth.o
Compiling ../../ecrobot/../ecrobot/c/ecrobot_base.c to ecrobot_base.o
Compiling ../../ecrobot/../ecrobot/c/ecrobot.c to ecrobot.o
Compiling helloworld.c to helloworld.o
Compiling ../../ecrobot/../toppers_osek/syslib/at91sam7s-gnu/lego_nxt/hw_sys_timer.c to hw_sys_timer.oram
Assembling ../../ecrobot/../lejos_nxj/src/nxtvm/platform/nxt/vectors.s to vectors.o
Assembling ../../ecrobot/../toppers_osek/config/at91sam7s-gnu/debug.S to debug.o
Assembling ../../ecrobot/../toppers_osek/config/at91sam7s-gnu/lego_nxt/sys_support.S to sys_support.o
Assembling ../../ecrobot/../ecrobot/c/nxt_binary_header.s to nxt_binary_header.o
Assembling ../../ecrobot/../ecrobot/c/nxt_entry_point.s to nxt_entry_point.o
Assembling ../../ecrobot/../ecrobot/c/ecrobot_init.s to ecrobot_init.o
Assembling ../../ecrobot/../toppers_osek/config/at91sam7s-gnu/cpu_support.S to cpu_support.oram
Assembling ../../ecrobot/../toppers_osek/config/at91sam7s-gnu/irq.s to irq.oram
Generating binary image file: helloworld_OSEK_rom.bin
Generating binary image file: helloworld_OSEK_ram.bin
Generating binary image file: helloworld_OSEK.rxe

Flashing the NXT brick

  • Install package "scons".
  • Install package "libusb-dev".
  • Download libnxt-bios.tgz.
  • Extract this tarball and go into its root directory.
  • Type "scons".
  • Connect the NXT brick to the PC with the USB cable.
  • Switch on the brick. Push at least for 4s on the reset button (when flipping over the brick, it's the upper left hole). The screen turns blank and the brick starts to make a periodical "clicking" noise.
  • Type "sudo ./biosflash nxt_bios_rom.rfw". This command should replace the standard firmware with an extra-light one.

To revert to the initial NBC/NXC Lego firmware

  • Download libnxt-firm.tgz.
  • Extract tarball and switch to its root directory.
  • Type "scons".
  • Connect the NXT brick to the PC with the USB cable.
  • Switch on the brick. Push at least for 4s on the reset button (when flipping over the brick, it's the upper left hole). The screen turns blank and the brick starts to make a periodical "clicking" noise.
  • Type "sudo ./fwflash lms_arm_nbcnxc_131.rfw". This command installs version 1.31 of the Lego firmware modified for using NBC/NXC. It is available at http://bricxcc.sourceforge.net/lms_arm_nbcnxc.zip.

Installing the download utility

  • Into the root directory of the "libnxt-bios" project, execute command "sudo cp appflash /usr/local/bin" and then "sudo chmod u+s /usr/local/bin/appflash".
  • Switch on the birck. You should see "UPLOAD: READY".
  • Go into the "samples_c/helloworld" directory.
  • Type "appflash helloworld_OSEK_rom.bin".
  • Into the terminal, you should see :
#=========================================================#
#                Application Flash Utility                #
#=========================================================#

File size is 17488 bytes
NXT device in reset mode located and opened.
Uploading an application program to Flash...
  • After download is complete (a progress bar is displayed on the brick during this process), message "UPLOAD: FINISHED" is displayed.
  • Switch off the brick with the small lower button. Wait 1s and switch on again pushing the orange button.
  • You should see the NXT OSEK welcome animation and then a screen where below "===============", the main commands associated with the buttons are reminded.
  • Launch the program by pressing the right arrow button "RUN>".
  • First line displays "OSEK HelloWorld!" followed by various informations.
  • To return to the main menu, press on the left arrow button.
  • To switch off the brick, you can push the lower button.
  • To switch the brick into download mode at the next OFF/ON cycle, simultanely press on the left arrow button and on the orange button for at least 1s. The brick will switch off and after the next power on, it will display "UPLOAD: READY".

Compiling the controller

  • Download the latest archive here.
  • Extract this archive in the "samples_c" directory of NXTOSEK.
  • Go into the archive root directory.
  • Compile the controller by entering "make all". A file named "cesar_rom.bin" has been created.
  • Use the procedure described before to download the controller to the brick : "appflash cesar_rom.bin".

Compiling the console utility

This Linux utility communicates with the controller using Bluetooth. Bluetooth pairing should be performed before.

  • Edit the file "xserial.h" and change "XSERIAL ADRESS" according to the BT address of your NXT brick.
  • Go into the "xbt" directory. Type "make". This will generate a linux program (no cross-compilation) called "xserial". This program can be used to communicate with the controller using Bluetooth.

Note : the pairing procedure has only to be done once using Gnome's standard utility. The pairing password is "1234".

Assembling the robot

Use the pictures below to assemble your robot. I put a very small amount of grease on the joints of the parallelogram to minimize friction.


Testing the robot

Using xserial

"xserial" is a little Linux utility that is used to communicate with the NXT controller. It uses Bluetooth. The most convenient way to use it is in its "monitor" mode. To switch to the "monitor" mode, type in the "xbt" directory the command "xserial mon". If the brick has been correctly associated, the terminal screen should be cleared and a prompt is displayed on the upper left corner. You can type your command here. It is interpreted only after you hit [ENTER]. If the syntax is not correct, an error message is displayed. If the command is understood, it is sent to the robot controller that execute it.

Below, a list of the most common commands :

  • on : switch on the power. The position loops are activated so it not possible to move the robot by hand in this mode.
  • off : switch off the power. The motor torque is servoed to 0. It is normal to feel a little resistance when moving the robot by hand. =
  • cal : calibrate the robot encoders. The robot must be put in a specific position (see below).
  • goto q1 q2 q3 : got to the specified positions where q1, q2, q3 are the joint angular positions. The angles are in radians. Note that the joints limits are the following :
    • q1 : -1.1 ... 0.17
    • q2 : -1.6 ... 1.6
    • q3 : -0.9 ... 0.9
  • cvel v1 v2 v3 : move at constant speeds v1, v2 and v3 (rad/s) joints 1, 2, 3. The velocity is given in fraction of maximum velocity (between 0 and 1).
  • status : displays the current robot status. If an error occurs, the information is displayed. In this case, the controller should be rebooted.

Robot calibration

Before making any motion, you should calibrate the robot. Before running the controller, put the robot in the configuration described in the picture below.

Calibration position


It is important that the bottom of the joint 2 and 3 actuators touch the surface of the table. Also, the end-effector has to be parallel and in contact with the table. Then run the controller, start "xserial mon" in a linux console, wait for the prompt and type :

> on [ENTER]
> cal [ENTER]

After that, the robot is ready to move.

Batch mode

The xserial utility can send a sequence of positions stored in the file "cesar.bat". Each line is constituted by 3 floats coding the angular position to attain. The next position is programmed when the last is attained. Simply edit this file if you want to change the sequence. Warning : the last line should not be empty. If you want to play the sequence, in the "monitor" mode type :

> batch [ENTER]

Repeatability test

<anyweb> http://www.youtube.com/embed/cj_VtWFQTNc </anyweb>