Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare packages for new release #938

Merged
merged 30 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
ROS_REPO: [main, testing]
ROS_DISTRO: [humble, iron, rolling]
ROS_DISTRO: [humble, jazzy, rolling]
runs-on: ubuntu-latest
env:
AFTER_INIT: ./scripts/ci_after_init.bash ${ROS_DISTRO} ${ROS_REPO}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
ROS_REPO: [main, testing]
ROS_DISTRO: [humble, iron, rolling]
ROS_DISTRO: [humble, jazzy, rolling]
runs-on: ubuntu-latest
env:
AFTER_INIT: ./scripts/ci_after_init.bash ${ROS_DISTRO} ${ROS_REPO}
Expand Down
42 changes: 42 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ARG ROS_DISTRO=jazzy

FROM osrf/ros:${ROS_DISTRO}-desktop

ARG DEBIAN_FRONTEND=noninteractive
ARG UID=1000
ARG DOCKERUSER=
ARG DOCKERUSERCOMMENT=
ARG ROS_DISTRO=jazzy
ARG ROS_TESTING=0
ARG WEBOTS_VERSION=2023b

RUN userdel -r ubuntu && \
useradd -d /${DOCKERUSER} -m \
-u ${UID} -U \
-s /usr/bin/bash \
-c "${DOCKERUSERCOMMENT}" ${DOCKERUSER} && \
echo "${DOCKERUSER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
usermod -a -G video ${DOCKERUSER} && \
usermod -a -G dialout ${DOCKERUSER}

RUN apt update && apt install -y wget && \
wget https://github.com/cyberbotics/webots/releases/download/R${WEBOTS_VERSION}/webots_${WEBOTS_VERSION}_amd64.deb -O /tmp/webots.deb && \
apt install -y /tmp/webots.deb && \
rm /tmp/webots.deb

RUN [ "$ROS_TESTING" -eq "1" ] && echo "deb [ signed-by=/usr/share/keyrings/ros2-latest-archive-keyring.gpg ] http://packages.ros.org/ros2-testing/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros2-latest.list || true

RUN apt-get update && apt-get install -y \
ros-${ROS_DISTRO}-vision-msgs \
ros-${ROS_DISTRO}-ros2-control \
ros-${ROS_DISTRO}-ros2-controllers \
ros-${ROS_DISTRO}-xacro \
gdb

COPY ./docker/bashrc /tmp/bashrc
COPY ./docker/webots.conf /${DOCKERUSER}/.config/Cyberbotics/Webots-R${WEBOTS_VERSION}.conf
RUN cat /tmp/bashrc >> /${DOCKERUSER}/.bashrc

ENV USERNAME=default
USER ${DOCKERUSER}
WORKDIR /${DOCKERUSER}/ros2_ws
44 changes: 44 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
UID:=$(shell id -u)
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))/../
NVIDIA_GPU:=$(shell docker info | grep Runtimes | grep nvidia 1> /dev/null && nvidia-smi 1> /dev/null && echo '--runtime nvidia --gpus all' || echo '')
DOCKERUSER:=cyberbotics
BASENAME:=webots_ros2
DOCKERUSERCOMMENT:="Cyberbotics"
ROS_DISTRO?=jazzy
ROS_TESTING?=0
WEBOTS_VERSION?=2023b

build:
echo "ROS_TESTING=${ROS_TESTING}"
docker build ${ROOT_DIR} \
-f ${ROOT_DIR}/docker/Dockerfile \
-t ${BASENAME}-image ${DOCKER_ARGS} \
--build-arg UID=${UID} \
--build-arg DOCKERUSER=${DOCKERUSER} \
--build-arg DOCKERUSERCOMMENT=${DOCKERUSERCOMMENT} \
--build-arg ROS_TESTING=${ROS_TESTING} \
--build-arg WEBOTS_VERSION=${WEBOTS_VERSION} \
--build-arg ROS_DISTRO=${ROS_DISTRO}

run:
@docker container rm -f ${BASENAME}-container
docker run \
--net=host \
--ipc=host \
--cap-add SYS_ADMIN \
--name ${BASENAME}-container \
--privileged \
--restart unless-stopped \
-e NVIDIA_DRIVER_CAPABILITIES=all ${NVIDIA_GPU} \
-e DISPLAY=${DISPLAY} \
-v ~/.Xauthority:/${DOCKERUSER}/.Xauthority:ro \
-v /tmp/.X11-unix/:/tmp/.X11-unix:rw \
-v /dev/dri:/dev/dri:ro \
-v ${ROOT_DIR}:/${DOCKERUSER}/ros2_ws/src/${BASENAME} \
-v /dev:/dev:rw \
--entrypoint bash \
-d -it ${BASENAME}-image


