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

Merge develop into master #779

Merged
merged 94 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
de3f8cb
Sync submodule (#501)
github-actions[bot] Nov 1, 2022
891294a
Sync submodule (#507)
github-actions[bot] Nov 3, 2022
67e3330
Merge master into develop (#524)
ygoumaz Nov 18, 2022
0e45db3
Remove deprecared `webots_ros2_core` package (#525)
ad-daniel Nov 18, 2022
4cea114
Add Python API compatibility and libController compilation (#508)
ygoumaz Nov 22, 2022
813770a
Upgrade to R2023a (develop) (#535)
ygoumaz Nov 24, 2022
d78b481
Enhancement add auto libcontroller sync (#528)
ygoumaz Nov 25, 2022
5afd530
Merge master into develop (#542)
ygoumaz Nov 29, 2022
06f14c5
Sync submodule (#544)
github-actions[bot] Nov 30, 2022
625f5bd
Sync submodule (#547)
github-actions[bot] Dec 2, 2022
e2bfba9
Sync submodule (#550)
github-actions[bot] Dec 5, 2022
47d50c5
Sync submodule (#553)
github-actions[bot] Dec 9, 2022
0f5d3d3
Sync submodule (#556)
github-actions[bot] Dec 13, 2022
7151b4d
Sync submodule (#563)
github-actions[bot] Dec 14, 2022
ecffb37
Sync submodule (#566)
github-actions[bot] Dec 16, 2022
3c1dd9a
Sync submodule (#571)
github-actions[bot] Dec 23, 2022
06cffad
Sync submodule (#589)
github-actions[bot] Jan 5, 2023
1817825
Merge branch 'master' into merge-master-into-develop
ad-daniel Jan 11, 2023
001285d
Merge pull request #598 from cyberbotics/merge-master-into-develop
ad-daniel Jan 12, 2023
3da50ad
Enforce clang format (#599) (#601)
ad-daniel Jan 19, 2023
7eec9b4
Sync submodule (#605)
github-actions[bot] Jan 24, 2023
1783557
Sync submodule (#608)
github-actions[bot] Jan 27, 2023
a111867
Sync submodule (#611)
github-actions[bot] Feb 1, 2023
6d16b9f
Sync submodule (#614)
github-actions[bot] Feb 3, 2023
8539f74
Sync submodule (#618)
github-actions[bot] Feb 7, 2023
cc23766
Sync submodule (#621)
github-actions[bot] Feb 8, 2023
79c4dee
Sync submodule (#624)
github-actions[bot] Feb 10, 2023
732f534
Sync submodule (#628)
github-actions[bot] Feb 16, 2023
d999fa6
Sync master with develop (#630)
ygoumaz Feb 17, 2023
e9cc6dc
Update sync_controller_lib.sh (#629)
ygoumaz Feb 17, 2023
0290484
Merge branch 'develop' into synchronization-master-into-develop
ygoumaz Mar 1, 2023
86eee52
revert lib controller changes
ygoumaz Mar 1, 2023
da6d7a5
Executable sync_controller_lib
ygoumaz Mar 1, 2023
785096b
Create lib controller PRs
ygoumaz Mar 1, 2023
5ff1a48
Update libcontroller_updater.yml
ygoumaz Mar 1, 2023
957d7d6
Fix develop branch (#649)
ygoumaz Mar 1, 2023
c16da1e
Update libcontroller_updater.yml
ygoumaz Mar 1, 2023
f60bfee
Merge branch 'develop' into synchronization-master-into-develop
ygoumaz Mar 1, 2023
61f33cb
Remove lib controller update
ygoumaz Mar 1, 2023
df7dee9
Sync submodule (#652)
github-actions[bot] Mar 1, 2023
c7cc471
Merge branch 'develop' into synchronization-master-into-develop
ygoumaz Mar 1, 2023
81cd9db
Merge pull request #648 from cyberbotics/synchronization-master-into-…
ygoumaz Mar 2, 2023
dab6e74
Sync submodule (#661)
github-actions[bot] Mar 7, 2023
4be8e98
Sync submodule (#663)
github-actions[bot] Mar 8, 2023
40fa234
Sync submodule (#667)
github-actions[bot] Mar 10, 2023
2097f3a
Sync submodule (#670)
github-actions[bot] Mar 13, 2023
a87f086
Sync submodule (#678)
github-actions[bot] Mar 21, 2023
3fb1a2d
Merge branch 'master' into merge-master-into-develop
ad-daniel Mar 29, 2023
f09a561
Adapt develop workflow
ad-daniel Mar 29, 2023
97497ef
Merge pull request #693 from cyberbotics/merge-master-into-develop
ad-daniel Mar 29, 2023
d157885
Sync submodule (#699)
github-actions[bot] Apr 3, 2023
7188baf
Sync submodule (#701)
github-actions[bot] Apr 4, 2023
a78c63e
Sync submodule (#713)
github-actions[bot] Apr 19, 2023
e46c59b
Merge master into develop (#715)
ygoumaz Apr 24, 2023
bb34c2c
Fix worlds in develop (#716)
ygoumaz Apr 24, 2023
024a630
Merge branch 'develop' into merge-master-into-develop
ygoumaz May 3, 2023
a607a8b
Sync libcontroller develop (#723)
github-actions[bot] May 3, 2023
a4d0d04
Merge branch 'develop' into merge-master-into-develop
ygoumaz May 3, 2023
699167c
Improve TIAGo for better compatibility with real robot (#717)
ygoumaz May 3, 2023
fd9b897
Merge branch 'develop' into merge-master-into-develop
ygoumaz May 3, 2023
c1d79f0
Merge pull request #724 from cyberbotics/merge-master-into-develop
ygoumaz May 3, 2023
4227210
backport changes (#729)
ygoumaz May 4, 2023
2343f0f
clean world (#738)
ygoumaz May 9, 2023
d12d24d
Sync submodule (#740)
github-actions[bot] May 10, 2023
2bd2ac1
Sync libcontroller develop (#745)
github-actions[bot] May 12, 2023
5476409
Merge branch 'develop' into merge-master-into-develop
ygoumaz May 17, 2023
3a4b152
Update CHANGELOG.rst
ygoumaz May 17, 2023
59fa1f5
Update CHANGELOG.rst
ygoumaz May 17, 2023
fb85a58
Update robot_bringup_launch.py
ygoumaz May 17, 2023
e927617
Remove forgotten TODO
ygoumaz May 17, 2023
92f5402
Merge pull request #751 from cyberbotics/merge-master-into-develop
ygoumaz May 17, 2023
dd566c7
Sync submodule (#752)
github-actions[bot] May 19, 2023
5b769d9
Feature WebotsController node (#746)
ygoumaz May 22, 2023
7516e7a
Install libgeneric_robot_window.so in driver (#742)
ygoumaz May 22, 2023
7f9c318
Merge branch 'develop' into sync-master-835e5ef
ygoumaz May 23, 2023
dee9fa8
Merge pull request #754 from cyberbotics/sync-master-835e5ef
ygoumaz May 23, 2023
68bc42b
Merge branch 'develop' into sync-master-4ba4eb1
ygoumaz May 24, 2023
94ef313
Merge pull request #758 from cyberbotics/sync-master-4ba4eb1
ygoumaz May 24, 2023
074675e
749 ros2camera publishes non canonical topics and camera info (#761)
justinberi Jun 2, 2023
653b00a
Merge branch 'develop' into sync-master-b901918
ygoumaz Jun 5, 2023
8b0ee83
Update robot_launch.py
ygoumaz Jun 5, 2023
16e4a46
Update robot_launch.py
ygoumaz Jun 5, 2023
b8fe29e
Merge pull request #762 from cyberbotics/sync-master-b901918
ygoumaz Jun 5, 2023
93bd27e
fix sources
ygoumaz Jun 8, 2023
68a2d30
Merge branch 'develop' into sync-master-720cb0c
ygoumaz Jun 8, 2023
891b495
fix
ygoumaz Jun 8, 2023
6da4618
fix testing tests
ygoumaz Jun 8, 2023
3762d7a
Merge pull request #769 from cyberbotics/sync-master-720cb0c
ygoumaz Jun 8, 2023
69e4859
Sync submodule
Jun 13, 2023
6f8c08f
Merge pull request #773 from cyberbotics/sync-develop-eee8e098c2fa74b…
omichel Jun 13, 2023
8f8bff6
Sync submodule
Jun 15, 2023
951c031
Merge pull request #774 from cyberbotics/sync-develop-a3ffbea6fdafc26…
omichel Jun 15, 2023
e6d4424
Adding VacuumGripper device (#771)
stefaniapedrazzi Jun 16, 2023
bae3c55
Update version.txt
ygoumaz Jun 19, 2023
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 scripts/ci_before_init_embed.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

ROS_DISTRO=$1

export WEBOTS_RELEASE_VERSION=2023a-rev1
export WEBOTS_RELEASE_VERSION=2023b
export WEBOTS_OFFSCREEN=1
export CI=1
export DEBIAN_FRONTEND=noninteractive
Expand Down
9 changes: 8 additions & 1 deletion webots_ros2/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ Changelog for package webots_ros2
------------------
* Added support for Navigation2 in Iron.
* Clean simulation reset in launch files.
* Added new TIAGo project to webots_ros2_tiago to run real robot configuration.
* Added new WebotsController node in the driver interface to launch robot controller plugins.
* Fixed unfound robot window library in Tesla example.
* Default to canonical topic name and fix camera_info stamp in Ros2Camera, Ros2RangeFinder.
* Added VacuumGripper gripper support in webots_ros2_driver.
* Added BoolStamped message in webots_ros2_msgs.
* Added GetBool message in webots_ros2_msgs.

2023.0.4 (2023-05-23)
------------------
* Drop support for Foxy.
* Fixed vertical field of view in static RangeFinder plugin.
* Added support for painted point clouds
* Added support for painted point clouds.
* Fixed ability to launch RViz without other tools in e-puck example.
* Fixed command line arguments in importer tools.
* Added custom handler in driver interface to start nodes when Webots is ready.
Expand Down
10 changes: 9 additions & 1 deletion webots_ros2_driver/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
Changelog for package webots_ros2_driver
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2023.1.0 (2023-XX-XX)
------------------
* Added parameters to rename Camera and RangeFinder topics.
* Added new WebotsController node to launch robot controller plugins.
* Added compilation of the generic robot window library.
* Default to canonical topic name and fix camera_info stamp in Ros2Camera, Ros2RangeFinder.
* Added VacuumGripper device support

2023.0.4 (2023-05-23)
------------------
* Fixed vertical field of view in static RangeFinder plugin.
* Added support for painted point clouds
* Added support for painted point clouds.
* Added custom handler to start nodes when Webots is ready.

2023.0.3 (2023-04-12)
Expand Down
18 changes: 15 additions & 3 deletions webots_ros2_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ add_custom_target(compile-lib-vehicle ALL
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/webots/projects/default/libraries/vehicle
)

add_custom_target(compile-generic-window ALL
COMMAND ${CMAKE_COMMAND} -E env "WEBOTS_HOME=${CMAKE_CURRENT_SOURCE_DIR}/webots" make release -f Makefile > /dev/null 2>&1
DEPENDS compile-lib-controller
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/webots/resources/projects/libraries/generic_robot_window
)

set(WEBOTS_LIB_BASE webots/lib/controller)

include_directories(
Expand Down Expand Up @@ -71,7 +77,6 @@ ament_python_install_package(${PROJECT_NAME}
PACKAGE_DIR ${PROJECT_NAME})

# Driver
set(CMAKE_INSTALL_RPATH "$ORIGIN/../controller")
add_executable(driver
src/Driver.cpp
src/WebotsNode.cpp
Expand All @@ -87,6 +92,7 @@ add_executable(driver
src/plugins/static/Ros2Emitter.cpp
src/plugins/static/Ros2Receiver.cpp
src/plugins/static/Ros2Compass.cpp
src/plugins/static/Ros2VacuumGripper.cpp
src/utils/Math.cpp
src/utils/Utils.cpp
)
Expand Down Expand Up @@ -119,7 +125,6 @@ install(TARGETS driver
)

# Dynamic IMU
set(CMAKE_INSTALL_RPATH "$ORIGIN/controller")
add_library(
${PROJECT_NAME}_imu
SHARED
Expand Down Expand Up @@ -147,7 +152,6 @@ install(TARGETS ${PROJECT_NAME}_imu
)

# Dynamic RGBD
set(CMAKE_INSTALL_RPATH "$ORIGIN/controller")
add_library(
${PROJECT_NAME}_rgbd
SHARED
Expand Down Expand Up @@ -193,6 +197,7 @@ install(
PATTERN "*CppCar*"
PATTERN "*driver*"
PATTERN "*CppDriver*"
PATTERN "*generic_robot_window*"
)

# Prevent pluginlib from using boost
Expand All @@ -213,6 +218,12 @@ install(
DESTINATION share/${PROJECT_NAME}/scripts
)

# Install webots-controller script
install(
PROGRAMS webots/webots-controller
DESTINATION share/${PROJECT_NAME}/scripts
)

# Ament export
set(WEBOTS_LIB_PATH
controller/${CMAKE_SHARED_LIBRARY_PREFIX}Controller${CMAKE_SHARED_LIBRARY_SUFFIX}
Expand All @@ -221,6 +232,7 @@ set(WEBOTS_LIB_PATH
controller/${CMAKE_SHARED_LIBRARY_PREFIX}CppDriver${CMAKE_SHARED_LIBRARY_SUFFIX}
controller/${CMAKE_SHARED_LIBRARY_PREFIX}car${CMAKE_SHARED_LIBRARY_SUFFIX}
controller/${CMAKE_SHARED_LIBRARY_PREFIX}CppCar${CMAKE_SHARED_LIBRARY_SUFFIX}
controller/${CMAKE_SHARED_LIBRARY_PREFIX}generic_robot_window${CMAKE_SHARED_LIBRARY_SUFFIX}
)

ament_export_include_directories(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace webots_ros2_driver {
void setAnotherNodeParameter(std::string anotherNodeName, std::string parameterName, std::string parameterValue);
rclcpp::Client<rcl_interfaces::srv::SetParameters>::SharedPtr mClient;

std::string mRobotDescriptionParam;
std::string mRobotDescription;
bool mSetRobotStatePublisher;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ namespace webots_ros2_driver {

WbDeviceTag mCamera;

std::string mCameraInfoSuffix;
std::string mImageSuffix;

rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr mImagePublisher;
sensor_msgs::msg::Image mImageMessage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ namespace webots_ros2_driver {

WbDeviceTag mRangeFinder;

std::string mCameraInfoSuffix;
std::string mImageSuffix;
std::string mPointCloudSuffix;

rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr mImagePublisher;
sensor_msgs::msg::Image mImageMessage;
rclcpp::Publisher<sensor_msgs::msg::CameraInfo>::SharedPtr mCameraInfoPublisher;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 1996-2023 Cyberbotics Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef ROS2_VACUUM_GRIPPER_HPP
#define ROS2_VACUUM_GRIPPER_HPP

#include <webots_ros2_driver/WebotsNode.hpp>
#include <webots_ros2_driver/plugins/Ros2SensorPlugin.hpp>

#include <std_msgs/msg/bool.hpp>
#include <webots_ros2_msgs/msg/bool_stamped.hpp>
#include <webots_ros2_msgs/srv/get_bool.hpp>

namespace webots_ros2_driver {
class Ros2VacuumGripper : public Ros2SensorPlugin {
public:
void step() override;
void init(webots_ros2_driver::WebotsNode *node, std::unordered_map<std::string, std::string> &parameters) override;

private:
void publishPresence();

// ROS2 subscriptions
rclcpp::Subscription<std_msgs::msg::Bool>::SharedPtr mTurnOnSubscription;
void turnOnCallback(const std_msgs::msg::Bool::SharedPtr message);

// ROS2 services
rclcpp::Service<webots_ros2_msgs::srv::GetBool>::SharedPtr mIsOnService;
void isOnCallback(const std::shared_ptr<webots_ros2_msgs::srv::GetBool::Request> request,
std::shared_ptr<webots_ros2_msgs::srv::GetBool::Response> response);

// ROS2 topics
rclcpp::Publisher<webots_ros2_msgs::msg::BoolStamped>::SharedPtr mPresencePublisher;
webots_ros2_msgs::msg::BoolStamped mPresenceMessage;
bool mIsPresenceEnabled;

// Device
WbDeviceTag mVacuumGripper;
// Runtime vars
std::string mDeviceName;
};

} // namespace webots_ros2_driver

#endif
5 changes: 0 additions & 5 deletions webots_ros2_driver/src/PythonPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ namespace webots_ros2_driver {
import os
import sys

# Set WEBOTS_HOME to the webots_ros2_driver installation folder
# to load the correct libController libraries from the Python API
from ament_index_python.packages import get_package_prefix
os.environ['WEBOTS_HOME'] = get_package_prefix('webots_ros2_driver')

import controller
from controller import Supervisor

Expand Down
48 changes: 44 additions & 4 deletions webots_ros2_driver/src/WebotsNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <webots_ros2_driver/plugins/static/Ros2LightSensor.hpp>
#include <webots_ros2_driver/plugins/static/Ros2RangeFinder.hpp>
#include <webots_ros2_driver/plugins/static/Ros2Receiver.hpp>
#include <webots_ros2_driver/plugins/static/Ros2VacuumGripper.hpp>
#include "webots_ros2_driver/PluginInterface.hpp"

#include "webots_ros2_driver/PluginInterface.hpp"
Expand All @@ -49,13 +50,45 @@ namespace webots_ros2_driver {
}

WebotsNode::WebotsNode(std::string name) : Node(name), mPluginLoader(gPluginInterfaceName, gPluginInterface) {
mRobotDescription = this->declare_parameter<std::string>("robot_description", "");
mRobotDescriptionParam = this->declare_parameter<std::string>("robot_description", "");
mSetRobotStatePublisher = this->declare_parameter<bool>("set_robot_state_publisher", false);
if (mRobotDescription != "") {
if (mRobotDescriptionParam != "") {
mRobotDescriptionDocument = std::make_shared<tinyxml2::XMLDocument>();
mRobotDescriptionDocument->Parse(mRobotDescription.c_str());
// Path to URDF file
if (mRobotDescriptionParam.rfind(".urdf") == mRobotDescriptionParam.size() - 5)
mRobotDescriptionDocument->LoadFile(mRobotDescriptionParam.c_str());
// Path to Xacro file
else if (mRobotDescriptionParam.rfind(".xacro") == mRobotDescriptionParam.size() - 6) {
std::vector<std::string> xacroMappings =
this->declare_parameter<std::vector<std::string>>("xacro_mappings", std::vector<std::string>());
std::string command = "ros2 run xacro xacro " + mRobotDescriptionParam;
for (const std::string &xacroMapping : xacroMappings) {
command += " ";
command += xacroMapping;
}

FILE *stream = popen(command.c_str(), "r");
if (!stream)
throw std::runtime_error("Failed to execute xacro command");

char buffer[4096];
std::string xacroOutput;
while (fgets(buffer, sizeof(buffer), stream) != NULL)
xacroOutput += buffer;
pclose(stream);

mRobotDescriptionDocument->Parse(xacroOutput.c_str());
}
// Full string (deprecated)
else {
mRobotDescriptionDocument->Parse(mRobotDescriptionParam.c_str());
RCLCPP_WARN(
get_logger(),
"\033[33mPassing robot description as a string is deprecated. Provide the URDF or Xacro file path instead.\033[0m");
}
if (!mRobotDescriptionDocument)
throw std::runtime_error("Invalid URDF, it cannot be parsed");
throw std::runtime_error("Invalid robot description, it cannot be parsed");
// Access the robot and webots elements as needed
tinyxml2::XMLElement *robotXMLElement = mRobotDescriptionDocument->FirstChildElement("robot");
if (!robotXMLElement)
throw std::runtime_error("Invalid URDF, it doesn't contain a <robot> tag");
Expand All @@ -64,6 +97,10 @@ namespace webots_ros2_driver {
mWebotsXMLElement = NULL;
RCLCPP_INFO(get_logger(), "Robot description is not passed, using default parameters.");
}
// Store robot description string in mRobotDescription
tinyxml2::XMLPrinter printer;
mRobotDescriptionDocument->Accept(&printer);
mRobotDescription = printer.CStr();

mRemoveUrdfRobotPublisher = create_publisher<std_msgs::msg::String>("/remove_urdf_robot", rclcpp::ServicesQoS());
mRemoveUrdfRobotMessage.data = name;
Expand Down Expand Up @@ -165,6 +202,9 @@ namespace webots_ros2_driver {
case WB_NODE_COMPASS:
plugin = std::make_shared<webots_ros2_driver::Ros2Compass>();
break;
case WB_NODE_VACUUM_GRIPPER:
plugin = std::make_shared<webots_ros2_driver::Ros2VacuumGripper>();
break;
}
if (plugin) {
plugin->init(this, parameters);
Expand Down
9 changes: 7 additions & 2 deletions webots_ros2_driver/src/plugins/static/Ros2Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ namespace webots_ros2_driver {
mRecognitionIsEnabled = false;
mCamera = wb_robot_get_device(parameters["name"].c_str());

mCameraInfoSuffix = parameters.count("cameraInfoSuffix") ? parameters["cameraInfoSuffix"] : "/camera_info";
mImageSuffix = parameters.count("imageSuffix") ? parameters["imageSuffix"] : "/image_color";

assert(mCamera != 0);

// Image publisher
mImagePublisher = mNode->create_publisher<sensor_msgs::msg::Image>(mTopicName, rclcpp::SensorDataQoS().reliable());
mImagePublisher =
mNode->create_publisher<sensor_msgs::msg::Image>(mTopicName + mImageSuffix, rclcpp::SensorDataQoS().reliable());
mImageMessage.header.frame_id = mFrameName;
mImageMessage.height = wb_camera_get_height(mCamera);
mImageMessage.width = wb_camera_get_width(mCamera);
Expand All @@ -37,7 +41,7 @@ namespace webots_ros2_driver {

// CameraInfo publisher
mCameraInfoPublisher =
mNode->create_publisher<sensor_msgs::msg::CameraInfo>(mTopicName + "/camera_info", rclcpp::SensorDataQoS().reliable());
mNode->create_publisher<sensor_msgs::msg::CameraInfo>(mTopicName + mCameraInfoSuffix, rclcpp::SensorDataQoS().reliable());
mCameraInfoMessage.header.stamp = mNode->get_clock()->now();
mCameraInfoMessage.header.frame_id = mFrameName;
mCameraInfoMessage.height = wb_camera_get_height(mCamera);
Expand Down Expand Up @@ -116,6 +120,7 @@ namespace webots_ros2_driver {
auto image = wb_camera_get_image(mCamera);
if (image) {
mImageMessage.header.stamp = mNode->get_clock()->now();
mCameraInfoMessage.header.stamp = mImageMessage.header.stamp;
memcpy(mImageMessage.data.data(), image, mImageMessage.data.size());
mImagePublisher->publish(mImageMessage);
}
Expand Down
14 changes: 10 additions & 4 deletions webots_ros2_driver/src/plugins/static/Ros2RangeFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ namespace webots_ros2_driver {
mIsEnabled = false;
mRangeFinder = wb_robot_get_device(parameters["name"].c_str());

mCameraInfoSuffix = parameters.count("cameraInfoSuffix") ? parameters["cameraInfoSuffix"] : "/camera_info";
mImageSuffix = parameters.count("imageSuffix") ? parameters["imageSuffix"] : "/image";
mPointCloudSuffix = parameters.count("pointCloudSuffix") ? parameters["pointCloudSuffix"] : "/point_cloud";

assert(mRangeFinder != 0);

const int width = wb_range_finder_get_width(mRangeFinder);
const int height = wb_range_finder_get_height(mRangeFinder);

// Image publisher
mImagePublisher = mNode->create_publisher<sensor_msgs::msg::Image>(mTopicName, rclcpp::SensorDataQoS().reliable());
mImagePublisher =
mNode->create_publisher<sensor_msgs::msg::Image>(mTopicName + mImageSuffix, rclcpp::SensorDataQoS().reliable());
mImageMessage.header.frame_id = mFrameName;
mImageMessage.height = height;
mImageMessage.width = width;
Expand All @@ -42,7 +47,7 @@ namespace webots_ros2_driver {

// CameraInfo publisher
mCameraInfoPublisher =
mNode->create_publisher<sensor_msgs::msg::CameraInfo>(mTopicName + "/camera_info", rclcpp::SensorDataQoS().reliable());
mNode->create_publisher<sensor_msgs::msg::CameraInfo>(mTopicName + mCameraInfoSuffix, rclcpp::SensorDataQoS().reliable());
mCameraInfoMessage.header.stamp = mNode->get_clock()->now();
mCameraInfoMessage.header.frame_id = mFrameName;
mCameraInfoMessage.height = height;
Expand All @@ -59,8 +64,8 @@ namespace webots_ros2_driver {
1.0, 0.0};

// Point cloud publisher
mPointCloudPublisher =
mNode->create_publisher<sensor_msgs::msg::PointCloud2>(mTopicName + "/point_cloud", rclcpp::SensorDataQoS().reliable());
mPointCloudPublisher = mNode->create_publisher<sensor_msgs::msg::PointCloud2>(mTopicName + mPointCloudSuffix,
rclcpp::SensorDataQoS().reliable());
mPointCloudMessage.header.frame_id = mFrameName;
mPointCloudMessage.fields.resize(3);
mPointCloudMessage.fields[0].name = "x";
Expand Down Expand Up @@ -118,6 +123,7 @@ namespace webots_ros2_driver {
auto image = wb_range_finder_get_range_image(mRangeFinder);
if (image) {
mImageMessage.header.stamp = mNode->get_clock()->now();
mCameraInfoMessage.header.stamp = mImageMessage.header.stamp;
memcpy(mImageMessage.data.data(), image, mImageMessage.data.size());
mImagePublisher->publish(mImageMessage);
}
Expand Down
Loading