-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
add XBow AHRS ROS2 plugin #41
Conversation
Signed-off-by: Michael Anderson <anderson@mbari.org>
Signed-off-by: Michael Anderson <anderson@mbari.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏽
xb_record_.imu.angular_velocity.z = _imu.angular_velocity().z(); | ||
xb_record_.imu.linear_acceleration.x = _imu.linear_acceleration().x(); | ||
xb_record_.imu.linear_acceleration.y = _imu.linear_acceleration().y(); | ||
xb_record_.imu.linear_acceleration.z = _imu.linear_acceleration().z(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have some helper functions to do these conversions in ros_ign_bridge
. I was curious to see whether it would be usable here and it worked like this:
diff
diff --git a/buoy_gazebo/CMakeLists.txt b/buoy_gazebo/CMakeLists.txt
index 3af2b97..052cebc 100644
--- a/buoy_gazebo/CMakeLists.txt
+++ b/buoy_gazebo/CMakeLists.txt
@@ -3,6 +3,7 @@ project(buoy_gazebo)
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
+find_package(ros_ign_bridge REQUIRED)
find_package(buoy_msgs REQUIRED)
find_package(ignition-cmake2 REQUIRED)
@@ -57,7 +58,7 @@ function(gz_add_plugin plugin_name)
${gz_add_plugin_PRIVATE_LINK_LIBS}
)
if(gz_add_plugin_ROS)
- ament_target_dependencies(${plugin_name} PUBLIC rclcpp buoy_msgs)
+ ament_target_dependencies(${plugin_name} PUBLIC rclcpp ros_ign_bridge buoy_msgs)
endif()
target_include_directories(${plugin_name}
PUBLIC ${gz_add_plugin_INCLUDE_DIRS})
diff --git a/buoy_gazebo/package.xml b/buoy_gazebo/package.xml
index 05fe4dd..be544da 100644
--- a/buoy_gazebo/package.xml
+++ b/buoy_gazebo/package.xml
@@ -14,6 +14,7 @@
<depend>buoy_examples</depend>
<depend>buoy_msgs</depend>
<depend>ignition-gazebo6</depend>
+ <depend>ros_ign_bridge</depend>
<depend>ros_ign_gazebo</depend>
<test_depend>ament_lint_auto</test_depend>
diff --git a/buoy_gazebo/src/controllers/XBowAHRS/XBowAHRS.cpp b/buoy_gazebo/src/controllers/XBowAHRS/XBowAHRS.cpp
index 9f8172e..8b03206 100644
--- a/buoy_gazebo/src/controllers/XBowAHRS/XBowAHRS.cpp
+++ b/buoy_gazebo/src/controllers/XBowAHRS/XBowAHRS.cpp
@@ -23,6 +23,7 @@
#include <ignition/transport/Node.hh>
#include <rclcpp/rclcpp.hpp>
+#include <ros_ign_bridge/convert/sensor_msgs.hpp>
#include <buoy_msgs/msg/xb_record.hpp>
#include <sensor_msgs/msg/imu.hpp>
@@ -57,16 +58,7 @@ struct buoy_gazebo::XBowAHRSPrivate
xb_record_.header.stamp.nanosec = _imu.header().stamp().nsec();
xb_record_.header.frame_id = "Buoy";
xb_record_.imu.header = xb_record_.header;
- xb_record_.imu.orientation.x = _imu.orientation().x();
- xb_record_.imu.orientation.y = _imu.orientation().y();
- xb_record_.imu.orientation.z = _imu.orientation().z();
- xb_record_.imu.orientation.w = _imu.orientation().w();
- xb_record_.imu.angular_velocity.x = _imu.angular_velocity().x();
- xb_record_.imu.angular_velocity.y = _imu.angular_velocity().y();
- xb_record_.imu.angular_velocity.z = _imu.angular_velocity().z();
- xb_record_.imu.linear_acceleration.x = _imu.linear_acceleration().x();
- xb_record_.imu.linear_acceleration.y = _imu.linear_acceleration().y();
- xb_record_.imu.linear_acceleration.z = _imu.linear_acceleration().z();
+ ros_ign_bridge::convert_ign_to_ros(_imu, xb_record_.imu);
}
bool data_valid() const
I don't think it's necessarily worth the added dependency, but it's something to keep in mind for future messages.
addresses part of #30
passes
colcon test