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 master into develop #524

Merged
merged 17 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ It integrates with ROS2 using ROS2 messages, services and actions.

Please visit the [documentation](https://github.com/cyberbotics/webots_ros2/wiki) that contains the following sections:
- [Getting Started](https://github.com/cyberbotics/webots_ros2/wiki/Getting-Started)
- [Build and Install](https://github.com/cyberbotics/webots_ros2/wiki/Build-and-Install)
- [Complete Installation Guide](https://github.com/cyberbotics/webots_ros2/wiki/Complete-Installation-Guide)
- [Tutorials](https://github.com/cyberbotics/webots_ros2/wiki/Tutorials)
- [Examples](https://github.com/cyberbotics/webots_ros2/wiki/Examples)
- [References](https://github.com/cyberbotics/webots_ros2/wiki/References)
Expand Down
15 changes: 15 additions & 0 deletions webots_ros2/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
Changelog for package webots_ros2
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2022.1.4 (2022-11-18)
------------------
* Fix the camera focal length in the CameraInfo topic.
* Upgraded to urdf2webots 2.0.3
* Update the calculation of CameraRecognitionObject messages to the RDF convention of R2022b.

2022.1.3 (2022-11-02)
------------------
* Added macOS support.
* Added reset handler to all examples to support simulation reset from Webots.

2022.1.2 (2022-10-21)
------------------
* Added WSL support.

2022.1.0 (2022-09-23)
------------------
* Adapted controllers to communicate with Webots R2022b.
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>2022.1.2</version>
<version>2022.1.4</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='2022.1.2',
version='2022.1.4',
packages=[package_name],
data_files=[
('share/' + package_name, ['package.xml']),
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>2022.1.2</version>
<version>2022.1.4</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
2 changes: 1 addition & 1 deletion webots_ros2_core/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_core</name>
<version>2022.1.2</version>
<version>2022.1.4</version>
<description>Core interface between Webots and ROS2</description>

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

setup(
name=package_name,
version='2022.1.2',
version='2022.1.4',
packages=[package_name, package_name + '.devices', package_name + '.math', package_name + '.webots'],
data_files=data_files,
install_requires=['setuptools', 'launch'],
Expand Down
13 changes: 13 additions & 0 deletions webots_ros2_driver/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@
Changelog for package webots_ros2_driver
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2022.1.4 (2022-11-18)
------------------
* Fix the camera focal length in the CameraInfo topic.
* Update the calculation of CameraRecognitionObject messages to the RDF convention of R2022b.

2022.1.3 (2022-11-02)
------------------
* Added macOS support.

2022.1.2 (2022-10-21)
------------------
* Fix issue where relatively defined PROTO were not found.
* Added WSL support.

2022.1.1 (2022-10-11)
------------------
* Simplified the detection of Webots installation folder.

2022.1.0 (2022-09-23)
------------------
* Added an URDF importer feature to spawn robots from URDF files.
Expand Down
3 changes: 3 additions & 0 deletions webots_ros2_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ find_package(rclcpp REQUIRED)
find_package(pluginlib REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(vision_msgs REQUIRED)
find_package(webots_ros2_msgs REQUIRED)
Expand Down Expand Up @@ -137,6 +138,7 @@ ament_target_dependencies(driver
pluginlib
sensor_msgs
std_msgs
tf2_geometry_msgs
tf2_ros
vision_msgs
webots_ros2_msgs
Expand Down Expand Up @@ -258,6 +260,7 @@ ament_export_dependencies(
rclpy
sensor_msgs
std_msgs
tf2_geometry_msgs
tf2_ros
vision_msgs
webots_ros2_msgs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <geometry_msgs/msg/quaternion.hpp>
#include <geometry_msgs/msg/point.hpp>
#include <geometry_msgs/msg/transform_stamped.hpp>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
#include <sensor_msgs/image_encodings.hpp>
#include <sensor_msgs/msg/camera_info.hpp>
#include <sensor_msgs/msg/image.hpp>
Expand Down
3 changes: 2 additions & 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>2022.1.2</version>
<version>2022.1.4</version>
<description>Implementation of the Webots - ROS 2 interface</description>
<maintainer email="[email protected]">Cyberbotics</maintainer>
<license>Apache License 2.0</license>
Expand All @@ -21,6 +21,7 @@
<depend>sensor_msgs</depend>
<depend>std_msgs</depend>
<depend>geometry_msgs</depend>
<depend>tf2_geometry_msgs</depend>
<depend>tf2_ros</depend>
<depend>vision_msgs</depend>
<depend>tinyxml2_vendor</depend>
Expand Down
30 changes: 17 additions & 13 deletions webots_ros2_driver/src/plugins/static/Ros2Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ namespace webots_ros2_driver
mCameraInfoMessage.distortion_model = "plumb_bob";

// Convert FoV to focal length.
// Reference: https://en.wikipedia.org/wiki/Focal_length#In_photography
const double diagonal = sqrt(pow(mCamera->getWidth(), 2) + pow(mCamera->getHeight(), 2));
const double focalLength = 0.5 * diagonal * (cos(0.5 * mCamera->getFov()) / sin(0.5 * mCamera->getFov()));
const double focalLength = mCamera->getWidth() / (2 * tan(mCamera->getFov() / 2));

mCameraInfoMessage.d = {0.0, 0.0, 0.0, 0.0, 0.0};
mCameraInfoMessage.r = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
Expand Down Expand Up @@ -138,18 +136,25 @@ namespace webots_ros2_driver
for (size_t i = 0; i < mCamera->getRecognitionNumberOfObjects(); i++)
{
// Getting Object Info
geometry_msgs::msg::Point position;
geometry_msgs::msg::Quaternion orientation;
position.x = objects[i].position[0];
position.y = objects[i].position[1];
position.z = objects[i].position[2];
axisAngleToQuaternion(objects[i].orientation, orientation);
geometry_msgs::msg::PoseStamped pose;
pose.pose.position.x = objects[i].position[0];
pose.pose.position.y = objects[i].position[1];
pose.pose.position.z = objects[i].position[2];
axisAngleToQuaternion(objects[i].orientation, pose.pose.orientation);

// Transform to ROS camera coordinate frame
// rpy = (0, pi/2, -pi/2)
geometry_msgs::msg::TransformStamped transform;
transform.transform.rotation.x = 0.5;
transform.transform.rotation.y = -0.5;
transform.transform.rotation.z = 0.5;
transform.transform.rotation.w = 0.5;
tf2::doTransform(pose, pose, transform);

// Object Info -> Detection2D
vision_msgs::msg::Detection2D detection;
vision_msgs::msg::ObjectHypothesisWithPose hypothesis;
hypothesis.pose.pose.position = position;
hypothesis.pose.pose.orientation = orientation;
hypothesis.pose.pose = pose.pose;
detection.results.push_back(hypothesis);
#if FOXY || GALACTIC
detection.bbox.center.x = objects[i].position_on_image[0];
Expand All @@ -166,8 +171,7 @@ namespace webots_ros2_driver
webots_ros2_msgs::msg::CameraRecognitionObject recognitionWebotsObject;
recognitionWebotsObject.id = objects[i].id;
recognitionWebotsObject.model = std::string(objects[i].model);
recognitionWebotsObject.pose.pose.position = position;
recognitionWebotsObject.pose.pose.orientation = orientation;
recognitionWebotsObject.pose = pose;
#if FOXY || GALACTIC
recognitionWebotsObject.bbox.center.x = objects[i].position_on_image[0];
recognitionWebotsObject.bbox.center.y = objects[i].position_on_image[1];
Expand Down
5 changes: 5 additions & 0 deletions webots_ros2_epuck/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog for package webots_ros2_epuck
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2022.1.3 (2022-11-02)
------------------
* Added macOS support.
* Added reset handler to support simulation reset from Webots.

2022.1.2 (2022-10-21)
------------------
* Added WSL support.
Expand Down
59 changes: 41 additions & 18 deletions webots_ros2_epuck/launch/robot_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,11 @@
from webots_ros2_driver.utils import controller_url_prefix


def generate_launch_description():
def get_ros2_nodes(*args):
package_dir = get_package_share_directory('webots_ros2_epuck')
world = LaunchConfiguration('world')
robot_description = pathlib.Path(os.path.join(package_dir, 'resource', 'epuck_webots.urdf')).read_text()
ros2_control_params = os.path.join(package_dir, 'resource', 'ros2_control.yml')
use_sim_time = LaunchConfiguration('use_sim_time', default=True)

webots = WebotsLauncher(
world=PathJoinSubstitution([package_dir, 'worlds', world])
)

ros2_supervisor = Ros2SupervisorLauncher()

controller_manager_timeout = ['--controller-manager-timeout', '50']
controller_manager_prefix = 'python.exe' if os.name == 'nt' else ''

Expand Down Expand Up @@ -112,6 +104,35 @@ def generate_launch_description():
arguments=['0', '0', '0', '0', '0', '0', 'base_link', 'base_footprint'],
)

return [
joint_state_broadcaster_spawner,
diffdrive_controller_spawner,
robot_state_publisher,
epuck_driver,
footprint_publisher,
epuck_process,
]


def generate_launch_description():
package_dir = get_package_share_directory('webots_ros2_epuck')
world = LaunchConfiguration('world')

webots = WebotsLauncher(
world=PathJoinSubstitution([package_dir, 'worlds', world])
)

ros2_supervisor = Ros2SupervisorLauncher()

# The following line is important!
# This event handler respawns the ROS 2 nodes on simulation reset (supervisor process ends).
reset_handler = launch.actions.RegisterEventHandler(
event_handler=launch.event_handlers.OnProcessExit(
target_action=ros2_supervisor,
on_exit=get_ros2_nodes,
)
)

return LaunchDescription([
DeclareLaunchArgument(
'world',
Expand All @@ -120,18 +141,20 @@ def generate_launch_description():
),
webots,
ros2_supervisor,
joint_state_broadcaster_spawner,
diffdrive_controller_spawner,
robot_state_publisher,
epuck_driver,
footprint_publisher,
epuck_process,

# This action will kill all nodes once the Webots simulation has exited
launch.actions.RegisterEventHandler(
event_handler=launch.event_handlers.OnProcessExit(
target_action=webots,
on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())],
on_exit=[
launch.actions.UnregisterEventHandler(
event_handler=reset_handler.event_handler
),
launch.actions.EmitEvent(event=launch.events.Shutdown())
],
)
)
])
),

# Add the reset event handler
reset_handler
] + get_ros2_nodes())
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>2022.1.2</version>
<version>2022.1.4</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='2022.1.2',
version='2022.1.4',
packages=[package_name],
data_files=data_files,
install_requires=['setuptools', 'launch'],
Expand Down
4 changes: 4 additions & 0 deletions webots_ros2_importer/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Changelog for package webots_ros2_importer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2022.1.4 (2022-11-18)
------------------
* Upgraded to urdf2webots 2.0.3

2022.1.1 (2022-10-11)
------------------
* Upgraded to urdf2webots 2.0.2
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>2022.1.2</version>
<version>2022.1.4</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='2022.1.2',
version='2022.1.4',
packages=[package_name, package_name + '.urdf2webots.urdf2webots'],
data_files=data_files,
install_requires=[
Expand Down
Loading