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

Code cleanup #485

Merged
merged 1 commit into from
Feb 17, 2025
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 Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@
* [Pull request #241](https://github.com/gazebosim/gz-msgs/pull/241)
* [Pull request #298](https://github.com/gazebosim/gz-msgs/pull/298)

1. Remove redunant namespace references
1. Remove redundant namespace references
* [Pull request #293](https://github.com/gazebosim/gz-msgs/pull/293)

### Gazebo Msgs 8.6.0 (2022-08-02)
Expand Down
2 changes: 1 addition & 1 deletion Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ release will remove the deprecated code.
3. Protobuf messages and packages will no longer use `ignition.msgs`, use `gz.msgs` instead
4. `INSTALL_IGN_MSGS_GEN_EXECUTABLE` and `IGN_MSGS_GEN_EXECUTABLE` are deprecated and will be removed. Use `INSTALL_GZ_MSGS_GEN_EXECUTABLE` and `GZ_MSGS_GEN_EXECUTABLE` instead.
5. `IGN_DESCRIPTOR_PATH` is deprecated and will be removed. Use `GZ_DESCRIPTOR_PATH` instead.
6. `camerasensor.proto` has deprected the `string image_format = 4`. Please
6. `camerasensor.proto` has deprecated the `string image_format = 4`. Please
use `PixelFormatType pixel_format = 21;`
### Breaking Changes

Expand Down
12 changes: 6 additions & 6 deletions cmake/gz_msgs_generate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
# One value arguments:
# PYTHON_INTERPRETER - Target or path to the python interpreter used
# PROTO_PACKAGE - Protobuf package the file belongs to (e.g. "gz.msgs")
# MSGS_GEN_SCRIPT - Location of the messge generator script
# MSGS_GEN_SCRIPT - Location of the message generator script
# GZ_PROTOC_PLUGIN - Location of the gazebo generator plugin
# FACTORY_GEN_SCRIPT - Location of the factory generator script
# PROTO_PATH - Base directory of the proto files
# DEPENDENCY_DESCRIPTIONS - .gz_desc files for each dependency
# DLLEXPORT_DECL - Visibilty macro to apply to messages
# OUTPUT_DIRECTORY - CMake binary directoy to place generated artifacts
# DLLEXPORT_DECL - Visibility macro to apply to messages
# OUTPUT_DIRECTORY - CMake binary directory to place generated artifacts
# OUTPUT_SOURCES - Variable to contain list of generated source files
# OUTPUT_HEADERS - Variable to contain list of generated header files
# OUTPUT_DETAIL_HEADERS - Variable to contain list of generated detail header files
Expand Down Expand Up @@ -133,7 +133,7 @@ function(gz_msgs_generate_messages_impl)

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Disable warning in generated *.pb.cc code
set_source_files_properties(${${generate_messges_OUTPUT_SOURCES}}
set_source_files_properties(${${generate_messages_OUTPUT_SOURCES}}
COMPILE_FLAGS "-Wno-invalid-offsetof")
endif()

Expand All @@ -148,7 +148,7 @@ endfunction()
# One value arguments:
# PROTOC_EXEC - protoc target or executable to use
# PROTO_PATH - Base directory of the proto files
# DEPENDENCY_DESCRIPTIONS - Variable containing all depedency description files
# DEPENDENCY_DESCRIPTIONS - Variable containing all dependency description files
# OUTPUT_DIRECTORY - Directory of output gz_desc file
# OUTPUT_FILENAME - Name of output gz_desc file
# Multi value arguments
Expand Down Expand Up @@ -196,7 +196,7 @@ endfunction()
# One value arguments:
# TARGET - Target (static library) to create
# PROTO_PACKAGE - Protobuf package the file belongs to (e.g. "gz.msgs")
# MSGS_GEN_SCRIPT - Location of the messge generator script
# MSGS_GEN_SCRIPT - Location of the message generator script
# PYTHON_INTERPRETER - Target or path to the python interpreter used
# PROTOC_EXEC - Protoc target or executable to use
# GZ_PROTOC_PLUGIN - Location of the gazebo generator plugin
Expand Down
6 changes: 3 additions & 3 deletions core/generator/Generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ Generator::~Generator() = default;

/////////////////////////////////////////////////
bool Generator::Generate(const FileDescriptor *_file,
const std::string &/*_parameter*/,
OutputDirectory *_generatorContext,
std::string * /*_error*/) const
const std::string &/*_parameter*/,
OutputDirectory *_generatorContext,
std::string * /*_error*/) const
{
auto filePath = std::filesystem::path(_file->name());
auto parent_path = filePath.parent_path();
Expand Down
4 changes: 2 additions & 2 deletions core/include/gz/msgs/Factory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace gz::msgs
/// \brief A map of message types as strings to factory functions
public: using FactoryFnCollection = MessageFactory::FactoryFnCollection;

/// \brief Private constuctor
/// \brief Private constructor
private: Factory() = default;

/// \brief Deleted copy constructor
Expand Down Expand Up @@ -113,7 +113,7 @@ namespace gz::msgs
public: static void Types(std::vector<std::string> &_types);

/// \brief Load a collection of descriptor .desc files.
/// \param[in] _paths A set of directories containing .desc decriptor
/// \param[in] _paths A set of directories containing .desc descriptor
/// files. Each directory should be separated by ":".
public: static void LoadDescriptors(const std::string &_paths);
};
Expand Down
2 changes: 1 addition & 1 deletion core/include/gz/msgs/MessageFactory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace gz::msgs {
public: void Types(std::vector<std::string> &_types);

/// \brief Load a collection of descriptor .desc files.
/// \param[in] _paths A set of directories containing .desc decriptor
/// \param[in] _paths A set of directories containing .desc descriptor
/// files. Each directory should be separated by ":".
public: void LoadDescriptors(const std::string &_paths);

Expand Down
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/AxisAlignedBox.hh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ inline gz::math::AxisAlignedBox Convert(const gz::msgs::AxisAlignedBox &_msg)
Set(&ret, _msg);
return ret;
}
} // namespce
} // namespace
} // namespace gz::msgs

