micro-ROS / micro_ros_setup

Support macros for building micro-ROS-based firmware.
Apache License 2.0
365 stars 133 forks source link

microros agent build stuck at 7% on kria kr260 running ubuntu 22.04 LTS #662

Closed NikoSalamini closed 1 year ago

NikoSalamini commented 1 year ago

Issue template

Steps to reproduce the issue

Follow the tutorial https://micro.ros.org/docs/tutorials/core/first_application_linux/ to get the agent running on ubuntu 22.04 on the board.

Expected behavior

Successful agent build

Actual behavior

Stuck at 7% without any error information

Additional information

Output (I aborted the process after 11 minutes): Building micro-ROS Agent Starting >>> micro_ros_msgs Finished <<< micro_ros_msgs [5.13s] Starting >>> micro_ros_agent [Processing: micro_ros_agent] [Processing: micro_ros_agent]micro_ros_agent:build 7% - 1min 5.7s] [Processing: micro_ros_agent] [Processing: micro_ros_agent] [Processing: micro_ros_agent]

[Processing: micro_ros_agent]micro_ros_agent:build 7% - 4min 52.3s]_agent:build 7% - 4min 4.9s] [Processing: micro_ros_agent] [Processing: micro_ros_agent] [Processing: micro_ros_agent] [Processing: micro_ros_agent] [Processing: micro_ros_agent] Aborted <<< micro_ros_agent [11min 53s]

Is it possible that the problem is related to the level of parallelism of the jobs?

pablogs9 commented 1 year ago

Do you have the ROS 2 installation sourced?

NikoSalamini commented 1 year ago

Do you have the ROS 2 installation sourced?

Yes, I have set the environment using: source /opt/ros/iron/setup.bash source install/local_setup.bash

pablogs9 commented 1 year ago

It may be a parallelism issue for sure, maybe it is a good idea to monitor with htop the RAM and CPU usage during the build.

Could you check that and report back?

NikoSalamini commented 1 year ago

It may be a parallelism issue for sure, maybe it is a good idea to monitor with htop the RAM and CPU usage during the build.

Could you check that and report back?

Yes of course, How can I change the parallelism when running ros2 run micro_ros_setup build_agent.sh?

pablogs9 commented 1 year ago

Maybe it is a better idea to build the micro-ROS Agent package independently.

Just add the package https://github.com/micro-ROS/micro-ROS-Agent and its dependency https://github.com/micro-ROS/micro_ros_msgs inside ws/src and just call colcon build with the ROS 2 installation sourced and the CLI args according to your platform requirements.

NikoSalamini commented 1 year ago

It may be a parallelism issue for sure, maybe it is a good idea to monitor with htop the RAM and CPU usage during the build.

Could you check that and report back?

Here are the reports: htop htop2

I see that the build run with the option -j3 but the platform has 4 processors. Could it cause problems?

pablogs9 commented 1 year ago

My main concern here would be the almost 100% of RAM usage. Do you have the possibility of configuring some swap?

NikoSalamini commented 1 year ago

My main concern here would be the almost 100% of RAM usage. Do you have the possibility of configuring some swap?

Yes, I can try. I have also tried to build just the microros agent package with its dependency but I got the same results. This is the streams.log:

