Skip to content

Commit

Permalink
Merge pull request #1021 from cyberbotics/sync-master-be9c9ce
Browse files Browse the repository at this point in the history
Merge master into develop
  • Loading branch information
lukicdarkoo authored Dec 26, 2024
2 parents 1442d78 + ac07cd4 commit 0b06a79
Show file tree
Hide file tree
Showing 38 changed files with 97 additions and 55 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/libcontroller_updater.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Libcontroller Updater

on:
schedule:
- cron: '0 04 * * *'
workflow_dispatch:

jobs:
automatic-libcontroller-sync:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/sync_master_to_develop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Branch synchronizer

on:
schedule:
- cron: '0 04 * * *'
workflow_dispatch:

jobs:
sync-develop-with-master:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
ROS_DISTRO: ${{matrix.ROS_DISTRO}}
- name: Upload Artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: generic_artifacts_${{matrix.ROS_REPO}}_${{matrix.ROS_DISTRO}}
path: /artifacts
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 @@ -31,7 +31,7 @@ jobs:
ROS_DISTRO: ${{matrix.ROS_DISTRO}}
- name: Upload Artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: generic_artifacts_develop_${{matrix.ROS_REPO}}_${{matrix.ROS_DISTRO}}
path: /artifacts
Expand Down
28 changes: 23 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ARG ROS_DISTRO=jazzy
ARG ROS_TESTING=0
ARG WEBOTS_VERSION=2023b

RUN userdel -r ubuntu && \
useradd -d /${DOCKERUSER} -m \
RUN if [ "${ROS_DISTRO}" != "humble" ]; then userdel -r ubuntu; fi
RUN useradd -d /${DOCKERUSER} -m \
-u ${UID} -U \
-s /usr/bin/bash \
-c "${DOCKERUSERCOMMENT}" ${DOCKERUSER} && \
Expand All @@ -28,10 +28,28 @@ RUN [ "$ROS_TESTING" -eq "1" ] && echo "deb [ signed-by=/usr/share/keyrings/ros2

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
ros-${ROS_DISTRO}-backward-ros \
ros-${ROS_DISTRO}-control-msgs \
ros-${ROS_DISTRO}-ackermann-msgs \
ros-${ROS_DISTRO}-realtime-tools \
ros-${ROS_DISTRO}-kinematics-interface \
ros-${ROS_DISTRO}-kinematics-interface-kdl \
ros-${ROS_DISTRO}-control-toolbox \
gdb \
git

# Comment for compiled ros2_control
RUN apt-get update && apt-get install -y \
ros-${ROS_DISTRO}-ros2-control \
ros-${ROS_DISTRO}-ros2-controllers

# Uncomment for compiled ros2_control
# RUN git clone --branch=${ROS_DISTRO} https://github.com/ros-controls/ros2_control.git /${DOCKERUSER}/ros2_libs_ws/src/ros2_control && \
# git clone --branch=${ROS_DISTRO} https://github.com/ros-controls/ros2_controllers.git /${DOCKERUSER}/ros2_libs_ws/src/ros2_controllers && \
# . /opt/ros/humble/setup.sh && \
# cd /${DOCKERUSER}/ros2_libs_ws && \
# colcon build --symlink-install

COPY ./docker/bashrc /tmp/bashrc
COPY ./docker/webots.conf /${DOCKERUSER}/.config/Cyberbotics/Webots-R${WEBOTS_VERSION}.conf
Expand Down
1 change: 1 addition & 0 deletions docker/bashrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
source /opt/ros/${ROS_DISTRO}/setup.bash
source ~/ros2_libs_ws/install/local_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'
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Changelog for package webots_ros2
------------------
* Created webots_ros2_husarion package.

2023.1.3 (2024-XX-XX)
2023.1.3 (2024-08-07)
------------------
* Added support for ROS 2 Jazzy.
* Make webots_ros2_driver scripts executable.
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>webots_ros2</name>
<version>2023.1.2</version>
<version>2023.1.3</version>
<description>Interface between Webots and ROS2</description>