exec:
docker exec -it ${BASENAME}-container bash
22 changes: 22 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Docker

Development container for the project.

## Dependencies

```bash
sudo apt install git make curl
curl -sSL https://get.docker.com | sh && sudo usermod -aG docker $USER
```

## Usage

You need to build & run the container only the first time:
```bash
ROS_DISTRO=jazzy ROS_TESTING=1 WEBOTS_VERSION=2023b make build run exec
```

After that, you can just attach to the container with:
```bash
make exec
```
8 changes: 8 additions & 0 deletions docker/bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source /opt/ros/${ROS_DISTRO}/setup.bash
source ~/ros2_ws/install/local_setup.bash
alias cb='colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Debug'
alias teleop='ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -p stamped:=true'

# For debugging
export WEBOTS_HOME=/usr/local/webots
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/cyberbotics/ros2_ws/src/webots_ros2/webots_ros2_driver/webots/lib/controller
17 changes: 17 additions & 0 deletions docker/webots.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[%General]
checkWebotsUpdateOnStartup=false
pythonCommand=python3
rendering=true
startupMode=Real-time
telemetry=false
theme=webots_night.qss

[OpenGL]
GTAO=0
disableAntiAliasing=true
disableShadows=true
textureFiltering=1
textureQuality=0

[Internal]
firstLaunch=false
41 changes: 21 additions & 20 deletions scripts/ci_after_init.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@
ROS_DISTRO=$1
ROS_REPO=$2

# Take the latest nightly build
YESTERDAY_WEEK_DAY_NUMBER=`date --date="1 day ago" +"%u"`
LAST_NIGHTLY_DAY_OLD=1
# There is no nightly build the weekend
if [ ${YESTERDAY_WEEK_DAY_NUMBER} -gt 5 ]; then
LAST_NIGHTLY_DAY_OLD="$((${YESTERDAY_WEEK_DAY_NUMBER}-4))"
WEBOTS_VERSION="R${WEBOTS_RELEASE_VERSION}"

if [ "${TEST_WITH_WEBOTS_NIGTHLY}" == "1" ]; then
# Take the latest nightly build
YESTERDAY_WEEK_DAY_NUMBER=`date --date="1 day ago" +"%u"`
LAST_NIGHTLY_DAY_OLD=1
# There is no nightly build the weekend
if [ ${YESTERDAY_WEEK_DAY_NUMBER} -gt 5 ]; then
LAST_NIGHTLY_DAY_OLD="$((${YESTERDAY_WEEK_DAY_NUMBER}-4))"
fi
NIGHTLY_DATE=`date --date="${LAST_NIGHTLY_DAY_OLD} day ago" +"%-d_%-m_%Y"`
WEBOTS_VERSION="nightly_${NIGHTLY_DATE}"
fi
NIGHTLY_DATE=`date --date="${LAST_NIGHTLY_DAY_OLD} day ago" +"%-d_%-m_%Y"`
WEBOTS_NIGHTLY_VERSION="nightly_${NIGHTLY_DATE}"

apt update
apt install -y wget dialog apt-utils psmisc lsb-release git
wget https://github.com/cyberbotics/webots/releases/download/${WEBOTS_NIGHTLY_VERSION}/webots_${WEBOTS_RELEASE_VERSION}_amd64.deb -O /tmp/webots.deb
apt install -y /tmp/webots.deb xvfb
apt update > /dev/null
apt install -y wget dialog apt-utils psmisc lsb-release git > /dev/null
wget https://github.com/cyberbotics/webots/releases/download/${WEBOTS_VERSION}/webots_${WEBOTS_RELEASE_VERSION}_amd64.deb -O /tmp/webots.deb > /dev/null
apt install -y /tmp/webots.deb xvfb > /dev/null

# OpenSSL patch for ubuntu 22
if [[ $(lsb_release -rs) == "22.04" && ${WEBOTS_RELEASE_VERSION} == "2022a" ]]; then
Expand Down Expand Up @@ -44,13 +48,10 @@ fi
# Setup Qt plugins for RViz (can be used once RViz does not randomly crash anymore in GitHub CI).
#export QT_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins

# TODO: Remove once the https://packages.ubuntu.com/noble/python3-flake8 package version is updated.
# Manually upgrade python3-flake8 to 7.0.0 for noble

