User Tools

Site Tools


getting_started:tutorials:hal3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
getting_started:tutorials:hal3 [2017/05/11 10:56] grafgetting_started:tutorials:hal3 [2026/05/13 10:55] (current) ursgraf
Line 1: Line 1:
-====== Reading from a XBox Controller or a Space Navigator ====== +====== Using the HAL with the GPIO Subsystem ====== 
-In the EEROS library you will find a directory with examples. Open a shell in the build directory of your EEROS library and run ''examples/controlsystem/xBoxTest''. +In the EEROS library you will find a directory with examples. For this example see [[https://github.com/eeros-project/eeros-framework/blob/master/examples/hal/HalTest4.cpp|HalTest4.cpp]]
-This examples reads and outputs periodically all 8 buttons and 8 axis of a XBox controllerFurther, the safety system checks for the button 'X' to be pressedThis causes a level change. As soon as the button is released the safety system changes back to the first level. \\ +
-If you connect several such controller you have to check in ''/dev/input/'' for the controller of your choice and adapt the program accordingly+
  
----- +The system either uses real hardware inputs and output or makes use of a simulated gpio device. You need to install the necessary wrapper library for gpio, see [[getting_started:install_wrapper|]].  
-There is a second example demonstrating the use of a space navigator. Open a shell in the build directory of your EEROS library and run ''examples/controlsystem/spaceNavigatorTest''+ 
-This examples reads and outputs periodically the 3 position and 3 rotation axis together with the state of the 2 buttons of a space navigator mouse. Further, the safety system checks for the left button to be pressed. This causes a level changeAs soon as the button is released the safety system changes back to the first level. +When using a simulated gpio device, make sure to load the kernel driver first and then create the device with 
 +<code> 
 +$ sudo modprobe gpio-sim 
 +$ sudo mkdir /sys/kernel/config/gpio-sim/ofagpio  
 +$ sudo mkdir /sys/kernel/config/gpio-sim/ofagpio/bank0 
 +$ echo 32 | sudo tee /sys/kernel/config/gpio-sim/ofagpio/bank0/num_lines 
 +$ echo 1 | sudo tee /sys/kernel/config/gpio-sim/ofagpio/live 
 +</code> 
 + 
 +Make sure that your local user has access to the device file. 
 +<code> 
 +$ sudo chown $USER:$USER /dev/gpiochip0 
 +</code> 
 +Open a shell in the build directory of your EEROS library and run   
 +<code> 
 +$ ./examples/hal/halTest4 -c HalTest4ConfigGpio.json   
 +</code> 
 + 
 +It will start in safety level //slOne// and mirror the digital input channel 1 to output channel 0. You can check this behavior with 
 +<code> 
 +$ echo pull-up | sudo tee /sys/devices/platform/gpio-sim.0/gpiochip0/sim_gpio1/pull 
 +</code> 
 +or 
 +<code> 
 +$ echo pull-down | sudo tee /sys/devices/platform/gpio-sim.0/gpiochip0/sim_gpio1/pull 
 +</code> 
 +while reading the state of channel 0 with 
 +<code> 
 +$ cat /sys/devices/platform/gpio-sim.0/gpiochip0/sim_gpio0/value 
 +</code> 
 + 
 +Next, change the state of channel 16. This is critical input in the safety system and causes a transition to safety level //slTwo// when pulled up 
 +<code> 
 +$ echo pull-up | sudo tee /sys/devices/platform/gpio-sim.0/gpiochip0/sim_gpio16/pull 
 +</code> 
 +To change back to //slOne// change the level back to '0'. 
 +<code> 
 +$ echo pull-down | sudo tee /sys/devices/platform/gpio-sim.0/gpiochip0/sim_gpio16/pull 
 +</code>
getting_started/tutorials/hal3.1494492996.txt.gz · Last modified: by graf