Skip to content

Commit

Permalink
Merge Iron -> Jazzy
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey committed Jun 25, 2024
1 parent 98b9d13 commit ab48047
Show file tree
Hide file tree
Showing 19 changed files with 403 additions and 79 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Install either [Edifice, Fortress, or Garden](https://gazebosim.org/docs).
Set the `GZ_VERSION` environment variable to the Gazebo version you'd
like to compile against. For example:

export GZ_VERSION=edifice
export GZ_VERSION=edifice # IMPORTANT: Replace with correct version

> You only need to set this variable when compiling, not when running.
Expand Down
14 changes: 14 additions & 0 deletions ros_gz_bridge/include/ros_gz_bridge/convert/ros_gz_interfaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ convert_gz_to_ros(
const gz::msgs::Light & gz_msg,
ros_gz_interfaces::msg::Light & ros_msg);

#if HAVE_MATERIALCOLOR
template<>
void
convert_ros_to_gz(
const ros_gz_interfaces::msg::MaterialColor & ros_msg,
gz::msgs::MaterialColor & gz_msg);

template<>
void
convert_gz_to_ros(
const gz::msgs::MaterialColor & gz_msg,
ros_gz_interfaces::msg::MaterialColor & ros_msg);
#endif // HAVE_MATERIALCOLOR

template<>
void
convert_ros_to_gz(
Expand Down
6 changes: 3 additions & 3 deletions ros_gz_bridge/ros_gz_bridge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ def ign_string(self):
return f'ignition.msgs.{self.gz_message_name}'

def ign_type(self):
# Return GZ type of a message (eg ignition::msgs::Bool)
return f'ignition::msgs::{self.gz_message_name}'
# Return GZ type of a message (eg gz::msgs::Bool)
return f'gz::msgs::{self.gz_message_name}'

def gz_string(self):
# Return GZ string version of a message (eg ignition.msgs.Bool)
return f'gz.msgs.{self.gz_message_name}'

def gz_type(self):
# Return GZ type of a message (eg ignition::msgs::Bool)
# Return GZ type of a message (eg gz::msgs::Bool)
return f'gz::msgs::{self.gz_message_name}'

def unique(self):
Expand Down
6 changes: 6 additions & 0 deletions ros_gz_bridge/ros_gz_bridge/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,9 @@
Mapping('Detection3D', 'AnnotatedOriented3DBox'),
],
}

MAPPINGS_10_1_0 = {
'ros_gz_interfaces': [
Mapping('MaterialColor', 'MaterialColor'),
],
}
2 changes: 1 addition & 1 deletion ros_gz_bridge/src/convert/gps_msgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ convert_gz_to_ros(
ros_msg.track = atan2(gz_msg.velocity_north(), gz_msg.velocity_east());
ros_msg.climb = gz_msg.velocity_up();

// position_covariance is not supported in Ignition::Msgs::NavSat.
// position_covariance is not supported in gz::msgs::NavSat.
ros_msg.position_covariance_type = gps_msgs::msg::GPSFix::COVARIANCE_TYPE_UNKNOWN;
ros_msg.status.status = gps_msgs::msg::GPSStatus::STATUS_GBAS_FIX;
}
Expand Down
64 changes: 63 additions & 1 deletion ros_gz_bridge/src/convert/ros_gz_interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,66 @@ convert_gz_to_ros(
ros_msg.intensity = gz_msg.intensity();
}

#if HAVE_MATERIALCOLOR
template<>
void
convert_ros_to_gz(
const ros_gz_interfaces::msg::MaterialColor & ros_msg,
gz::msgs::MaterialColor & gz_msg)
{
using EntityMatch = gz::msgs::MaterialColor::EntityMatch;

switch (ros_msg.entity_match) {
case ros_gz_interfaces::msg::MaterialColor::FIRST:
gz_msg.set_entity_match(EntityMatch::MaterialColor_EntityMatch_FIRST);
break;
case ros_gz_interfaces::msg::MaterialColor::ALL:
gz_msg.set_entity_match(EntityMatch::MaterialColor_EntityMatch_ALL);
break;
default:
std::cerr << "Unsupported entity match type ["
<< ros_msg.entity_match << "]\n";
}

convert_ros_to_gz(ros_msg.header, (*gz_msg.mutable_header()));
convert_ros_to_gz(ros_msg.entity, *gz_msg.mutable_entity());
convert_ros_to_gz(ros_msg.ambient, *gz_msg.mutable_ambient());
convert_ros_to_gz(ros_msg.diffuse, *gz_msg.mutable_diffuse());
convert_ros_to_gz(ros_msg.specular, *gz_msg.mutable_specular());
convert_ros_to_gz(ros_msg.emissive, *gz_msg.mutable_emissive());

gz_msg.set_shininess(ros_msg.shininess);
}

