【Elixir】rclexから始めるROS 2 (2021/12/05)

https://qiita.com/advent-calendar/2021/nervesjp

2021/12/05 の記事です。

# はじめに
- [Elixir](https://elixir-lang.org/)を楽しんでいますか :bangbang::bangbang::bangbang:
- この記事は、@takasehideki 先生を中心に取り組まれている[rclex/rclex](https://github.com/rclex/rclex)にコントリビュートしていくべく、まず最初の一歩を踏み出してみました〜　的なノリの記事です
- みなさんも、「れっつじょいなす」

# モチベーション
- [ROS 2](https://docs.ros.org/en/eloquent/index.html)をなんなのかわかっていません
- [ROS 2](https://docs.ros.org/en/eloquent/index.html)を何に使えるのかわかっていません
- [ROS 2](https://docs.ros.org/en/eloquent/index.html)を利用して何かやりたいことがみえているわけではありません
- 私は入り方が[Elixir](https://elixir-lang.org/)からなんです
- [rclex/rclex](https://github.com/rclex/rclex)というのがあるそうな |> それならいっちょやってみるか
- あえて正直にいま時点のお気持ちを包み隠さずに披瀝いたしますと、**とにかくアドベントカレンダーを埋める、ネタをいただけて感謝の気持ち**でいっぱいです
- もっと端的にいうと、記事を書くことが目的です
- 踏み出さないと始まらないのでやるだけやってみます

# [Installing ROS 2 on Ubuntu Linux](https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Binary.html)
- 何はともあれ、[ROS 2](https://docs.ros.org/en/foxy/index.html)をインストールしてみます
- バージョンはいろいろありますして、[rclex/rclex](https://github.com/rclex/rclex)に書いてある`foxy`を選んでみます
- [Installing ROS 2 on Ubuntu Linux](https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Binary.html)して進めばよさそうです
- まずUbuntu 20.04を用意する必要があるわけですが、Azureの[仮想マシン](https://azure.microsoft.com/ja-jp/services/virtual-machines/)を使うことにしました
- だいたい、以下の感じです

| 設定項目 | 値 |
|:-:|:-:|
| コンピュータ名 | ros2 |
| OS  | Ubuntu 20.04  |
| サイズ  | Standard B1s (1 vcpu 数、1 GiB メモリ)  |
| ストレージの種類 | Standard SSD   |

## VMにsshしていろいろやっていく
- ローカルマシンからsshで[仮想マシン](https://azure.microsoft.com/ja-jp/services/virtual-machines/)につなぎます

```
$ ssh -i ~/.ssh/id_rsa azureuser@<VMのIPアドレス>
```

以下、[仮想マシン](https://azure.microsoft.com/ja-jp/services/virtual-machines/)内で作業を進めます

### スワップ領域の作成

- [Ubuntu 20.04にスワップ領域を追加する方法](https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04-ja)

```
azureuser@ros2:~$ sudo fallocate -l 1G /swapfile
azureuser@ros2:~$ sudo chmod 600 /swapfile
azureuser@ros2:~$ sudo mkswap /swapfile
azureuser@ros2:~$ sudo swapon /swapfile
azureuser@ros2:~$ sudo swapon --show
azureuser@ros2:~$ free -m
azureuser@ros2:~$ sudo cp /etc/fstab /etc/fstab.bak
azureuser@ros2:~$ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
```

### [Installing ROS 2 on Ubuntu Linux](https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Binary.html)
- リンク先を参考に**無心**でコマンドを実行していきます
- 余計なことを考える必要はありません
- :coffee: をお供に、気長に取り組みましょう

```
azureuser@ros2:~$ sudo apt update && sudo apt install curl gnupg2 lsb-release
azureuser@ros2:~$ sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key  -o /usr/share/keyrings/ros-archive-keyring.gpg
azureuser@ros2:~$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

azureuser@ros2:~$ wget https://github.com/ros2/ros2/releases/download/release-foxy-20211013/ros2-foxy-20211013-linux-focal-amd64.tar.bz2

azureuser@ros2:~$ mkdir -p ~/ros2_foxy
azureuser@ros2:~$ cd ~/ros2_foxy
azureuser@ros2:~/ros2_foxy$ tar xf ~/ros2-foxy-20211013-linux-focal-amd64.tar.bz2
# ここ結構時間がかかります
```

```
azureuser@ros2:~/ros2_foxy$ sudo apt update
azureuser@ros2:~/ros2_foxy$ sudo apt install -y python3-rosdep
azureuser@ros2:~/ros2_foxy$ sudo rosdep init
azureuser@ros2:~/ros2_foxy$ rosdep update

azureuser@ros2:~/ros2_foxy$ rosdep install --from-paths ~/ros2_foxy/ros2-linux/share --ignore-src -y --skip-keys "cyclonedds fastcdr fastrtps rti-connext-dds-5.3.1 urdfdom_headers"
# ここ結構時間がかかります
```

```
azureuser@ros2:~/ros2_foxy$ sudo apt install -y libpython3-dev python3-pip
azureuser@ros2:~/ros2_foxy$ pip3 install -U argcomplete
```

### 動作確認
- ターミナルを2つ使います

1個目

```
azureuser@ros2:~/ros2_foxy$ . ~/ros2_foxy/ros2-linux/setup.bash
azureuser@ros2:~/ros2_foxy$ ros2 run demo_nodes_cpp talker
[INFO] [1636183632.992403351] [talker]: Publishing: 'Hello World: 1'
[INFO] [1636183633.992364771] [talker]: Publishing: 'Hello World: 2'
[INFO] [1636183634.992373291] [talker]: Publishing: 'Hello World: 3'
...
[INFO] [1636183670.992492904] [talker]: Publishing: 'Hello World: 39'
[INFO] [1636183671.992472986] [talker]: Publishing: 'Hello World: 40'
[INFO] [1636183672.992509068] [talker]: Publishing: 'Hello World: 41'
[INFO] [1636183673.992495650] [talker]: Publishing: 'Hello World: 42'
[INFO] [1636183674.992536432] [talker]: Publishing: 'Hello World: 43'
[INFO] [1636183675.992518214] [talker]: Publishing: 'Hello World: 44'
[INFO] [1636183676.992552309] [talker]: Publishing: 'Hello World: 45'
...
```

2個目

```
azureuser@ros2:~/ros2_foxy$ . ~/ros2_foxy/ros2-linux/setup.bash
azureuser@ros2:~/ros2_foxy$ ros2 run demo_nodes_py listener
[INFO] [1636183673.008444671] [listener]: I heard: [Hello World: 41]
[INFO] [1636183673.993684158] [listener]: I heard: [Hello World: 42]
[INFO] [1636183674.994017942] [listener]: I heard: [Hello World: 43]
[INFO] [1636183675.993909023] [listener]: I heard: [Hello World: 44]
```

:tada::tada::tada:

> You should see the talker saying that it’s Publishing messages and the listener saying I heard those messages. This verifies both the C++ and Python APIs are working properly. Hooray!  

# ErlangとElixirのインストール
- [ROS 2](https://docs.ros.org/en/foxy/index.html)をインストールできました
- いよいよ本題です
- まずは[Elixir](https://elixir-lang.org/)を使えるようにします
- [rclex/rclex](https://github.com/rclex/rclex)に指定されているバージョンをインストールします
    - Elixir 1.11.2-otp-23
    - Erlang/OTP 23.3.1
- https://hexdocs.pm/nerves/installation.html#linux
- [Nerves](https://www.nerves-project.org/)を始めるわけではないので余計なパッケージが含まれているのかもしれませんが、[asdf](https://asdf-vm.com/)でバージョン切り替えができるようにしたいので、[Nerves](https://www.nerves-project.org/)のドキュメントに従います

```
azureuser@ros2:~$ sudo apt install build-essential automake autoconf git squashfs-tools ssh-askpass pkg-config curl

# Nervesのドキュメントには書いていないけど追加しておくと、あとでErlangのインストールでWARNINGがでない
azureuser@ros2:~$ sudo apt install libssl-dev libncurses5-dev default-jdk unixodbc-dev fop xsltproc libxml2-utils

azureuser@ros2:~$ git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0
azureuser@ros2:~$ echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc
azureuser@ros2:~$ echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc
azureuser@ros2:~$ source ~/.bashrc
azureuser@ros2:~$ asdf plugin-add erlang
azureuser@ros2:~$ asdf plugin-add elixir
azureuser@ros2:~$ sudo apt install libwxgtk3.0-gtk3-dev
azureuser@ros2:~$ asdf install erlang 23.3.1
# めっちゃ時間かかります
```

:coffee::coffee::coffee::coffee::coffee:

```
azureuser@ros2:~$ asdf install elixir 1.11.2-otp-23
azureuser@ros2:~$ asdf global erlang 23.3.1
azureuser@ros2:~$ asdf global elixir 1.11.2-otp-23
``` 

# https://github.com/rclex/rclex_connection_tests をRUN
- https://github.com/rclex/rclex_connection_tests/blob/main/README.md に従って進めてみます

```
azureuser@ros2:~$ git clone https://github.com/rclex/rclex
azureuser@ros2:~$ git clone https://github.com/rclex/rclex_connection_tests
azureuser@ros2:~$ cd rclex_connection_tests/
azureuser@ros2:~/rclex_connection_tests$ ./run-all.sh
INFO: building rclcpp node in /home/azureuser/rclex_connection_tests/rclcpp_node
run-rebuild.sh: line 40: colcon: command not found
ERROR: `colcon build` for Rclcpp failed: 127
ERROR: run-rebuild.sh failed.
```

- :sob: 失敗した

https://colcon.readthedocs.io/en/released/user/installation.html

- ここを参考にインストールしてみます

```
azureuser@ros2:~/rclex_connection_tests$ sudo sh -c 'echo "deb [arch=amd64,arm64] http://repo.ros2.org/ubuntu/main `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
azureuser@ros2:~/rclex_connection_tests$ curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
azureuser@ros2:~/rclex_connection_tests$ sudo apt update
azureuser@ros2:~/rclex_connection_tests$ sudo apt install python3-colcon-common-extensions
```

気を取り直して再度実行してみます

```
azureuser@ros2:~/rclex_connection_tests$ ./run-all.sh
```

## 実行結果

```
INFO: building rclcpp node in /home/azureuser/rclex_connection_tests/rclcpp_node
Starting >>> cpp_pubsub
Finished <<< cpp_pubsub [15.5s]                       

Summary: 1 package finished [15.8s]
INFO: building rclcpp node in /home/azureuser/rclex_connection_tests/rclex_node
==> rclex
Could not find Hex, which is needed to build dependency :elixir_make
Shall I install Hex? (if running non-interactively, use "mix local.hex --force") [Yn] y
* creating /home/azureuser/.asdf/installs/elixir/1.11.2-otp-23/.mix/archives/hex-0.21.3
==> rclex_node
Resolving Hex dependencies...
Dependency resolution completed:
New:
  elixir_make 0.6.3
* Getting elixir_make (Hex package)
==> elixir_make
Compiling 1 file (.ex)
Generated elixir_make app
==> rclex
mkdir -p /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/priv
mkdir -p /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj
gcc -c -I/home/azureuser/.asdf/installs/erlang/23.3.1/usr/include -I/home/azureuser/ros2_foxy/ros2-linux/include -g -O2 -Wall -Wextra -Wno-unused-parameter -pedantic -fPIC -DFOXY -o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/total_nif.o src/total_nif.c
gcc -c -I/home/azureuser/.asdf/installs/erlang/23.3.1/usr/include -I/home/azureuser/ros2_foxy/ros2-linux/include -g -O2 -Wall -Wextra -Wno-unused-parameter -pedantic -fPIC -DFOXY -o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/init_nif.o src/init_nif.c
src/init_nif.c: In function ‘nif_rcl_init_options_init’:
src/init_nif.c:52:16: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
   52 |   ERL_NIF_TERM ret;
      |                ^~~
gcc -c -I/home/azureuser/.asdf/installs/erlang/23.3.1/usr/include -I/home/azureuser/ros2_foxy/ros2-linux/include -g -O2 -Wall -Wextra -Wno-unused-parameter -pedantic -fPIC -DFOXY -o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/node_nif.o src/node_nif.c
src/node_nif.c: In function ‘nif_rcl_node_init’:
src/node_nif.c:54:7: warning: variable ‘res’ set but not used [-Wunused-but-set-variable]
   54 |   int res = 0;
      |       ^~~
src/node_nif.c: In function ‘nif_rcl_node_init_without_namespace’:
src/node_nif.c:99:7: warning: variable ‘res’ set but not used [-Wunused-but-set-variable]
   99 |   int res = 0;
      |       ^~~
gcc -c -I/home/azureuser/.asdf/installs/erlang/23.3.1/usr/include -I/home/azureuser/ros2_foxy/ros2-linux/include -g -O2 -Wall -Wextra -Wno-unused-parameter -pedantic -fPIC -DFOXY -o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/publisher_nif.o src/publisher_nif.c
src/publisher_nif.c: In function ‘nif_rcl_publisher_init’:
src/publisher_nif.c:110:7: warning: variable ‘return_value’ set but not used [-Wunused-but-set-variable]
  110 |   int return_value = 0;
      |       ^~~~~~~~~~~~
gcc -c -I/home/azureuser/.asdf/installs/erlang/23.3.1/usr/include -I/home/azureuser/ros2_foxy/ros2-linux/include -g -O2 -Wall -Wextra -Wno-unused-parameter -pedantic -fPIC -DFOXY -o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/subscription_nif.o src/subscription_nif.c
src/subscription_nif.c: In function ‘nif_rcl_subscription_init’:
src/subscription_nif.c:69:7: warning: variable ‘return_value’ set but not used [-Wunused-but-set-variable]
   69 |   int return_value;
      |       ^~~~~~~~~~~~
src/subscription_nif.c: In function ‘nif_rcl_take’:
src/subscription_nif.c:191:16: warning: unused variable ‘ret’ [-Wunused-variable]
  191 |   ERL_NIF_TERM ret,ret_sub,ret_msginfo,ret_sub_alloc;
      |                ^~~
gcc -c -I/home/azureuser/.asdf/installs/erlang/23.3.1/usr/include -I/home/azureuser/ros2_foxy/ros2-linux/include -g -O2 -Wall -Wextra -Wno-unused-parameter -pedantic -fPIC -DFOXY -o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/wait_nif.o src/wait_nif.c
src/wait_nif.c: In function ‘nif_get_sublist_from_waitset’:
src/wait_nif.c:293:64: warning: passing argument 2 of ‘enif_make_resource’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  293 |     ret[i] = enif_make_resource(env,(res_waitset->subscriptions[i]));
      |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
In file included from src/wait_nif.c:6:
/home/azureuser/.asdf/installs/erlang/23.3.1/usr/include/erl_nif_api_funcs.h:113:74: note: expected ‘void *’ but argument is of type ‘const rcl_subscription_t *’ {aka ‘const struct rcl_subscription_t *’}
  113 | ERL_NIF_API_FUNC_DECL(ERL_NIF_TERM,enif_make_resource,(ErlNifEnv*, void* obj));
      |                                                                    ~~~~~~^~~
/home/azureuser/.asdf/installs/erlang/23.3.1/usr/include/erl_nif.h:339:76: note: in definition of macro ‘ERL_NIF_API_FUNC_DECL’
  339 | #  define ERL_NIF_API_FUNC_DECL(RET_TYPE, NAME, ARGS) extern RET_TYPE NAME ARGS
      |                                                                            ^~~~
src/wait_nif.c:282:23: warning: unused variable ‘res_sub’ [-Wunused-variable]
  282 |   rcl_subscription_t* res_sub;
      |                       ^~~~~~~
src/wait_nif.c: In function ‘nif_rcl_wait_set_init’:
src/wait_nif.c:122:3: warning: ignoring return value of ‘rcl_wait_set_init’, declared with attribute warn_unused_result [-Wunused-result]
  122 |   rcl_wait_set_init(res_waitset,number_of_subscriptions,number_of_guard_conditions,number_of_timers,number_of_clients,
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  123 |                     number_of_services,number_of_events,res_context,*res_alloc);
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -c -I/home/azureuser/.asdf/installs/erlang/23.3.1/usr/include -I/home/azureuser/ros2_foxy/ros2-linux/include -g -O2 -Wall -Wextra -Wno-unused-parameter -pedantic -fPIC -DFOXY -o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/graph_nif.o src/graph_nif.c
src/graph_nif.c: In function ‘nif_rcl_get_topic_names_and_types’:
src/graph_nif.c:48:38: warning: comparison with string literal results in unspecified behavior [-Waddress]
   48 |   bool no_demangle = res_no_demangle == "true";
      |                                      ^~
src/graph_nif.c:55:40: warning: passing argument 2 of ‘memset’ makes integer from pointer without a cast [-Wint-conversion]
   55 |   (void)memset(&res_names_and_types[0],NULL,sizeof(rcl_names_and_types_t));
      |                                        ^~~~
      |                                        |
      |                                        void *
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/sys/types.h:25,
                 from /home/azureuser/.asdf/installs/erlang/23.3.1/usr/include/erl_drv_nif.h:158,
                 from /home/azureuser/.asdf/installs/erlang/23.3.1/usr/include/erl_nif.h:31,
                 from src/graph_nif.c:7:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:1: note: expected ‘int’ but argument is of type ‘void *’
   59 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~
src/graph_nif.c:29:16: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
   29 |   ERL_NIF_TERM ret;
      |                ^~~
src/graph_nif.c:27:7: warning: variable ‘res’ set but not used [-Wunused-but-set-variable]
   27 |   int res;
      |       ^~~
gcc -c -I/home/azureuser/.asdf/installs/erlang/23.3.1/usr/include -I/home/azureuser/ros2_foxy/ros2-linux/include -g -O2 -Wall -Wextra -Wno-unused-parameter -pedantic -fPIC -DFOXY -o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/msg_int16_nif.o src/msg_int16_nif.c
src/msg_int16_nif.c: In function ‘nif_std_msgs__msg__Int16__destroy’:
src/msg_int16_nif.c:80:16: warning: unused variable ‘ret’ [-Wunused-variable]
   80 |   ERL_NIF_TERM ret;
      |                ^~~
src/msg_int16_nif.c: In function ‘nif_getmsgtype_int16’:
src/msg_int16_nif.c:103:12: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  103 |   *res_tmp = ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs,msg,Int16);
      |            ^
src/msg_int16_nif.c: In function ‘nif_readdata_int16’:
src/msg_int16_nif.c:112:16: warning: unused variable ‘ret’ [-Wunused-variable]
  112 |   ERL_NIF_TERM ret;
      |                ^~~
src/msg_int16_nif.c: In function ‘nif_setdata_int16’:
src/msg_int16_nif.c:127:16: warning: unused variable ‘ret’ [-Wunused-variable]
  127 |   ERL_NIF_TERM ret;
      |                ^~~
gcc -c -I/home/azureuser/.asdf/installs/erlang/23.3.1/usr/include -I/home/azureuser/ros2_foxy/ros2-linux/include -g -O2 -Wall -Wextra -Wno-unused-parameter -pedantic -fPIC -DFOXY -o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/msg_string_nif.o src/msg_string_nif.c
src/msg_string_nif.c: In function ‘nif_setdata_string’:
src/msg_string_nif.c:13:26: warning: implicit declaration of function ‘rosidl_runtime_c__String__assign’ [-Wimplicit-function-declaration]
   13 | #define __STRING__ASSIGN rosidl_runtime_c__String__assign
      |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/msg_string_nif.c:78:3: note: in expansion of macro ‘__STRING__ASSIGN’
   78 |   __STRING__ASSIGN(res_msg,data_buf);
      |   ^~~~~~~~~~~~~~~~
src/msg_string_nif.c:65:16: warning: unused variable ‘ret’ [-Wunused-variable]
   65 |   ERL_NIF_TERM ret;
      |                ^~~
gcc -o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/priv/rclex_nifs.so -L/home/azureuser/.asdf/installs/erlang/23.3.1/usr/lib -g -shared /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/total_nif.o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/init_nif.o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/node_nif.o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/publisher_nif.o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/subscription_nif.o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/wait_nif.o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/graph_nif.o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/msg_int16_nif.o /home/azureuser/rclex_connection_tests/rclex_node/_build/dev/lib/rclex/obj/msg_string_nif.o -L/home/azureuser/ros2_foxy/ros2-linux/lib -lrcl -lrmw -lrcutils -lrosidl_runtime_c -lrosidl_typesupport_c -lrosidl_typesupport_introspection_c -lstd_msgs__rosidl_generator_c -lstd_msgs__rosidl_typesupport_c -lfastcdr -lfastrtps -lrmw_fastrtps_cpp
Compiling 13 files (.ex)
warning: unused alias Nifs
  lib/rclex/jobqueue.ex:2

warning: unused alias Nifs
  lib/rclex/jobexecutor.ex:2

warning: variable "id" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/rclex/executor.ex:29: Rclex.Executor.init/1

warning: variable "pub" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/rclex/publisher.ex:66: Rclex.Publisher.terminate/2

warning: variable "do_nothing" does not exist and is being expanded to "do_nothing()", please use parentheses to remove the ambiguity or change the variable name
  lib/rclex/subloop.ex:57: Rclex.SubLoop.each_subscribe/3

warning: variable "call_back" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/rclex/subloop.ex:42: Rclex.SubLoop.each_subscribe/3

warning: variable "state" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/rclex/subloop.ex:91: Rclex.SubLoop.terminate/2

warning: variable "state" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/rclex/subloop.ex:95: Rclex.SubLoop.terminate/2

warning: Rclex.Timer.terminate_timer/2 is undefined or private. Did you mean one of:

      * terminate/2

  lib/rclex.ex:83: Rclex.waiting_input/2

Generated rclex app
==> rclex_node
Compiling 3 files (.ex)
warning: variable "index" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/test/helper/string.ex:6: Test.Helper.String.random_string/1

warning: variable "str" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/test/helper/string.ex:7: Test.Helper.String.random_string/1

Generated rclex_node app
[connext_cmake_module] Warning: The location at which Connext was found when the workspace was built [[/opt/rti.com/rti_connext_dds-5.3.1]] does not point to a valid directory, and the NDDSHOME environment variable has not been set. Support for Connext will not be available.
INFO: running test scrpit: simple_pubsub/rclcpp_to_rclcpp.sh
TESTINFO: wait for creating subscriber
TESTINFO: subscriber has created
[INFO] [1636186505.610333397] [rclcpp]: publishing msg: p4Oqu9iuvz
[INFO] [1636186506.611383144] [rclcpp]: subscribed msg: p4Oqu9iuvz
TESTINFO: published message  : p4Oqu9iuvz
TESTINFO: subscribed message : p4Oqu9iuvz
TESTINFO: result : 0
INFO: simple_pubsub/rclcpp_to_rclcpp.sh passed!

INFO: running test scrpit: simple_pubsub/rclcpp_to_rclex.sh
TESTINFO: wait for creating subscriber
==> rclex
make: Nothing to be done for 'all'.

08:15:08.811 [debug] JobExecutor start

08:15:08.834 [debug] test_sub_node0/testtopic subscriber process start
TESTINFO: subscriber has created
[INFO] [1636186512.147066796] [rclcpp]: publishing msg: cYkrEaSvEW
[rclex] received msg: cYkrEaSvEW
[rclex] subscription has completed

08:15:13.283 [debug] subscriber finished: test_sub_node0/testtopic

08:15:13.285 [debug] finish node: test_sub_node0
TESTINFO: published message  : cYkrEaSvEW
TESTINFO: subscribed message : cYkrEaSvEW
TESTINFO: result : 0
INFO: simple_pubsub/rclcpp_to_rclex.sh passed!

INFO: running test scrpit: simple_pubsub/rclex_to_rclcpp.sh
TESTINFO: wait for creating subscriber
TESTINFO: subscriber has created
==> rclex
make: Nothing to be done for 'all'.
[rclex] publishing message: AVImlvDvy@

08:15:15.671 [debug] JobExecutor start

08:15:16.021 [debug] test_pub_node0/testtopic
[INFO] [1636186516.121891170] [rclcpp]: subscribed msg: AVImlvDvy@

08:15:16.126 [debug] publish ok

08:15:17.090 [debug] publish ok

08:15:18.110 [debug] publish ok

08:15:19.079 [debug] publish ok

08:15:19.130 [debug] publisher finished: test_pub_node0/testtopic

08:15:19.132 [debug] finish node: test_pub_node0
TESTINFO: published message  : AVImlvDvy@
TESTINFO: subscribed message : AVImlvDvy@
TESTINFO: result : 0
INFO: simple_pubsub/rclex_to_rclcpp.sh passed!

INFO: running test scrpit: simple_pubsub/rclex_to_rclex.sh
TESTINFO: wait for creating subscriber
==> rclex
make: Nothing to be done for 'all'.

08:15:20.243 [debug] JobExecutor start

08:15:20.263 [debug] test_sub_node0/testtopic subscriber process start
TESTINFO: subscriber has created
==> rclex
make: Nothing to be done for 'all'.
[rclex] publishing message: yufL@DEbA^

08:15:24.488 [debug] JobExecutor start

08:15:24.506 [debug] test_pub_node0/testtopic

08:15:24.595 [debug] publish ok

08:15:25.564 [debug] publish ok

08:15:26.584 [debug] publish ok

08:15:27.604 [debug] publish ok
[rclex] received msg: yufL@DEbA^
[rclex] subscription has completed

08:15:27.745 [debug] subscriber finished: test_sub_node0/testtopic

08:15:27.747 [debug] finish node: test_sub_node0

08:15:28.573 [debug] publish ok

08:15:29.593 [debug] publish ok

08:15:30.613 [debug] publish ok

08:15:30.646 [debug] publisher finished: test_pub_node0/testtopic

08:15:30.648 [debug] finish node: test_pub_node0
TESTINFO: published message  : yufL@DEbA^
TESTINFO: subscribed message : yufL@DEbA^
TESTINFO: result : 0
INFO: simple_pubsub/rclex_to_rclex.sh passed!

INFO: Complete all tests
INFO: number of passed tests: 4 / 4
INFO: All Tests passed.
```

<font color="purple">$\huge{All　Tests　passed.}$</font>

**やったね:tada::tada::tada:**
なんだかさっぱりわかっていませんが、とにかく**イゴきました**[^1] :rocket::rocket::rocket: 

[^1]: 「動きました」の意。おそらく、西日本の表現、たぶん。[NervesJP](https://nerves-jp.connpass.com/)ではおなじみ。

# Wrapping up :qiitan::lgtm::xmas-tree::santa::santa_tone1::santa_tone2::santa_tone3::santa_tone4::santa_tone5::lgtm::xmas-tree::qiitan:
- [Elixir](https://elixir-lang.org/)とIoTの要素は入っているとおもいますし、Erlangのインストールで[Nerves](https://www.nerves-project.org/)のドキュメントを参照していますので、[#NervesJP](https://qiita.com/advent-calendar/2021/nervesjp)アドベントカレンダーの参加資格は満たしているでしょう
- これから、somethingをやっていきますというお気持ちを表明して筆を置きます


## [NervesJP](https://nerves-jp.connpass.com/)

最後に[NervesJP](https://nerves-jp.connpass.com/)の紹介です。

https://nerves-jp.connpass.com/

れっつじょいなす(Let's join us) :bangbang::bangbang::bangbang:
:point_down::point_down_tone1::point_down_tone2::point_down_tone3::point_down_tone4::point_down_tone5: 
[NervesJP Slackへの参加URL](https://join.slack.com/t/nerves-jp/shared_invite/enQtNzc0NTM1OTA5MzQ1LTg5NTAyYThiYzRlNDRmNDIwM2ZlZTJiZDc1MmE5NTFjYzA5OTE4ZTM5OWQxODFhZjY1NWJmZTc4NThkMjQ1Yjk)
:point_up::point_up_tone1::point_up_tone2::point_up_tone3::point_up_tone4::point_up_tone5: 


![https___qiita-user-contents.imgix.net_https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F240349%2F5ef22bb9-f357-778c-1bff-b018cce54948.png_ixlib=rb-1.2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/131808/447253f9-3060-8bb7-7132-7754ef4aead5.png)