diff --git a/src/core/lambkin-shepherd/poetry.lock b/src/core/lambkin-shepherd/poetry.lock index 97bf771f..e715a383 100644 --- a/src/core/lambkin-shepherd/poetry.lock +++ b/src/core/lambkin-shepherd/poetry.lock @@ -1761,13 +1761,13 @@ doc = ["furo", "sphinx", "sphinx-design"] [[package]] name = "rosbags" -version = "0.9.23" +version = "0.10.11" description = "Pure Python library to read, modify, convert, and write rosbag files." optional = true -python-versions = ">=3.8.2" +python-versions = ">=3.10" files = [ - {file = "rosbags-0.9.23-py3-none-any.whl", hash = "sha256:0fd14b10ee5b2422a08b3a09d2171dc347925307716779ad6f21e398b280c56a"}, - {file = "rosbags-0.9.23.tar.gz", hash = "sha256:89229ca8fbb6d5e1cc452045229e6e47028dc10a8724fbe86c93eda477296dc2"}, + {file = "rosbags-0.10.11-py3-none-any.whl", hash = "sha256:6390c6d3c34471c37458d8cad16003c43371719610cb6a23513b8a1fe8b2c3d1"}, + {file = "rosbags-0.10.11.tar.gz", hash = "sha256:6c5fcb6392f9a8e69a9e0f6420e0862e9dcb69449b3e2d3bbec5ae17b62fc201"}, ] [package.dependencies] diff --git a/src/core/lambkin-shepherd/src/lambkin/shepherd/robot/api/ros2.py b/src/core/lambkin-shepherd/src/lambkin/shepherd/robot/api/ros2.py index bd808414..5c9f1aa4 100644 --- a/src/core/lambkin-shepherd/src/lambkin/shepherd/robot/api/ros2.py +++ b/src/core/lambkin-shepherd/src/lambkin/shepherd/robot/api/ros2.py @@ -90,12 +90,21 @@ def dump_ros_2_parameters( """ ros2cli = import_module('ros2cli.node.strategy') ros2param = import_module('ros2param.api') + if not hasattr(ros2param, "PARAMETER_SEPARATOR_STRING"): + rclpy_param = import_module('rclpy.parameter') + ros2param.PARAMETER_SEPARATOR_STRING = rclpy_param.PARAMETER_SEPARATOR_STRING with ros2cli.NodeStrategy(Namespace(**kwargs)) as node: output = deepdict() for node_name in list_nodes_with_parameters(node=node): - parameter_names = ( - ros2param.call_list_parameters( - node=node, node_name=node_name)) + future = ros2param.call_list_parameters( + node=node, node_name=node_name) + list_parameters_result = future.result() + if list_parameters_result is None: + raise RuntimeError( + f"Error in lambkin.shepherd.robot.api.ros2.dump_ros_2_parameters: " + f"Failed to list parameters for node '{node_name}'." + ) + parameter_names = list_parameters_result.result.names parameter_values = get_node_parameters( node=node, node_name=node_name, parameter_names=parameter_names) @@ -123,6 +132,9 @@ def set_ros_2_parameter( ros2param = import_module('ros2param.api') rcl_interfaces = import_module('rcl_interfaces.msg') parameter = rcl_interfaces.Parameter(name=name) + if not hasattr(ros2param, "get_parameter_value"): + rclpy_param = import_module('rclpy.parameter') + ros2param.get_parameter_value = rclpy_param.get_parameter_value parameter.value = ros2param.get_parameter_value(string_value=str(value)) with ros2cli.NodeStrategy(Namespace(**kwargs)) as node: known_node_names = list_nodes_with_parameters(node=node) diff --git a/src/core/lambkin-shepherd/src/lambkin/shepherd/robot/resources/library/ros2.resource b/src/core/lambkin-shepherd/src/lambkin/shepherd/robot/resources/library/ros2.resource index 4ccdf038..4afac7e1 100644 --- a/src/core/lambkin-shepherd/src/lambkin/shepherd/robot/resources/library/ros2.resource +++ b/src/core/lambkin-shepherd/src/lambkin/shepherd/robot/resources/library/ros2.resource @@ -101,7 +101,7 @@ Start Recording ROS 2 Bag [Documentation] Starts recording a ROS 2 bag in the background. [Arguments] ${bag} ${cwd}=. &{kwargs} [Tags] imperative - ${options} = Convert To Command Line Options output=${bag} &{kwargs} + ${options} = Convert To Command Line Options output=${bag} storage=sqlite3 &{kwargs} ${process} = Start Managed Process ros2 bag record @{options} alias=RECORD:${bag} cwd=${cwd} Process Should Be Running RECORD:${bag} msg=${bag} recording process is not running RETURN ${process} diff --git a/src/core/lambkin-shepherd/tox.ini b/src/core/lambkin-shepherd/tox.ini index c7854957..03e9e486 100644 --- a/src/core/lambkin-shepherd/tox.ini +++ b/src/core/lambkin-shepherd/tox.ini @@ -23,7 +23,7 @@ envlist = poetry_check [testenv] -allowlist_externals = poetry +allowlist_externals = poetry,flake8,robocop,mypy,pytest,robot commands_pre = poetry install --with dev --no-root --sync passenv = # ROS specific diff --git a/src/external/os/Earthfile b/src/external/os/Earthfile index 3addadee..433231fb 100644 --- a/src/external/os/Earthfile +++ b/src/external/os/Earthfile @@ -51,6 +51,12 @@ ADDUSER: ARG uid ARG gid ARG workdir=/home/${user} + IF getent passwd ${uid} > /dev/null + RUN deluser --remove-home $(id -nu ${uid}) + END + IF getent group ${gid} > /dev/null + RUN delgroup $(getent group ${gid}) + END RUN addgroup --gid ${gid} ${user} && \ adduser --uid ${uid} --ingroup ${user} \ --home /home/${user} --shell /bin/bash ${user} && \ diff --git a/src/external/ros2/Earthfile b/src/external/ros2/Earthfile index 6aaaba1e..052b1515 100644 --- a/src/external/ros2/Earthfile +++ b/src/external/ros2/Earthfile @@ -21,8 +21,9 @@ embed-ubuntu-release: ARG rosdistro FROM os+ubuntu --distro=${distro} COPY rosdistro.yml /etc/. - RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null - RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg + LET ros_apt_source_version = $(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F 'tag_name' | awk -F\\\" '{print $4}') + RUN curl -L -o /tmp/ros2-apt-source.deb "https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ros_apt_source_version}/ros2-apt-source_${ros_apt_source_version}.$(. /etc/os-release && echo $VERSION_CODENAME)_all.deb" + RUN dpkg -i /tmp/ros2-apt-source.deb LET rosdistro = "${rosdistro}" IF [ "$rosdistro" = "" ] SET rosdistro = "$(yq .ubuntu.${distro} /etc/rosdistro.yml || echo unknown)" @@ -35,6 +36,8 @@ embed-ubuntu-devel: ARG distro ARG rosdistro # forward FROM +embed-ubuntu-release --distro=${distro} --rosdistro=${rosdistro} - RUN pip install colcon-common-extensions poetry colcon-poetry-ros==0.8.0 + RUN apt update && apt install -y python3-venv && apt clean && rm -rf /var/lib/apt/lists/* + RUN pip install pipx colcon-common-extensions colcon-poetry-ros==0.8.0 + RUN pipx install --global poetry ## NOTE(hidmic): remove colcon-poetry-ros weird script relocation RUN sed -i '111,131d' $(python3 -c "import colcon_poetry_ros.task.poetry.build as m; print(m.__file__)")