# Fixes:
# MESA: error: ZINK: failed to choose pdev
# 2024-07-27T19:23:20.1063344Z [webots-4] glx: failed to create drisw screen
if [[ "${ROS_DISTRO}" == "rolling" ]]; then
apt install -y python3-flake8
wget http://ftp.ubuntu.com/ubuntu/ubuntu/pool/universe/p/pyflakes/python3-pyflakes_3.2.0-1_all.deb -P /tmp
dpkg -i /tmp/python3-pyflakes_3.2.0-1_all.deb
wget http://ftp.ubuntu.com/ubuntu/ubuntu/pool/universe/p/python-flake8/python3-flake8_7.0.0-1_all.deb -P /tmp
dpkg -i /tmp/python3-flake8_7.0.0-1_all.deb
apt --fix-broken install -y
apt-get install -y libqt5quickcontrols2-5 qtquickcontrols2-5-dev
fi
3 changes: 2 additions & 1 deletion scripts/ci_before_init_embed.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

ROS_DISTRO=$1

export WEBOTS_RELEASE_VERSION=2023b-rev1
export TEST_WITH_WEBOTS_NIGTHLY=0
export WEBOTS_RELEASE_VERSION=2023b
export WEBOTS_OFFSCREEN=1
export CI=1
export DEBIAN_FRONTEND=noninteractive
Expand Down
8 changes: 8 additions & 0 deletions webots_ros2/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog for package webots_ros2
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2023.1.3 (2024-XX-XX)
------------------
* Added support for ROS 2 Jazzy.
* Make webots_ros2_driver scripts executable.
* Fixed passing the `robot_description` parameter to ros2_control.
* Fixed the produced URDF to also contain joint limits necessary for ros2_control.
* Added support for the new `ros2_control` API affecting resource_manager and controller_manager.

2023.1.2 (2024-04-08)
------------------
* Fixed errors showing up when launching moveit for ur5e.
Expand Down
4 changes: 4 additions & 0 deletions webots_ros2_control/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Changelog for package webots_ros2_control
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2023.1.3 (2024-XX-XX)
------------------
* Added support for the new `ros2_control` API affecting resource_manager and controller_manager.

2023.1.0 (2023-06-29)
------------------
* Fixed component activation.
Expand Down
4 changes: 2 additions & 2 deletions webots_ros2_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ project(webots_ros2_control)
# Check which ROS distribution is used, ros2control depends of that
if($ENV{ROS_DISTRO} MATCHES "humble")
add_compile_definitions(HUMBLE)
elseif($ENV{ROS_DISTRO} MATCHES "iron")
add_compile_definitions(IRON)
elseif($ENV{ROS_DISTRO} MATCHES "jazzy")
add_compile_definitions(JAZZY)
elseif($ENV{ROS_DISTRO} MATCHES "rolling")
add_compile_definitions(ROLLING)
endif()
Expand Down
57 changes: 55 additions & 2 deletions webots_ros2_control/src/Ros2Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,53 @@ const double CONTROLLER_MANAGER_ALLOWED_SAMPLE_ERROR_MS = 1.0;