template<>
void
convert_gz_to_ros(
const gz::msgs::MaterialColor & gz_msg,
ros_gz_interfaces::msg::MaterialColor & ros_msg)
{
using EntityMatch = gz::msgs::MaterialColor::EntityMatch;
if (gz_msg.entity_match() == EntityMatch::MaterialColor_EntityMatch_FIRST) {
ros_msg.entity_match = ros_gz_interfaces::msg::MaterialColor::FIRST;
/* *INDENT-OFF* */
} else if (gz_msg.entity_match() ==
EntityMatch::MaterialColor_EntityMatch_ALL) {
/* *INDENT-ON* */
ros_msg.entity_match = ros_gz_interfaces::msg::MaterialColor::ALL;
} else {
std::cerr << "Unsupported EntityMatch [" <<
gz_msg.entity_match() << "]" << std::endl;
}
convert_gz_to_ros(gz_msg.header(), ros_msg.header);
convert_gz_to_ros(gz_msg.entity(), ros_msg.entity);
convert_gz_to_ros(gz_msg.ambient(), ros_msg.ambient);
convert_gz_to_ros(gz_msg.diffuse(), ros_msg.diffuse);
convert_gz_to_ros(gz_msg.specular(), ros_msg.specular);
convert_gz_to_ros(gz_msg.emissive(), ros_msg.emissive);

ros_msg.shininess = gz_msg.shininess();
}
#endif // HAVE_MATERIALCOLOR

template<>
void
convert_ros_to_gz(
Expand Down Expand Up @@ -413,7 +473,9 @@ convert_gz_to_ros(
ros_msg.type = 0;
} else if (gz_msg.type() == gz::msgs::SensorNoise_Type::SensorNoise_Type_GAUSSIAN) {
ros_msg.type = 2;
} else if (gz_msg.type() == gz::msgs::SensorNoise_Type::SensorNoise_Type_GAUSSIAN_QUANTIZED) {
} else if (gz_msg.type() == // NOLINT
gz::msgs::SensorNoise_Type::SensorNoise_Type_GAUSSIAN_QUANTIZED) // NOLINT
{ // NOLINT
ros_msg.type = 3;
}

Expand Down
2 changes: 1 addition & 1 deletion ros_gz_bridge/src/convert/sensor_msgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ convert_gz_to_ros(
ros_msg.longitude = gz_msg.longitude_deg();
ros_msg.altitude = gz_msg.altitude();

// position_covariance is not supported in Ignition::Msgs::NavSat.
// position_covariance is not supported in gz::msgs::NavSat.
ros_msg.position_covariance_type = sensor_msgs::msg::NavSatFix::COVARIANCE_TYPE_UNKNOWN;
ros_msg.status.status = sensor_msgs::msg::NavSatStatus::STATUS_FIX;
}
Expand Down
31 changes: 31 additions & 0 deletions ros_gz_bridge/test/utils/gz_test_msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,37 @@ void compareTestMsg(const std::shared_ptr<gz::msgs::Light> & _msg)
EXPECT_FLOAT_EQ(expected_msg.intensity(), _msg->intensity());
}

#if HAVE_MATERIALCOLOR
void createTestMsg(gz::msgs::MaterialColor & _msg)
{
createTestMsg(*_msg.mutable_header());
createTestMsg(*_msg.mutable_entity());
createTestMsg(*_msg.mutable_ambient());
createTestMsg(*_msg.mutable_diffuse());
createTestMsg(*_msg.mutable_specular());
createTestMsg(*_msg.mutable_emissive());

_msg.set_shininess(1.0);
_msg.set_entity_match(gz::msgs::MaterialColor::EntityMatch::MaterialColor_EntityMatch_ALL);
}

void compareTestMsg(const std::shared_ptr<gz::msgs::MaterialColor> & _msg)
{
gz::msgs::MaterialColor expected_msg;
createTestMsg(expected_msg);

compareTestMsg(std::make_shared<gz::msgs::Header>(_msg->header()));
compareTestMsg(std::make_shared<gz::msgs::Entity>(_msg->entity()));
compareTestMsg(std::make_shared<gz::msgs::Color>(_msg->ambient()));
compareTestMsg(std::make_shared<gz::msgs::Color>(_msg->diffuse()));
compareTestMsg(std::make_shared<gz::msgs::Color>(_msg->specular()));
compareTestMsg(std::make_shared<gz::msgs::Color>(_msg->emissive()));

EXPECT_EQ(expected_msg.shininess(), _msg->shininess());
EXPECT_EQ(expected_msg.entity_match(), _msg->entity_match());
}
#endif // HAVE_MATERIALCOLOR

