micro-ROS/micro-ROS-Agent

micro-ROS-Agent inside Docker on Jetson Nano

elgarbe opened this issue · 2 comments

I need to build micro-ros-agent inside a Docker container on a Jetson Nano. I saw this post and this one

I modify build_agent.sh to this:

#! /bin/bash
set -e
set -o nounset
set -o pipefail                                                                                                                                                                                                                                                                                                                                                                                                                   echo "Building micro-ROS Agent"
colcon build --packages-up-to micro_ros_agent $@ --cmake-args \
"-DUAGENT_BUILD_EXECUTABLE=OFF" \
"-DUAGENT_USE_SYSTEM_LOGGER=ON" \
"-DUAGENT_P2P_PROFILE=OFF" \
"--no-warn-unused-cli" 

but the same errors occurr:

--- stderr: micro_ros_agent
/uros_ws/install/micro_ros_agent/lib/libmicroxrcedds_agent.so.2.4.1: undefined reference to `typeinfo for fmt::v7::format_error'
/uros_ws/install/micro_ros_agent/lib/libmicroxrcedds_agent.so.2.4.1: undefined reference to `spdlog::details::log_msg::log_msg(spdlog::source_loc, fmt::v7::basic_string_view<char>, spdlog::level::level_enum, fmt::v7::basic_string_view<char>)'
/uros_ws/install/micro_ros_agent/lib/libmicroxrcedds_agent.so.2.4.1: undefined reference to `void fmt::v7::detail::vformat_to<char>(fmt::v7::detail::buffer<char>&, fmt::v7::basic_string_view<char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity<char>::type>, fmt::v7::type_identity<char>::type> >, fmt::v7::detail::locale_ref)'
/uros_ws/install/micro_ros_agent/lib/libmicroxrcedds_agent.so.2.4.1: undefined reference to `fmt::v7::detail::error_handler::on_error(char const*)'
/uros_ws/install/micro_ros_agent/lib/libmicroxrcedds_agent.so.2.4.1: undefined reference to `fmt::v7::detail::basic_data<void>::left_padding_shifts'
/uros_ws/install/micro_ros_agent/lib/libmicroxrcedds_agent.so.2.4.1: undefined reference to `std::locale fmt::v7::detail::locale_ref::get<std::locale>() const'
/uros_ws/install/micro_ros_agent/lib/libmicroxrcedds_agent.so.2.4.1: undefined reference to `vtable for fmt::v7::format_error'
/uros_ws/install/micro_ros_agent/lib/libmicroxrcedds_agent.so.2.4.1: undefined reference to `fmt::v7::format_error::~format_error()'
collect2: error: ld returned 1 exit status
make[2]: *** [micro_ros_agent] Error 1
make[1]: *** [CMakeFiles/micro_ros_agent.dir/all] Error 2
make: *** [all] Error 2

am I missing something?

Thank

I mannage to make it work with this Dockerfile:


FROM dustynv/ros:humble-ros-base-l4t-r32.7.1

RUN mkdir -p /home/microros_ws
WORKDIR /home/microros_ws

RUN mkdir src \
    && git -C src clone -b $ROS_DISTRO https://github.com/micro-ROS/micro-ROS-Agent.git \
    && git -C src clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_msgs.git  \
    && . /opt/ros/$ROS_DISTRO/install/setup.sh \
    &&  apt update \
    &&  apt install -y python3-pip \
    libspdlog-dev \
    libfmt-dev \
    &&  apt autoremove -y \
    &&  sudo rosdep fix-permissions \
    &&  rosdep update \
    &&  rosdep install --from-paths src --ignore-src -y \
    &&  colcon build --cmake-args -DUAGENT_BUILD_EXECUTABLE=OFF -DUAGENT_P2P_PROFILE=OFF -DUAGENT_USE_SYSTEM_LOGGER=ON --no-warn-unused-cli \
    &&  rm -rf log/ build/ src/* \
    &&  rm -rf /var/lib/apt/lists/*

ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp

RUN echo "source /home/microros_ws/install/setup.bash" >> ~/.bashrc
RUN echo "source /opt/ros/$ROS_DISTRO/install/setup.bash" >> ~/.bashrc

ENTRYPOINT ["/ros_entrypoint.sh"]

I'm using this docker-compose:

version: '3.4'
services:
  robot:
    network_mode: "host"
    privileged: true
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    # command: /bin/sh -c './home/microros_ws/install/setup.bash' run
      # - /bin/sh 
      # - -c 
      # - |
      #   ./home/microros_ws/install/setup.bash
        # ros2 run micro_ros_agent micro_ros_agent serial -v --dev /dev/ttyACM0
    command: /bin/sh -c "while sleep 1000; do :; done"

Then I run:

docker-compose up -d --build
docker exec -it microrosagentdocker_robot_1 bash
elgarbe@jetson:~/micro-ros-agent_docker$ docker exec -it microrosagentdocker_robot_1 bash
root@jetson:/home/microros_ws# ros2 run micro_ros_agent micro_ros_agent serial -v --dev /dev/ttyACM0

My question is not related with micros-ROS now, but maybe you can help me.
I would like to run ros2 run micro_ros_agent micro_ros_agent serial -v --dev /dev/ttyACM0 in the docker-compose up command. Si I've tried using docker-compose's command: label. But I have not succed.
If a use
command: ros2 run micro_ros_agent micro_ros_agent serial -v --dev /dev/ttyACM0
then I get micro_ros_agent not found
I was trying to source microros_ws in the command label but without success.
Is there a way to make it work?

Thank!