micro-ROS / micro-ROS-Agent

ROS 2 package using Micro XRCE-DDS Agent.
Apache License 2.0
101 stars 58 forks source link

Micro Ros Agent build without internet. #161

Closed coalman321 closed 7 months ago

coalman321 commented 2 years ago

Issue template

I am not sure if this issue belongs with setup or the agent. If it needs to be on the agent, let me know and I will move it.

Steps to reproduce the issue

During builds, the micro-ros-agent attempts to pull content from github. This can happen if many days have passed since the last successful build of the agent, or if the build install and log directories are cleaned or removed due to other packages being broken. We use an rsync process to move content over to a remote target that does not have readily available internet access. This rsync process does not seem to move the necessary files used by the agent during build.

Expected behavior

The agent should be buildable without immediate internet access. Synchronizing the source directory from one computer to another should produce the same build result.

Actual behavior

The agent build attempts to pull content from a github repository during clean or new builds. As the build computer at this time does not have internet access, this process fails, halting the build.

coalman321@cole-asus:~/test_ws$ ls ./src
micro_ros_setup  ros2.repos  uros
coalman321@cole-asus:~/test_ws$ colcon build
Starting >>> micro_ros_msgs
Starting >>> micro_ros_setup
Finished <<< micro_ros_setup [0.15s]                               
Finished <<< micro_ros_msgs [1.54s]                     
Starting >>> micro_ros_agent
Finished <<< micro_ros_agent [0.55s]                     

Summary: 3 packages finished [2.31s]

Now I disconnect from the network and clean build artifacts

coalman321@cole-asus:~/test_ws$ rm -rf build install log
coalman321@cole-asus:~/test_ws$ colcon build
Starting >>> micro_ros_msgs
Starting >>> micro_ros_setup
Finished <<< micro_ros_setup [0.76s]                               
Finished <<< micro_ros_msgs [4.83s]                     
Starting >>> micro_ros_agent
--- stderr: micro_ros_agent                             
Cloning into 'xrceagent'...
fatal: unable to access 'https://github.com/eProsima/Micro-XRCE-DDS-Agent.git/': Could not resolve host: github.com
Cloning into 'xrceagent'...
fatal: unable to access 'https://github.com/eProsima/Micro-XRCE-DDS-Agent.git/': Could not resolve host: github.com
Cloning into 'xrceagent'...
fatal: unable to access 'https://github.com/eProsima/Micro-XRCE-DDS-Agent.git/': Could not resolve host: github.com
CMake Error at /home/coalman321/test_ws/build/micro_ros_agent/agent/tmp/xrceagent-gitclone.cmake:31 (message):
  Failed to clone repository:
  'https://github.com/eProsima/Micro-XRCE-DDS-Agent.git'

gmake[2]: *** [CMakeFiles/xrceagent.dir/build.make:99: agent/src/xrceagent-stamp/xrceagent-download] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/xrceagent.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
---
Failed   <<< micro_ros_agent [0.48s, exited with code 2]

Summary: 2 packages finished [5.52s]
  1 package failed: micro_ros_agent
  1 package had stderr output: micro_ros_agent

Additional information

This doesnt have to be the default build, and could be hidden behind a config option as this is a bit of a special case.

Any help on this would be appreciated. Thanks!

pablogs9 commented 2 years ago
  1. Add Micro XRCE-DDS Agent to your workspace, branch ros2: https://github.com/eProsima/Micro-XRCE-DDS-Agent
  2. Build Micro XRCE-DDS Agent with this flags: https://github.com/micro-ROS/micro-ROS-Agent/blob/da7fb682e9594294302bce5ef404f5dd9618f7b1/micro_ros_agent/cmake/SuperBuild.cmake#L35-L52
  3. Build micro-ROS Agent with MICROROSAGENT_SUPERBUILD set to off.
  4. Make sure that Micro XRCE-DDS Agent is built first (manually with a colcon build --packages-up-to ...) because this package is not in the package.xml of micro-ROS Agent so colcon won't resolve the dependency.

If you have any problem I will create a replicable command set for solving this.

coalman321 commented 2 years ago

I have implemented your suggestions, but I did notice something of concern. It looks like the XRCE agent has a similar cloning behavior built in. Can I forcibly include those packages into my build as well?

Output from colcon during a build

Starting >>> microxrcedds_agent
[Processing: microxrcedds_agent]                               
--- stderr: microxrcedds_agent                                       
Cloning into 'microxrcedds_client'...
HEAD is now at bdaddba Release v2.1.0
Cloning into 'microcdr'...
HEAD is now at 1c712a0 Release v2.0.0
pablogs9 commented 2 years ago

Those packages are extra functionality for the agent, I guess that you can get rid of them setting UAGENT_P2P_PROFILE and UAGENT_CED_PROFILE to OFF.

I have been able to build micro-ROS Agent without downloading any extra package with these commands:

mkdir -p ws/src && cd ws/src
git clone https://github.com/micro-ROS/micro_ros_msgs
git clone https://github.com/micro-ROS/micro-ROS-Agent
git clone https://github.com/eProsima/Micro-XRCE-DDS-Agent
cd ..

# Enter into a network-less environment
docker run -it --rm --net=none -v $(pwd):/ws ros:humble

cd ws
colcon build --packages-select microxrcedds_agent --event-handler console_direct+ --cmake-args -DUAGENT_P2P_PROFILE=OFF -DUAGENT_CED_PROFILE=OFF -DUAGENT_USE_SYSTEM_FASTDDS:BOOL=ON -DUAGENT_USE_SYSTEM_FASTCDR:BOOL=ON -DUAGENT_BUILD_EXECUTABLE=OFF -DUAGENT_ISOLATED_INSTALL:BOOL=OFF

source install/local_setup.bash

colcon build --packages-up-to micro_ros_agent --event-handler console_direct+ --cmake-args -DMICROROSAGENT_SUPERBUILD=OFF

source install/local_setup.bash

ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 -v6