namespace webots_ros2_control {

#if HARDWARE_INTERFACE_VERSION_MAJOR >= 4 && HARDWARE_INTERFACE_VERSION_MINOR >= 12
class WebotsResourceManager : public hardware_interface::ResourceManager {
public:
WebotsResourceManager(webots_ros2_driver::WebotsNode *node) :
hardware_interface::ResourceManager(node->get_node_clock_interface(), node->get_node_logging_interface()),
mHardwareLoader("webots_ros2_control", "webots_ros2_control::Ros2ControlSystemInterface"),
mLogger(node->get_logger().get_child("WebotsResourceManager")) {
mNode = node;
}

WebotsResourceManager(const WebotsResourceManager &) = delete;

bool load_and_initialize_components(const std::string &urdf, unsigned int update_rate) override {
components_are_loaded_and_initialized_ = true;

std::vector<hardware_interface::HardwareInfo> controlHardware;
try {
controlHardware = hardware_interface::parse_control_resources_from_urdf(urdf);
} catch (const std::runtime_error &ex) {
throw std::runtime_error("URDF cannot be parsed by a `ros2_control` component parser: " + std::string(ex.what()));
}
for (unsigned int i = 0; i < controlHardware.size(); i++) {
const std::string pluginName = controlHardware[i].hardware_plugin_name;

std::unique_ptr<webots_ros2_control::Ros2ControlSystemInterface> webotsSystem;
try {
webotsSystem = std::unique_ptr<webots_ros2_control::Ros2ControlSystemInterface>(
mHardwareLoader.createUnmanagedInstance(pluginName));
} catch (pluginlib::PluginlibException &ex) {
RCLCPP_ERROR(mLogger, "The plugin failed to load for some reason. Error: %s\n", ex.what());
continue;
}

webotsSystem->init(mNode, controlHardware[i]);
import_component(std::move(webotsSystem), controlHardware[i]);
}

return components_are_loaded_and_initialized_;
}

private:
webots_ros2_driver::WebotsNode *mNode;
pluginlib::ClassLoader<webots_ros2_control::Ros2ControlSystemInterface> mHardwareLoader;
rclcpp::Logger mLogger;
};
#endif

Ros2Control::Ros2Control() {
mNode = NULL;
}
Expand All @@ -62,10 +109,14 @@ namespace webots_ros2_control {
mHardwareLoader.reset(new pluginlib::ClassLoader<webots_ros2_control::Ros2ControlSystemInterface>(
"webots_ros2_control", "webots_ros2_control::Ros2ControlSystemInterface"));
} catch (pluginlib::LibraryLoadException &ex) {
throw std::runtime_error("Hardware loader cannot be created: " + atoi(ex.what()));
throw std::runtime_error("Hardware loader cannot be created: " + std::string(ex.what()));
}

// Control Hardware
#if HARDWARE_INTERFACE_VERSION_MAJOR >= 4 && HARDWARE_INTERFACE_VERSION_MINOR >= 12
std::unique_ptr<hardware_interface::ResourceManager> resourceManager =
std::make_unique<webots_ros2_control::WebotsResourceManager>(node);
#else
std::string urdfString;
std::vector<hardware_interface::HardwareInfo> controlHardware;
std::unique_ptr<hardware_interface::ResourceManager> resourceManager =
Expand All @@ -74,7 +125,7 @@ namespace webots_ros2_control {
urdfString = mNode->urdf();
controlHardware = hardware_interface::parse_control_resources_from_urdf(urdfString);
} catch (const std::runtime_error &ex) {
throw std::runtime_error("URDF cannot be parsed by a `ros2_control` component parser: " + atoi(ex.what()));
throw std::runtime_error("URDF cannot be parsed by a `ros2_control` component parser: " + std::string(ex.what()));
}
for (unsigned int i = 0; i < controlHardware.size(); i++) {
// Necessary hotfix for renamed variables present in "hardware_interface" package for versions above 3.5 (#590)
Expand All @@ -94,8 +145,10 @@ namespace webots_ros2_control {
using lifecycle_msgs::msg::State;
rclcpp_lifecycle::State active_state(State::PRIMARY_STATE_ACTIVE, hardware_interface::lifecycle_state_names::ACTIVE);
resourceManager->set_component_state(controlHardware[i].name, active_state);

resourceManager->load_urdf(urdfString, false, false);
}
#endif

// Controller Manager
mExecutor = std::make_shared<rclcpp::executors::MultiThreadedExecutor>();
Expand Down
5 changes: 5 additions & 0 deletions webots_ros2_driver/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog for package webots_ros2_driver
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2023.1.3 (2024-XX-XX)
------------------
* Make webots_ros2_driver scripts executable.
* Fixed the produced URDF to also contain joint limits necessary for ros2_control.

2023.1.1 (2023-07-11)
------------------
* Fixed RangeFinder activation to also check for point cloud subscriptions.
Expand Down
8 changes: 4 additions & 4 deletions webots_ros2_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
# Check which ROS distribution is used, vision_msgs depends of that
if($ENV{ROS_DISTRO} MATCHES "humble")
add_compile_definitions(HUMBLE)
elseif($ENV{ROS_DISTRO} MATCHES "iron")
add_compile_definitions(IRON)
elseif($ENV{ROS_DISTRO} MATCHES "jazzy")
add_compile_definitions(JAZZY)
elseif($ENV{ROS_DISTRO} MATCHES "rolling")
add_compile_definitions(ROLLING)
endif()
Expand All @@ -32,8 +32,8 @@ find_package(yaml-cpp REQUIRED)

if($ENV{ROS_DISTRO} MATCHES "humble")
find_package(Python 3.10 EXACT REQUIRED COMPONENTS Development)
elseif($ENV{ROS_DISTRO} MATCHES "iron")
find_package(Python 3.10 EXACT REQUIRED COMPONENTS Development)
elseif($ENV{ROS_DISTRO} MATCHES "jazzy")
find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development)
elseif($ENV{ROS_DISTRO} MATCHES "rolling")
find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development)
endif()
Expand Down
Loading
Loading