#endif // GZ_MSGS_CONVERT_VECTOR3_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/Color.hh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ inline gz::math::Color Convert(const gz::msgs::Color &_msg)
Set(&ret, _msg);
return ret;
}
} // namespce
} // namespace
} // namespace gz::msgs

#endif // GZ_MSGS_CONVERT_VECTOR3_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/DiscoveryType.hh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ inline std::string ToString(const msgs::Discovery::Type &_t)
{
return ConvertDiscoveryType(_t);
}
} // namespce
} // namespace
} // namespace gz::msgs

#endif // GZ_MSGS_CONVERT_DISCOVERYTYPE_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/FuelMetadata.hh
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ inline bool ConvertFuelMetadata(const msgs::FuelMetadata &_meta,
_modelConfigStr = out.str();
return true;
}
} // namespce
} // namespace
} // namespace gz::msgs

#endif // GZ_MSGS_CONVERT_FUELMETADATA_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/GeometryType.hh
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ inline std::string ConvertGeometryType(const msgs::Geometry::Type _type)
}
return result;
}
} // namespce
} // namespace
} // namespace gz::msgs

#endif // GZ_MSGS_CONVERT_GEOMETRYTYPE_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/Inertial.hh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,6 @@ inline gz::math::Inertiald Convert(const gz::msgs::Inertial &_msg)
Set(&ret, _msg);
return ret;
}
} // namespce
} // namespace
} // namespace gz::msgs
#endif // GZ_MSGS_CONVERT_VECTOR3_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/JointType.hh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ inline std::string ConvertJointType(const msgs::Joint::Type &_type)
return result;
}

} // namespce
} // namespace
} // namespace gz::msgs

#endif // GZ_MSGS_CONVERT_JOINTTYPE_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/PixelFormatType.hh
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ inline std::string ConvertPixelFormatType(const msgs::PixelFormatType &_t)
}


} // namespce
} // namespace
} // namespace gz::msgs