void createTestMsg(gz::msgs::GUICamera & _msg)
{
gz::msgs::Header header_msg;
Expand Down
15 changes: 15 additions & 0 deletions ros_gz_bridge/test/utils/gz_test_msg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <gz/msgs/entity.pb.h>
#include <gz/msgs/dataframe.pb.h>
#include <gz/msgs/float.pb.h>
#include <gz/msgs/float_v.pb.h>
#include <gz/msgs/fluid_pressure.pb.h>
#include <gz/msgs/gui_camera.pb.h>
#include <gz/msgs/header.pb.h>
Expand Down Expand Up @@ -71,6 +72,10 @@

#include <ros_gz_bridge/ros_gz_bridge.hpp>

#if HAVE_MATERIALCOLOR
#include <gz/msgs/material_color.pb.h>
#endif // HAVE_MATERIALCOLOR

namespace ros_gz_bridge
{
namespace testing
Expand Down Expand Up @@ -451,6 +456,16 @@ void createTestMsg(gz::msgs::Light & _msg);
/// \param[in] _msg The message to compare.
void compareTestMsg(const std::shared_ptr<gz::msgs::Light> & _msg);

#if HAVE_MATERIALCOLOR
/// \brief Create a message used for testing.
/// \param[out] _msg The message populated.
void createTestMsg(gz::msgs::MaterialColor & _msg);

/// \brief Compare a message with the populated for testing.
/// \param[in] _msg The message to compare.
void compareTestMsg(const std::shared_ptr<gz::msgs::MaterialColor> & _msg);
#endif // HAVE_MATERIALCOLOR

/// \brief Create a message used for testing.
/// \param[out] _msg The message populated.
void createTestMsg(gz::msgs::GUICamera & _msg);
Expand Down
30 changes: 30 additions & 0 deletions ros_gz_bridge/test/utils/ros_test_msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,36 @@ void compareTestMsg(const std::shared_ptr<ros_gz_interfaces::msg::Light> & _msg)
EXPECT_FLOAT_EQ(expected_msg.intensity, _msg->intensity);
}

#if HAVE_MATERIALCOLOR
void createTestMsg(ros_gz_interfaces::msg::MaterialColor & _msg)
{
createTestMsg(_msg.header);
createTestMsg(_msg.entity);
createTestMsg(_msg.ambient);
createTestMsg(_msg.diffuse);
createTestMsg(_msg.specular);
createTestMsg(_msg.emissive);
_msg.shininess = 1.0;
_msg.entity_match = ros_gz_interfaces::msg::MaterialColor::ALL;
}

void compareTestMsg(const std::shared_ptr<ros_gz_interfaces::msg::MaterialColor> & _msg)
{
ros_gz_interfaces::msg::MaterialColor expected_msg;
createTestMsg(expected_msg);

compareTestMsg(_msg->header);
compareTestMsg(std::make_shared<ros_gz_interfaces::msg::Entity>(_msg->entity));
compareTestMsg(std::make_shared<std_msgs::msg::ColorRGBA>(_msg->ambient));
compareTestMsg(std::make_shared<std_msgs::msg::ColorRGBA>(_msg->diffuse));
compareTestMsg(std::make_shared<std_msgs::msg::ColorRGBA>(_msg->specular));
compareTestMsg(std::make_shared<std_msgs::msg::ColorRGBA>(_msg->emissive));

EXPECT_EQ(expected_msg.shininess, _msg->shininess);
EXPECT_EQ(expected_msg.entity_match, _msg->entity_match);
}
#endif // HAVE_MATERIALCOLOR

void createTestMsg(ros_gz_interfaces::msg::GuiCamera & _msg)
{
createTestMsg(_msg.header);
Expand Down
13 changes: 13 additions & 0 deletions ros_gz_bridge/test/utils/ros_test_msg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
#include <ros_gz_interfaces/msg/float32_array.hpp>
#include <ros_gz_interfaces/msg/dataframe.hpp>
#include <ros_gz_interfaces/msg/light.hpp>
#if HAVE_MATERIALCOLOR
#include <ros_gz_interfaces/msg/material_color.hpp>
#endif // HAVE_MATERIALCOLOR
#include <ros_gz_interfaces/msg/param_vec.hpp>
#include <ros_gz_interfaces/msg/sensor_noise.hpp>
#include <ros_gz_interfaces/msg/string_vec.hpp>
Expand Down Expand Up @@ -408,6 +411,16 @@ void createTestMsg(ros_gz_interfaces::msg::Light & _msg);
/// \param[in] _msg The message to compare.
void compareTestMsg(const std::shared_ptr<ros_gz_interfaces::msg::Light> & _msg);

#if HAVE_MATERIALCOLOR
/// \brief Create a message used for testing.
/// \param[out] _msg The message populated.
void createTestMsg(ros_gz_interfaces::msg::MaterialColor & _msg);

/// \brief Compare a message with the populated for testing.
/// \param[in] _msg The message to compare.
void compareTestMsg(const std::shared_ptr<ros_gz_interfaces::msg::MaterialColor> & _msg);
#endif // HAVE_MATERIALCOLOR

/// \brief Create a message used for testing.
/// \param[out] _msg The message populated.
void createTestMsg(ros_gz_interfaces::msg::Entity & _msg);
Expand Down
2 changes: 1 addition & 1 deletion ros_gz_image/test/publishers/gz_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int main(int /*argc*/, char **/*argv*/)
gz::transport::Node node;

// gz::msgs::Image.
auto image_pub = node.Advertise<ignition::msgs::Image>("image");
auto image_pub = node.Advertise<gz::msgs::Image>("image");
gz::msgs::Image image_msg;
ros_gz_image::testing::createTestMsg(image_msg);

Expand Down
18 changes: 9 additions & 9 deletions ros_gz_image/test/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <chrono>
#include <string>
#include <thread>
#include <ignition/msgs.hh>
#include <gz/msgs.hh>

namespace ros_gz_image
{
Expand Down Expand Up @@ -142,7 +142,7 @@ namespace testing

/// \brief Create a message used for testing.
/// \param[out] _msg The message populated.
void createTestMsg(ignition::msgs::Header &_msg)
void createTestMsg(gz::msgs::Header &_msg)
{
auto seq_entry = _msg.add_data();
seq_entry->set_key("seq");
Expand All @@ -156,9 +156,9 @@ namespace testing

/// \brief Compare a message with the populated for testing.
/// \param[in] _msg The message to compare.
void compareTestMsg(const ignition::msgs::Header &_msg)
void compareTestMsg(const gz::msgs::Header &_msg)
{
ignition::msgs::Header expected_msg;
gz::msgs::Header expected_msg;
createTestMsg(expected_msg);

EXPECT_EQ(expected_msg.stamp().sec(), _msg.stamp().sec());
Expand All @@ -183,24 +183,24 @@ namespace testing

/// \brief Create a message used for testing.
/// \param[out] _msg The message populated.
void createTestMsg(ignition::msgs::Image &_msg)
void createTestMsg(gz::msgs::Image &_msg)
{
ignition::msgs::Header header_msg;
gz::msgs::Header header_msg;
createTestMsg(header_msg);

_msg.mutable_header()->CopyFrom(header_msg);
_msg.set_width(320);
_msg.set_height(240);
_msg.set_pixel_format_type(ignition::msgs::PixelFormatType::RGB_INT8);
_msg.set_pixel_format_type(gz::msgs::PixelFormatType::RGB_INT8);
_msg.set_step(_msg.width() * 3);
_msg.set_data(std::string(_msg.height() * _msg.step(), '1'));
}

/// \brief Compare a message with the populated for testing.
/// \param[in] _msg The message to compare.
void compareTestMsg(const ignition::msgs::Image &_msg)
void compareTestMsg(const gz::msgs::Image &_msg)
{
ignition::msgs::Image expected_msg;
gz::msgs::Image expected_msg;
createTestMsg(expected_msg);

compareTestMsg(_msg.header());
Expand Down
1 change: 1 addition & 0 deletions ros_gz_interfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set(msg_files
"msg/GuiCamera.msg"
"msg/JointWrench.msg"
"msg/Light.msg"
"msg/MaterialColor.msg"
"msg/ParamVec.msg"
"msg/SensorNoise.msg"
"msg/StringVec.msg"
Expand Down
12 changes: 12 additions & 0 deletions ros_gz_interfaces/msg/MaterialColor.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Entities that match to apply material color: constant definition
uint8 FIRST = 0
uint8 ALL = 1

std_msgs/Header header # Optional header data
ros_gz_interfaces/Entity entity # Entity to change material color
std_msgs/ColorRGBA ambient # Ambient color
std_msgs/ColorRGBA diffuse # Diffuse color
std_msgs/ColorRGBA specular # Specular color
std_msgs/ColorRGBA emissive # Emissive color
float64 shininess # Specular exponent
uint8 entity_match # Entities that match to apply material color
Loading

0 comments on commit ab48047

Please sign in to comment.