<maintainer email="[email protected]">Cyberbotics</maintainer>
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name=package_name,
version='2023.1.2',
version='2023.1.3',
packages=[package_name],
data_files=[
('share/' + package_name, ['package.xml']),
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_control/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Changelog for package webots_ros2_control
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_control/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>webots_ros2_control</name>
<version>2023.1.2</version>
<version>2023.1.3</version>
<description>ros2_control plugin for Webots</description>
<maintainer email="[email protected]">Cyberbotics</maintainer>
<url type="website">http://wiki.ros.org/webots_ros2</url>
Expand Down
6 changes: 5 additions & 1 deletion webots_ros2_control/src/Ros2Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ namespace webots_ros2_control {

// Controller Manager
mExecutor = std::make_shared<rclcpp::executors::MultiThreadedExecutor>();
mControllerManager.reset(new controller_manager::ControllerManager(std::move(resourceManager), mExecutor));

rclcpp::NodeOptions options = controller_manager::get_cm_node_options();
options.arguments(node->get_node_options().arguments());
mControllerManager.reset(new controller_manager::ControllerManager(std::move(resourceManager), mExecutor,
"controller_manager", node->get_namespace(), options));

// Update rate
const int updateRate = mControllerManager->get_parameter("update_rate").as_int();
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_driver/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Changelog for package webots_ros2_driver
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2023.1.3 (2024-XX-XX)
2023.1.3 (2024-08-07)
------------------
* Make webots_ros2_driver scripts executable.
* Fixed the produced URDF to also contain joint limits necessary for ros2_control.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace webots_ros2_driver {

class WebotsNode : public rclcpp::Node {
public:
WebotsNode(std::string name);
WebotsNode(std::string name, rclcpp::NodeOptions &options);
void init();
int step();
std::string urdf() const { return mRobotDescription; };
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_driver/package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package format="3">
<name>webots_ros2_driver</name>
<version>2023.1.2</version>
<version>2023.1.3</version>
<description>Implementation of the Webots - ROS 2 interface</description>
<maintainer email="[email protected]">Cyberbotics</maintainer>
<license>Apache License 2.0</license>
Expand Down
5 changes: 4 additions & 1 deletion webots_ros2_driver/src/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ int main(int argc, char **argv) {
for (char notAllowedChar : " -.)(")
std::replace(robotName.begin(), robotName.end(), notAllowedChar, '_');

std::shared_ptr<webots_ros2_driver::WebotsNode> node = std::make_shared<webots_ros2_driver::WebotsNode>(robotName);
rclcpp::NodeOptions nodeOptions;
nodeOptions.arguments(std::vector<std::string>(argv + 1, argv + argc));
std::shared_ptr<webots_ros2_driver::WebotsNode> node =
std::make_shared<webots_ros2_driver::WebotsNode>(robotName, nodeOptions);
node->init();

// The parent process must be ros2 run. Declaring from launch file is deprecated. Remove with 2024.0.0.
Expand Down
4 changes: 3 additions & 1 deletion webots_ros2_driver/src/WebotsNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ namespace webots_ros2_driver {
gShutdownSignalReceived = true;
}

WebotsNode::WebotsNode(std::string name) : Node(name), mPluginLoader(gPluginInterfaceName, gPluginInterface) {
WebotsNode::WebotsNode(std::string name, rclcpp::NodeOptions &options) :
Node(name, options),
mPluginLoader(gPluginInterfaceName, gPluginInterface) {
mRobotDescriptionParam = this->declare_parameter<std::string>("robot_description", "");
mSetRobotStatePublisher = this->declare_parameter<bool>("set_robot_state_publisher", false);
if (mRobotDescriptionParam != "") {
Expand Down
42 changes: 28 additions & 14 deletions webots_ros2_driver/webots/src/controller/c/robot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,21 +1081,33 @@ static void wb_robot_cleanup_devices() {
}
}

static char *encode_robot_name(const char *robot_name) {
static char *encode_robot_name(const char *robot_name, int chars_used) {
if (!robot_name)
return NULL;

char *encoded_name = percent_encode(robot_name);
int length = strlen(encoded_name);
// the robot name is used to connect to the libController and in this process there are indirect
// limitations such as QLocalServer only accepting strings up to 106 characters for server names,
// for these reasons if the robot name is bigger than an arbitrary length, a hashed version is used instead
if (length > 70) { // note: this threshold should be the same as in WbRobot.cpp
// limitations such as QLocalServer only accepting strings up to 91 characters long for server names
// on some platforms.
// Since the server name also contains the tmp path and that includes the user's username and,
// in the case of a Snap, the user's home directory, we need to limit the length of the encoded
// robot name based on the tmp path. If it is longer than that, then we compute a hashed version
// of the name and use as much of it as we can. If that would be less than 4 chars, we try to use
// 4 chars and hope we are on a platform where QLocalServer accepts longer names. 4 chars makes the
// chance of a name collision 1/65536.
// Note: It is critical that the same logic is used in WbRobot.cpp
int max_name_length = 91 - chars_used;
if (max_name_length < 4)
max_name_length = 4;
// Round down to the next multiple of 2 because it makes the code easier.
max_name_length = max_name_length / 2 * 2;
if (length > max_name_length) {
char hash[21];
char *output = malloc(41);
char *output = malloc(max_name_length + 1);
SHA1(hash, encoded_name, length);
free(encoded_name);
for (size_t i = 0; i < 20; i++)
for (size_t i = 0; i < max_name_length / 2 && i < 20; i++)
sprintf((output + (2 * i)), "%02x", hash[i] & 0xff);
return output;
}
Expand All @@ -1104,10 +1116,12 @@ static char *encode_robot_name(const char *robot_name) {
}

static char *compute_socket_filename(char *error_buffer) {
char *robot_name = encode_robot_name(wbu_system_getenv("WEBOTS_ROBOT_NAME"));
const char *WEBOTS_INSTANCE_PATH = wbu_system_webots_instance_path(true);
char *robot_name = NULL;
const char *WEBOTS_ROBOT_NAME = wbu_system_getenv("WEBOTS_ROBOT_NAME");
char *socket_filename;
if (robot_name && robot_name[0] && WEBOTS_INSTANCE_PATH && WEBOTS_INSTANCE_PATH[0]) {
if (WEBOTS_ROBOT_NAME && WEBOTS_ROBOT_NAME[0] && WEBOTS_INSTANCE_PATH && WEBOTS_INSTANCE_PATH[0]) {
robot_name = encode_robot_name(WEBOTS_ROBOT_NAME, strlen(WEBOTS_INSTANCE_PATH) + strlen("ipc//intern"));
#ifndef _WIN32
const int length = strlen(WEBOTS_INSTANCE_PATH) + strlen(robot_name) + 15; // "%sintern/%s/socket"
socket_filename = malloc(length);
Expand Down Expand Up @@ -1267,7 +1281,7 @@ static char *compute_socket_filename(char *error_buffer) {

free(robot_name);
const char *sub_string = strstr(&WEBOTS_CONTROLLER_URL[6], "/");
robot_name = encode_robot_name(sub_string ? sub_string + 1 : NULL);
robot_name = encode_robot_name(sub_string ? sub_string + 1 : NULL, strlen(ipc_folder) + strlen("//extern"));
if (robot_name) {
#ifndef _WIN32
// socket file name is like: folder + robot_name + "/extern"
Expand Down Expand Up @@ -1370,7 +1384,7 @@ static void compute_remote_info(char **host, int *port, char **robot_name) {
snprintf(*host, host_length, "%s", &WEBOTS_CONTROLLER_URL[6]);
sscanf(url_suffix, ":%d", port);
const char *rn = strstr(url_suffix, "/");
*robot_name = rn != NULL ? encode_robot_name(rn + 1) : NULL;
*robot_name = rn != NULL ? encode_robot_name(rn + 1, 0) : NULL;
}

int wb_robot_init() { // API initialization
Expand Down Expand Up @@ -1462,11 +1476,11 @@ int wb_robot_init() { // API initialization
retry -= 5;
fprintf(stderr, "%s, pending until loading is done...\n", error_message);
} else if (socket_filename) {
fprintf(stderr,
"The specified robot (at %s) is not in the list of robots with <extern> controllers, retrying for another %d "
"seconds...\n",
socket_filename, 50 - retry);
free(socket_filename);
fprintf(
stderr,
"The specified robot is not in the list of robots with <extern> controllers, retrying for another %d seconds...\n",
50 - retry);
} else
fprintf(stderr, "%s, retrying for another %d seconds...\n", error_message, 50 - retry);
}
Expand Down
3 changes: 3 additions & 0 deletions webots_ros2_driver/webots/src/controller/c/supervisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2831,6 +2831,9 @@ const double *wb_supervisor_virtual_reality_headset_get_orientation() {
}

const char *wb_supervisor_field_get_name(WbFieldRef field) {
if (!check_field(field, __FUNCTION__, WB_NO_FIELD, false, NULL, false, false))
return "";

return field->name;
}

Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_epuck/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>webots_ros2_epuck</name>
<version>2023.1.2</version>
<version>2023.1.3</version>
<description>E-puck2 driver for Webots simulated robot</description>

<maintainer email="[email protected]">Cyberbotics</maintainer>
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_epuck/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

setup(
name=package_name,
version='2023.1.2',
version='2023.1.3',
packages=[package_name],
data_files=data_files,
install_requires=['setuptools', 'launch'],
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_importer/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>webots_ros2_importer</name>
<version>2023.1.2</version>
<version>2023.1.3</version>
<description>This package allows to convert URDF and XACRO files into Webots PROTO files.</description>

<maintainer email="[email protected]">Cyberbotics</maintainer>
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_importer/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name=package_name,
version='2023.1.2',
version='2023.1.3',
packages=[package_name, package_name + '.urdf2webots.urdf2webots'],
data_files=data_files,
install_requires=[
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_mavic/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>webots_ros2_mavic</name>
<version>2023.1.2</version>
<version>2023.1.3</version>
<description>Mavic 2 Pro robot ROS2 interface for Webots.</description>

<maintainer email="[email protected]">Cyberbotics</maintainer>
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_mavic/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

setup(
name=package_name,
version='2023.1.2',
version='2023.1.3',
packages=[package_name],
data_files=data_files,
install_requires=['setuptools', 'launch'],
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_msgs/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>webots_ros2_msgs</name>
<version>2023.1.2</version>
<version>2023.1.3</version>
<description>Services and Messages of the webots_ros2 packages.</description>

<maintainer email="[email protected]">Cyberbotics</maintainer>
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_tesla/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>webots_ros2_tesla</name>
<version>2023.1.2</version>
<version>2023.1.3</version>
<description>Tesla ROS2 interface for Webots.</description>

<maintainer email="[email protected]">Cyberbotics</maintainer>
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_tesla/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

setup(
name=package_name,
version='2023.1.2',
version='2023.1.3',
packages=[package_name],
data_files=data_files,
install_requires=['setuptools', 'launch'],
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_tests/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>webots_ros2_tests</name>
<version>2023.1.2</version>
<version>2023.1.3</version>
<description>System tests for `webots_ros2` packages.</description>

<maintainer email="[email protected]">Cyberbotics</maintainer>
Expand Down
2 changes: 1 addition & 1 deletion webots_ros2_tests/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name=package_name,
version='2023.1.2',
version='2023.1.3',
packages=[package_name],
data_files=data_files,
install_requires=['setuptools', 'launch'],
Expand Down
Loading

0 comments on commit 0b06a79

Please sign in to comment.