Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions rclcpp/plugins/polygon_base/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be during release process? we are planning to release this package, correct?

Changelog for package polygon_base
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
55 changes: 55 additions & 0 deletions rclcpp/plugins/polygon_base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.20)
project(polygon_base)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_ros REQUIRED)
find_package(pluginlib REQUIRED)

add_library(polygon_base INTERFACE)
add_library(polygon_base::polygon_base ALIAS polygon_base)
target_compile_features(polygon_base INTERFACE c_std_99 cxx_std_17) # Require C99 and C++17
target_include_directories(polygon_base INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
target_link_libraries(
polygon_base INTERFACE
${pluginlib_TARGETS}
)

install(
DIRECTORY include/
DESTINATION include/${PROJECT_NAME}
)
install(
TARGETS polygon_base
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove, these linters should work

ament_lint_auto_find_test_dependencies()
endif()

ament_export_include_directories(
"include/${PROJECT_NAME}"
)
ament_export_targets(
export_${PROJECT_NAME}
)

ament_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2025 Open Source Robotics Foundation, Inc.
//
// 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 POLYGON_BASE__REGULAR_POLYGON_HPP_
#define POLYGON_BASE__REGULAR_POLYGON_HPP_

namespace polygon_base
{
class RegularPolygon
{
public:
virtual void initialize(double side_length) = 0;
virtual double area() = 0;
virtual ~RegularPolygon() {}

protected:
RegularPolygon() {}
};
} // namespace polygon_base

#endif // POLYGON_BASE__REGULAR_POLYGON_HPP_
28 changes: 28 additions & 0 deletions rclcpp/plugins/polygon_base/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>polygon_base</name>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I rename the package?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to do that? and into what name?

and if we do that, probably the tutorial in the documentation should be changed accordingly to keep the consistency?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that other packages are prefixed with example_rclcpp, that's why I am asking if it is required to rename it

<version>0.21.3</version>
<description>Examples of polygon base</description>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better description


<maintainer email="aditya.pande@openrobotics.org">Aditya Pande</maintainer>
<maintainer email="alejandro@openrobotics.org">Alejandro Hernandez Cordero</maintainer>

<license>Apache License 2.0</license>

<author email="jacob@openrobotics.org">Jacob Perron</author>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add yourself here

<author>Mikael Arguedas</author>
<author>Morgan Quigley</author>
<author email="sloretz@openrobotics.org">Shane Loretz</author>

<buildtool_depend>ament_cmake_ros</buildtool_depend>

<depend>pluginlib</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
3 changes: 3 additions & 0 deletions rclcpp/plugins/polygon_plugins/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. i think this should be generated by release tool.

Changelog for package polygon_plugins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58 changes: 58 additions & 0 deletions rclcpp/plugins/polygon_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
cmake_minimum_required(VERSION 3.20)
project(polygon_plugins)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(polygon_base REQUIRED)
find_package(pluginlib REQUIRED)

add_library(polygon_plugins SHARED
src/polygon_plugins.cpp
)
target_compile_features(polygon_plugins PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17
target_include_directories(polygon_plugins PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(polygon_plugins PUBLIC
${polygon_base_TARGETS}
${pluginlib_TARGETS}
)

add_executable(area_node src/area_node.cpp)
target_include_directories(area_node PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
target_compile_features(area_node PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17
target_link_libraries(
area_node
${polygon_base_TARGETS}
${pluginlib_TARGETS}
)

install(
TARGETS polygon_plugins
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(TARGETS area_node
DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

pluginlib_export_plugin_description_file(polygon_base plugins.xml)
ament_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2025 Open Source Robotics Foundation, Inc.
//
// 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 POLYGON_PLUGINS__POLYGON_PLUGINS_HPP_
#define POLYGON_PLUGINS__POLYGON_PLUGINS_HPP_

namespace polygon_plugins
{

class PolygonPlugins
{
public:
PolygonPlugins();

virtual ~PolygonPlugins();
};

} // namespace polygon_plugins

#endif // POLYGON_PLUGINS__POLYGON_PLUGINS_HPP_
29 changes: 29 additions & 0 deletions rclcpp/plugins/polygon_plugins/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>polygon_plugins</name>
<version>0.21.3</version>
<description>Example of polygon plugins</description>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better description


<maintainer email="aditya.pande@openrobotics.org">Aditya Pande</maintainer>
<maintainer email="alejandro@openrobotics.org">Alejandro Hernandez Cordero</maintainer>

<license>Apache License 2.0</license>

<author email="jacob@openrobotics.org">Jacob Perron</author>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add yourself as the author

<author>Mikael Arguedas</author>
<author>Morgan Quigley</author>
<author email="sloretz@openrobotics.org">Shane Loretz</author>

<buildtool_depend>ament_cmake_ros</buildtool_depend>

<depend>polygon_base</depend>
<depend>pluginlib</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
8 changes: 8 additions & 0 deletions rclcpp/plugins/polygon_plugins/plugins.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<library path="polygon_plugins">
<class type="polygon_plugins::Square" base_class_type="polygon_base::RegularPolygon">
<description>This is a square plugin.</description>
</class>
<class type="polygon_plugins::Triangle" base_class_type="polygon_base::RegularPolygon" name="awesome_triangle">
<description>This is a triangle plugin.</description>
</class>
</library>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new line

43 changes: 43 additions & 0 deletions rclcpp/plugins/polygon_plugins/src/area_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2025 Open Source Robotics Foundation, Inc.
//
// 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.

#include <pluginlib/class_loader.hpp>
#include <polygon_base/regular_polygon.hpp>

int main(int argc, char ** argv)
{
// To avoid unused parameter warnings
(void) argc;
(void) argv;

pluginlib::ClassLoader<polygon_base::RegularPolygon> poly_loader("polygon_base",
"polygon_base::RegularPolygon");

try {
std::shared_ptr<polygon_base::RegularPolygon> triangle =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include <memory>

poly_loader.createSharedInstance("awesome_triangle");
triangle->initialize(10.0);

std::shared_ptr<polygon_base::RegularPolygon> square =
poly_loader.createSharedInstance("polygon_plugins::Square");
square->initialize(10.0);

printf("Triangle area: %.2f\n", triangle->area());
printf("Square area: %.2f\n", square->area());
} catch(pluginlib::PluginlibException & ex) {
printf("The plugin failed to load for some reason. Error: %s\n", ex.what());
}

return 0;
}
63 changes: 63 additions & 0 deletions rclcpp/plugins/polygon_plugins/src/polygon_plugins.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2025 Open Source Robotics Foundation, Inc.
//
// 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.

#include <cmath>
#include <polygon_base/regular_polygon.hpp>

namespace polygon_plugins
{
class Square : public polygon_base::RegularPolygon
{
public:
void initialize(double side_length) override
{
side_length_ = side_length;
}

double area() override
{
return side_length_ * side_length_;
}

protected:
double side_length_;
};

class Triangle : public polygon_base::RegularPolygon
{
public:
void initialize(double side_length) override
{
side_length_ = side_length;
}

double area() override
{
return 0.5 * side_length_ * getHeight();
}

double getHeight()
{
return sqrt((side_length_ * side_length_) - ((side_length_ / 2) * (side_length_ / 2)));
}

protected:
double side_length_;
};
} // namespace polygon_plugins

#include <pluginlib/class_list_macros.hpp>

PLUGINLIB_EXPORT_CLASS(polygon_plugins::Square, polygon_base::RegularPolygon)
PLUGINLIB_EXPORT_CLASS(polygon_plugins::Triangle, polygon_base::RegularPolygon)