#endif // GZ_MSGS_CONVERT_PIXELFORMATTYPE_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/Plane.hh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ inline gz::math::Planed Convert(const gz::msgs::PlaneGeom &_msg)
Set(&ret, _msg);
return ret;
}
} // namespce
} // namespace
} // namespace gz::msgs

#endif // GZ_MSGS_CONVERT_VECTOR3_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/Pose.hh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ inline gz::math::Pose3d Convert(const gz::msgs::Pose &_msg)
Set(&ret, _msg);
return ret;
}
} // namespce
} // namespace
} // namespace gz::msgs

#endif // GZ_MSGS_CONVERT_VECTOR3_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/Quaternion.hh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ inline gz::math::Quaterniond Convert(const gz::msgs::Quaternion &_msg)
Set(&ret, _msg);
return ret;
}
} // namespce
} // namespace
} // namespace gz::msgs

#endif // GZ_MSGS_CONVERT_VECTOR3_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/ShaderType.hh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ inline std::string ConvertShaderType(const msgs::Material::ShaderType &_type)
return result;
}

} // namespce
} // namespace
} // namespace gz::msgs

#endif // GZ_MSGS_CONVERT_SHADERTYPE_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/SphericalCoordinates.hh
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,6 @@ inline gz::math::SphericalCoordinates
Set(&ret, _msg);
return ret;
}
} // namespce
} // namespace
} // namespace gz::msgs
#endif // GZ_MSGS_CONVERT_VECTOR3_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/StdTypes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,6 @@ inline double Convert(const gz::msgs::Double &_msg)
Set(&ret, _msg);
return ret;
}
} // namespce
} // namespace
} // namespace gz::msgs
#endif // GZ_MSGS_CONVERT_VECTOR3_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/Vector2.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ inline gz::math::Vector2d Convert(const gz::msgs::Vector2d &_msg)
Set(&ret, _msg);
return ret;
}
} // namespce
} // namespace
} // namespace gz::msgs
#endif // GZ_MSGS_CONVERT_VECTOR3_HH_
2 changes: 1 addition & 1 deletion core/include/gz/msgs/convert/make_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

{conversions}

}} // namespce
}} // namespace
}} // namespace gz::msgs

