Running sample components

In the following example, using GPIO, you can create a component (DigitalIn-RTC, DigitalOut-RTC) that detects the ON/OFF of the switch and light up the LED and understand the use of GPIO which is the feature of Raspberry Pi I will deepen. The source code of the sample component can be downloaded from the following.

  • Sample component source: &ref (RaspberryPi_sample.zip);

(G)GIOP of Raspberry Pi

Raspberry Pi has a GPIO terminal, which allows you to use various external devices.

The pin assignment of the GPIO that is attached to the Raspberry Pi main unit is shown below.

raspberrypi_gpio_pinassign.png
Raspberry Pi GPIO pin assignment

When using GPIO, pay attention to the position of each pin, especially if using 5V terminal, mistake in wiring may damage the Raspberry Pi main unit and SD card, so be careful enough please.

(G)Breadboard wiring example

Create a circuit that lights the LED and a circuit that detects ON/OFF of the switch. If you have a breadboard etc, you can easily build a circuit, but since there are few parts even if it is not, you can easily form a circuit by soldering lead wires etc. Below is a list of necessary parts.

Bill of Material
LED circuit
LED 1piece
Resistance 100Ω(brown black tea gold) - 330Ω(orange orange tea gold)
Lead wire Somewhat
Switch LED circuit
LED 1piece
Resistance 330Ω(Orange Orange Tea) - 1kΩ(Brown Black Red Gold)
Lead wire Somewhat

If there is only one Raspberry Pi, connect the following LED and switch circuit to the same Raspberry Pi. If there are two Raspberry Pi, it may be interesting to install LEDs and switches on each Raspberry Pi.

(G)Wiring example for DigitalIn-RTC

DigitalIn-RTC is a component that outputs the bool value (true/false) input to the data port to the specified GPIO port. In order to observe the output value of the GPIO port, connect the LED and resistor to the Ground pin and GPIO 18 pin and create a circuit as shown below.

gpio_led_circuit.png
LED Connection Circuit

This is the case when creating this circuit with breadboard.

3_rp2.png
Example of LED circuit wiring with breadboard

(G)Wiring example for DigitalOut-RTC

DigitalOut-RTC is a component that outputs the bool value (true/false) input to the GPIO port from the data port. In order to input the value to GPIO, connect a resistor and a switch to Ground, 3.3V Power, GPIO 17 and create a circuit as shown below.

gpio_stiwch_circuit.png
TACT Switch Connection Circuit

This is the case when creating this circuit with breadboard.

3_rp3.png
Example of switching circuit wiring with breadboard

(G)Compiling components

Download the source code to Raspberry Pi from below and compile the DigitalIn-RTC/DigitalOut-RTC component.

(G)Compiling DigitalIn-RTC

 $ unzip RaspberryPi_sample.zip
 $ cd RaspberryPi_sample/DigitalInRPI/
 $ vi CMakeLists.txt

Now rewrite CMakeLists.txt and set it to suppress document generation.

 option(BUILD_DOCUMENTATION "Build the documentation" OFF)
  ↓
 option(BUILD_DOCUMENTATION "Build the documentation" ON)
 
 $ mkdir build
 $ cd build
 $ cmake ..
 -- The C compiler identification is GNU 4.6.3
 -- The CXX compiler identification is GNU 4.6.3
   : Omission
 -- Configuring done
 -- Generating done
 -- Build files have been written to: /home/pi/RaspberryPi_sample/DigitalInRPI/build

If OpenRTM-aist is correctly installed, configure will terminate without problems. If an error occurs due to lack of OpenRTM or coil, please confirm that OpenRTM-aist (C++ version) is correctly installed (dpkg -l |grep openrtm etc.).

 $ make
  : Omission
 Scanning dependencies of target DigitalInComp
 [ 66%] Building CXX object src/CMakeFiles/DigitalInComp.dir/DigitalInComp.cpp.o
 [100%] Building CXX object src/CMakeFiles/DigitalInComp.dir/DigitalIn.cpp.o
 Linking CXX executable DigitalInComp
 [100%] Built target DigitalInComp
 $

The compiled component DigitalInComp is under src.

 $ ls src/
 CMakeFiles  cmake_install.cmake  DigitalInComp  DigitalIn.so  Makefile

(G)Compiling DigitalOut-RTC

Compile like DigitalIn-RTC.

 $ cd RaspberryPi_sample/DigitalOutRPI/
 $ mkdir build
 $ vi CMakeLists.txt

Now rewrite CMakeLists.txt and set it to suppress document generation.

 option(BUILD_DOCUMENTATION "Build the documentation" OFF)
  ↓
 option(BUILD_DOCUMENTATION "Build the documentation" ON)
 
 $ mkdir build
 $ cd build
 $ cmake ..
 -- The C compiler identification is GNU 4.6.3
 -- The CXX compiler identification is GNU 4.6.3
   : Omission
 -- Configuring done
 -- Generating done
 -- Build files have been written to: /home/pi/RaspberryPi_sample/DigitalOutRPI/build
Then make it.

 $ make
 -- OpenRTMConfig.cmake found.
 -- Configrued by configuration mode.
  : Omission
 Scanning dependencies of target DigitalOutComp
 [ 66%] Building CXX object src/CMakeFiles/DigitalOutComp.dir/DigitalOutComp.cpp.o
 [100%] Building CXX object src/CMakeFiles/DigitalOutComp.dir/DigitalOut.cpp.o
 Linking CXX executable DigitalOutComp
 [100%] Built target DigitalOutComp
 $

The compiled component DigitalOutComp is under src.

 $ ls src/
 CMakeFiles  cmake_install.cmake  DigitalOutComp  DigitalOut.so  Makefile

(G)Running components

Once each RTC has been successfully compiled, start up each RTC after launching NameServer.

 $ rtm-naming
 $ sudo  /home/pi/RaspberryPi_sample/DigitalOutRPI/build/src/DigitalOutComp &
 $ sudo  /home/pi/RaspberryPi_sample/DigitalInRPI/build/src/DigitalInComp &

&color(red){Since the sample component uses GPIO, it must be executed with root authority.} &color(red){※サンプルコンポーネントは GPIO を利用するので root 権限で実行する必要があります。}

Launch RTSystemEditor on PC and connect to NameServewr on Raspberry Pi. After placing each RTC, connecting between the ports, activate.

3_rp4.png
Run sample RTC

When each RTC starts normally, the LED turns on/off according to the status of the takt switch.

Download

latest Releases : 2.0.0-RELESE

2.0.0-RELESE Download page

Number of Projects

Choreonoid

Motion editor/Dynamics simulator

OpenHRP3

Dynamics simulator

OpenRTP

Integrated Development Platform

AIST RTC collection

RT-Components collection by AIST

TORK

Tokyo Opensource Robotics Association

DAQ-Middleware

Middleware for DAQ (Data Aquisition) by KEK