[0.047s] Invoking command in '/home/ubuntu/microros_ws/build/micro_ros_agent': CMAKE_PREFIX_PATH=/home/ubuntu/microros_ws/install/micro_ros_msgs:/home/ubuntu/microros_ws/install/drive_base_msgs:/home/ubuntu/microros_ws/install/micro_ros_setup:/opt/ros/iron LD_LIBRARY_PATH=/home/ubuntu/microros_ws/install/micro_ros_msgs/lib:/home/ubuntu/microros_ws/install/drive_base_msgs/lib:/opt/ros/iron/lib/aarch64-linux-gnu:/opt/ros/iron/lib PYTHONPATH=/home/ubuntu/microros_ws/install/micro_ros_msgs/lib/python3.10/site-packages:/home/ubuntu/microros_ws/install/drive_base_msgs/lib/python3.10/site-packages:/opt/ros/iron/lib/python3.10/site-packages /usr/bin/cmake /home/ubuntu/microros_ws/src/micro-ROS-Agent/micro_ros_agent -DCMAKE_INSTALL_PREFIX=/home/ubuntu/microros_ws/install/micro_ros_agent
[0.378s] -- The C compiler identification is GNU 11.4.0
[0.413s] -- Detecting C compiler ABI info
[0.765s] -- Detecting C compiler ABI info - done
[0.821s] -- Check for working C compiler: /usr/bin/cc - skipped
[0.822s] -- Detecting C compile features
[0.824s] -- Detecting C compile features - done
[1.134s] -- The CXX compiler identification is GNU 11.4.0
[1.168s] -- Detecting CXX compiler ABI info
[1.572s] -- Detecting CXX compiler ABI info - done
[1.630s] -- Check for working CXX compiler: /usr/bin/c++ - skipped
[1.631s] -- Detecting CXX compile features
[1.634s] -- Detecting CXX compile features - done
[1.817s] -- Configuring done
[1.836s] -- Generating done
[1.839s] -- Build files have been written to: /home/ubuntu/microros_ws/build/micro_ros_agent
[1.864s] Invoked command in '/home/ubuntu/microros_ws/build/micro_ros_agent' returned '0': CMAKE_PREFIX_PATH=/home/ubuntu/microros_ws/install/micro_ros_msgs:/home/ubuntu/microros_ws/install/drive_base_msgs:/home/ubuntu/microros_ws/install/micro_ros_setup:/opt/ros/iron LD_LIBRARY_PATH=/home/ubuntu/microros_ws/install/micro_ros_msgs/lib:/home/ubuntu/microros_ws/install/drive_base_msgs/lib:/opt/ros/iron/lib/aarch64-linux-gnu:/opt/ros/iron/lib PYTHONPATH=/home/ubuntu/microros_ws/install/micro_ros_msgs/lib/python3.10/site-packages:/home/ubuntu/microros_ws/install/drive_base_msgs/lib/python3.10/site-packages:/opt/ros/iron/lib/python3.10/site-packages /usr/bin/cmake /home/ubuntu/microros_ws/src/micro-ROS-Agent/micro_ros_agent -DCMAKE_INSTALL_PREFIX=/home/ubuntu/microros_ws/install/micro_ros_agent
[1.871s] Invoking command in '/home/ubuntu/microros_ws/build/micro_ros_agent': CMAKE_PREFIX_PATH=/home/ubuntu/microros_ws/install/micro_ros_msgs:/home/ubuntu/microros_ws/install/drive_base_msgs:/home/ubuntu/microros_ws/install/micro_ros_setup:/opt/ros/iron LD_LIBRARY_PATH=/home/ubuntu/microros_ws/install/micro_ros_msgs/lib:/home/ubuntu/microros_ws/install/drive_base_msgs/lib:/opt/ros/iron/lib/aarch64-linux-gnu:/opt/ros/iron/lib PYTHONPATH=/home/ubuntu/microros_ws/install/micro_ros_msgs/lib/python3.10/site-packages:/home/ubuntu/microros_ws/install/drive_base_msgs/lib/python3.10/site-packages:/opt/ros/iron/lib/python3.10/site-packages /usr/bin/cmake --build /home/ubuntu/microros_ws/build/micro_ros_agent -- -j3 -l3
[2.065s] [  6%] Creating directories for 'xrceagent'
[2.373s] [ 12%] Performing download step (git clone) for 'xrceagent'
[2.455s] Cloning into 'xrceagent'...
[5.039s] Switched to a new branch 'ros2'
[5.040s] Branch 'ros2' set up to track remote branch 'ros2' from 'origin'.
[5.257s] [ 18%] Performing update step for 'xrceagent'
[6.205s] HEAD is now at 2cbbc4a Fix deserialization endianness (#336)
[6.329s] [ 25%] No patch step for 'xrceagent'
[6.434s] [ 31%] Performing configure step for 'xrceagent'
[6.471s] loading initial cache file /home/ubuntu/microros_ws/build/micro_ros_agent/agent/tmp/xrceagent-cache-.cmake
[6.778s] -- The C compiler identification is GNU 11.4.0
[6.813s] -- Detecting C compiler ABI info
[7.162s] -- Detecting C compiler ABI info - done
[7.220s] -- Check for working C compiler: /usr/bin/cc - skipped
[7.221s] -- Detecting C compile features
[7.223s] -- Detecting C compile features - done
[7.532s] -- The CXX compiler identification is GNU 11.4.0
[7.565s] -- Detecting CXX compiler ABI info
[7.970s] -- Detecting CXX compiler ABI info - done
[8.029s] -- Check for working CXX compiler: /usr/bin/c++ - skipped
[8.030s] -- Detecting CXX compile features
[8.033s] -- Detecting CXX compile features - done
[8.072s] -- Looking for pthread.h
[8.447s] -- Looking for pthread.h - found
[8.448s] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
[8.820s] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
[8.825s] -- Found Threads: TRUE
[8.898s] -- Configuring done
[8.911s] -- Generating done
[8.915s] -- Build files have been written to: /home/ubuntu/microros_ws/build/micro_ros_agent/agent/src/xrceagent-build
[9.004s] [ 37%] Performing build step for 'xrceagent'
[9.171s] [ 12%] Creating directories for 'uagent'
[9.480s] [ 25%] No download step for 'uagent'
[9.585s] [ 37%] No update step for 'uagent'
[9.690s] [ 50%] No patch step for 'uagent'
[9.795s] [ 62%] Performing configure step for 'uagent'
[9.834s] loading initial cache file /home/ubuntu/microros_ws/build/micro_ros_agent/agent/src/xrceagent-build/uagent-prefix/tmp/uagent-cache-.cmake
[9.986s] -- Setting build type to 'Release' as none was specified.
[10.101s] CMake Warning (dev) at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
[10.102s]   The package name passed to `find_package_handle_standard_args` (tinyxml2)
[10.102s]   does not match the name of the calling package (TinyXML2).  This can lead
[10.103s]   to problems in calling code that expects `find_package` result variables
[10.103s]   (e.g., `_FOUND`) to follow a certain pattern.
[10.104s] Call Stack (most recent call first):
[10.105s]   cmake/modules/FindTinyXML2.cmake:40 (find_package_handle_standard_args)
[10.105s]   /opt/ros/iron/share/fastrtps/cmake/fastrtps-config.cmake:51 (find_package)
[10.105s]   CMakeLists.txt:153 (find_package)
[10.106s] This warning is for project developers.  Use -Wno-dev to suppress it.
[10.106s]
[10.107s] -- Found tinyxml2: /usr/lib/aarch64-linux-gnu/libtinyxml2.so
[10.350s] -- Found OpenSSL: /usr/lib/aarch64-linux-gnu/libcrypto.so (found version "3.0.2")
[10.403s] -- Configuring done
[10.476s] -- Generating done
[10.481s] -- Build files have been written to: /home/ubuntu/microros_ws/build/micro_ros_agent/agent/src/xrceagent-build
[10.561s] [ 75%] Performing build step for 'uagent'
[10.750s] [  7%] Building CXX object CMakeFiles/microxrcedds_agent.dir/src/cpp/Agent.cpp.o
[10.750s] [  7%] Building CXX object CMakeFiles/microxrcedds_agent.dir/src/cpp/Root.cpp.o
[10.751s] [  7%] Building CXX object CMakeFiles/microxrcedds_agent.dir/src/cpp/AgentInstance.cpp.o`
pablogs9 commented 1 year ago

It seems to be freezing due to RAM exhaustion, try configuring some swap.

NikoSalamini commented 1 year ago

Using a swap the build runs successfully.

pablogs9 commented 1 year ago

Cool, so I'm closed as solved, this was a RAM exhaustion problem.

pablogs9 commented 1 year ago

BTW, we are interested in knowing your use case for micro-ROS in KR260, could you provide some details here or contacting me at pablogarrido [at] eprosima [dot] com?