#endif // GZ_MSGS_CONVERT_VECTOR3_HH_
Expand Down
1 change: 1 addition & 0 deletions core/include/gz/msgs/detail/dynamic_message_cast.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dynamic_message_cast(std::unique_ptr<google::protobuf::Message> &&_baseMsg)
{
auto converted = std::unique_ptr<MsgT>{dynamic_cast<MsgT*>(_baseMsg.get())};
if (converted) {
// transfer ownership to a new unique_ptr object by releasing from old one
(void) _baseMsg.release();
}
return converted;
Expand Down
2 changes: 1 addition & 1 deletion core/src/DynamicFactory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DynamicFactory

//////////////////////////////////////////////////
/// \brief Load descriptors into the descriptor pool.
/// \param[in] _paths A set of directories containing .desc decriptor files.
/// \param[in] _paths A set of directories containing .desc descriptor files.
/// Each directory should be separated by ":".
public: void LoadDescriptors(const std::string &_paths);

Expand Down
11 changes: 5 additions & 6 deletions core/src/MessageFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ MessageFactory::MessagePtr MessageFactory::New(
// Convert ".gz_msgs." prefix
else if (_msgType.find(".gz_msgs.") == 0)
{
type = kGzMsgsPrefix + _msgType.substr(9);
type = kGzMsgsPrefix + _msgType.substr(9);
}
// Convert ".gz.msgs." prefix
else if (_msgType.find(".gz.msgs.") == 0)
Expand All @@ -77,11 +77,11 @@ MessageFactory::MessagePtr MessageFactory::New(

auto getMessagePtr = [this](const std::string &_type)
{
MessageFactory::MessagePtr ret = nullptr;
if (msgMap.find(_type) != msgMap.end())
MessageFactory::MessagePtr ret;
if (auto it = msgMap.find(_type); it != msgMap.end())
{
// Create a new message via FactoryFn
ret = msgMap[_type]();
ret = it->second();
}
else
{
Expand Down Expand Up @@ -118,8 +118,7 @@ void MessageFactory::Types(std::vector<std::string> &_types)
_types.clear();

// Return the list of all known message types.
std::map<std::string, FactoryFn>::const_iterator iter;
for (iter = msgMap.begin(); iter != msgMap.end(); ++iter)
for (auto iter = msgMap.begin(); iter != msgMap.end(); ++iter)
{
_types.push_back(iter->first);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/generating_custom_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ gz_msgs_generate_messages(
MSGS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/proto
# List of proto files to process
MSGS_PROTOS ${MSGS_PROTOS}
# Depenency on gz-msgs
# Dependency on gz-msgs
DEPENDENCIES gz-msgs${GZ_MSGS_VER}::gz-msgs${GZ_MSGS_VER}
)

Expand Down
2 changes: 1 addition & 1 deletion examples/generating_custom_msgs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Creating custom gz-msgs entries

The example in this folder demonstrates how to create your own message defintions.
The example in this folder demonstrates how to create your own message definitions.

Most of the setup is the same as the `using_gz_msgs` example, so if you are not familiar, view that first.

Expand Down
9 changes: 3 additions & 6 deletions examples/generating_custom_msgs/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
// A simple example that demonstrates the use of the message factory
//
// ./generating_custom_messages
int main(int argc, char** argv)
int main()
{
(void) argc;
(void) argv;

gz::custom_msgs::BazStamped msg;

// msg has header and baz field
Expand Down Expand Up @@ -45,7 +42,7 @@ int main(int argc, char** argv)
auto *bar = baz->mutable_bar();

{
// Set the values of our custom sub-messges
// Set the values of our custom sub-messages
foo->set_value(1.0);
bar->set_value(1.0);
}
Expand All @@ -63,6 +60,6 @@ int main(int argc, char** argv)
{
// Print the populated values of a message
std::cout << "===============================" << std::endl;
std::cout << "Pouplated Message: \n" << msg.DebugString() << std::endl;
std::cout << "Populated Message: \n" << msg.DebugString() << std::endl;
}
}
2 changes: 1 addition & 1 deletion examples/using_gz_msgs/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char** argv)
std::cout << "Known types: " << std::endl;
for (const auto &t: known_types)
{
std::cout << t << std::endl;
std::cout << t << std::endl;
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion gz-msgs-extras.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ set(@PROJECT_NAME@_PROTO_GENERATOR_SCRIPT ${@PROJECT_NAME@_INSTALL_PATH}/bin/${P
set(@PROJECT_NAME@_FACTORY_GENERATOR_SCRIPT ${@PROJECT_NAME@_INSTALL_PATH}/bin/${FACTORY_SCRIPT_NAME})

##################################################
# A function to generate a target mesage library from a group of protobuf files .
# A function to generate a target message library from a group of protobuf files .
# The generation follows the conventions to make the messages available in gazebo tooling
#
# For an example use, consult gz-msgs/examples/generating_custom_messages
Expand Down
2 changes: 1 addition & 1 deletion proto/gz/msgs/data_load_options.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ message DataLoadPathOptions
/// Units
DataAngularUnits units = 7;

/// Spherical Coodinate type
/// Spherical Coordinate type
gz.msgs.SphericalCoordinatesType coordinate_type = 8;
}
2 changes: 1 addition & 1 deletion proto/gz/msgs/discovery.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ message Discovery
/// \brief Unadvertise message.
UNADVERTISE = 3;

/// \brief Hearbeat message.
/// \brief Heartbeat message.
HEARTBEAT = 4;

/// \brief Bye message.
Expand Down
2 changes: 1 addition & 1 deletion proto/gz/msgs/response.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ option java_outer_classname = "ResponseProtos";

/// \ingroup gz.msgs
/// \interface Response
/// \brief Message that encapsulates a respons message with a type description
/// \brief Message that encapsulates a response message with a type description

import "gz/msgs/header.proto";

Expand Down
Loading