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

ROS2 port #18

Open
wants to merge 8 commits into
base: ros2
Choose a base branch
from
Open
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
20 changes: 4 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: CI

on:
push:
branches:
- master
# branches:
# - master
pull_request:
branches:
- master
Expand All @@ -14,24 +14,12 @@ jobs:
fail-fast: false
matrix:
env:
- {CI_NAME: xenial,
OS_NAME: ubuntu,
OS_CODE_NAME: xenial,
ROS_DISTRO: kinetic,
ROS_REPO: main,
DOCKER_IMAGE: "ros:kinetic"}
- {CI_NAME: bionic,
OS_NAME: ubuntu,
OS_CODE_NAME: bionic,
ROS_DISTRO: melodic,
ROS_REPO: main,
DOCKER_IMAGE: "ros:melodic"}
- {CI_NAME: focal,
OS_NAME: ubuntu,
OS_CODE_NAME: focal,
ROS_DISTRO: noetic,
ROS_DISTRO: foxy,
ROS_REPO: main,
DOCKER_IMAGE: "ros:noetic"}
DOCKER_IMAGE: "ros:foxy"}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
91 changes: 48 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,15 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(catkin REQUIRED COMPONENTS
rviz
pluginlib
pcl_ros
)
cmake_policy(SET CMP0057 NEW)

find_package(ament_cmake REQUIRED)
find_package(Eigen3 REQUIRED)

catkin_package(
INCLUDE_DIRS
include
LIBRARIES
tool_cursor
CATKIN_DEPENDS
rviz
pluginlib
pcl_ros
)

###########
## Build ##
###########

include_directories(
include
${catkin_INCLUDE_DIRS}
)
find_package(PCL REQUIRED COMPONENTS common io geometry)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rviz_common REQUIRED)
find_package(rviz_rendering REQUIRED)

# QT
find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
Expand All @@ -42,42 +24,65 @@ qt5_wrap_cpp(MOC_FILES
src/mesh_tool_cursor.h
)

add_library(tool_cursor
add_library(${PROJECT_NAME} SHARED
src/${PROJECT_NAME}/rviz_tool_cursor.cpp
src/${PROJECT_NAME}/get_point_on_plane.cpp
src/circle_tool_cursor.cpp
src/mesh_tool_cursor.cpp
${MOC_FILES}
)
target_link_libraries(tool_cursor
${catkin_LIBRARIES}
target_link_libraries(${PROJECT_NAME}
Qt5::Widgets
)
${rclcpp_LIBRARIES}
${rviz_common_LIBRARIES}
${rviz_rendering_LIBRARIES}
${pluginlib_LIBRARIES}
Eigen3::Eigen
${PCL_LIBRARIES})
target_include_directories(${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PUBLIC $<INSTALL_INTERFACE:include>)
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
${PCL_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME} PUBLIC
${pluginlib_INCLUDE_DIRS}
${rviz_common_INCLUDE_DIRS}
${rviz_rendering_INCLUDE_DIRS}

)
target_compile_definitions(${PROJECT_NAME} PRIVATE "RVIZ_DEFAULT_PLUGINS_BUILDING_LIBRARY")
target_compile_definitions(${PROJECT_NAME} PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")

#############
## Install ##
#############
pluginlib_export_plugin_description_file(rviz_common plugin_description.xml)

# Mark executables and/or libraries for installation
install(TARGETS tool_cursor
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)

# Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
install(DIRECTORY include/
DESTINATION include
)

# Mark other files for installation (e.g. launch and bag files, etc.)
install(FILES plugin_description.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
DESTINATION share/${PROJECT_NAME}
)
install(DIRECTORY resources
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
DESTINATION share/${PROJECT_NAME}
)

#############
## Testing ##
#############
ament_export_include_directories(include)
ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET)
ament_export_dependencies(${PROJECT_NAME}
rclcpp
rviz_common
rviz_rendering
pluginlib)

ament_package()
16 changes: 16 additions & 0 deletions include/rviz_tool_cursor/get_point_on_plane.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <OgrePrerequisites.h>

namespace rviz_rendering
{
/** @brief Given a viewport and an x,y position in window-pixel coordinates,
* find the point on a plane directly behind it, if any.
* @return true if the intersection exists, false if it does not. */
bool getPointOnPlaneFromWindowXY(Ogre::Viewport* viewport,
Ogre::Plane& plane,
int window_x,
int window_y,
Ogre::Vector3& intersection_out);

}
37 changes: 22 additions & 15 deletions include/rviz_tool_cursor/rviz_tool_cursor.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
#ifndef RVIZ_TOOL_CURSOR_RVIZ_TOOL_CURSOR_H
#define RVIZ_TOOL_CURSOR_RVIZ_TOOL_CURSOR_H
#pragma once

#include <rviz/tool.h>
#include <ros/node_handle.h>
#include <ros/publisher.h>
#include <rviz_common/tool.hpp>
#include <rclcpp/clock.hpp>
#include <rclcpp/publisher.hpp>
#include <geometry_msgs/msg/pose_stamped.hpp>

namespace Ogre
{
class SceneNode;
class MovableObject;
}

namespace rviz
namespace rviz_common
{
class RenderPanel;
}

namespace rviz_common
{
namespace properties
{
class StringProperty;
class IntProperty;
class ColorProperty;
class FloatProperty;
}
}

namespace rviz_tool_cursor
{

class ToolCursor : public rviz::Tool
class ToolCursor : public rviz_common::Tool
{
Q_OBJECT
public:
Expand All @@ -36,7 +45,7 @@ Q_OBJECT

virtual void deactivate() override;

virtual int processMouseEvent(rviz::ViewportMouseEvent& event) override;
virtual int processMouseEvent(rviz_common::ViewportMouseEvent& event) override;

public Q_SLOTS:

Expand All @@ -58,17 +67,15 @@ public Q_SLOTS:

Ogre::MovableObject* movable_obj_;

ros::NodeHandle nh_;
rclcpp::Clock::SharedPtr clock_;

ros::Publisher pub_;
rclcpp::Publisher<geometry_msgs::msg::PoseStamped>::SharedPtr pub_;

rviz::StringProperty* topic_property_;
rviz_common::properties::StringProperty* topic_property_;

rviz::IntProperty* patch_size_property_;
rviz_common::properties::IntProperty* patch_size_property_;

rviz::ColorProperty* color_property_;
rviz_common::properties::ColorProperty* color_property_;
};

} // namespace rviz_tool_cursor

#endif // RVIZ_TOOL_CURSOR_RVIZ_TOOL_CURSOR_H
9 changes: 5 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@

<license>Apache 2.0</license>

<buildtool_depend>catkin</buildtool_depend>
<depend>rviz</depend>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>libpcl-all-dev</depend>
<depend>pluginlib</depend>
<depend>pcl_ros</depend>
<depend>rviz_common</depend>
<depend>rviz_rendering</depend>

<export>
<rviz plugin="${prefix}/plugin_description.xml"/>
<build_type>ament_cmake</build_type>
</export>
</package>
6 changes: 3 additions & 3 deletions plugin_description.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0"?>
<library path="lib/libtool_cursor">
<class name="rviz_tool_cursor/CircleToolCursor" type="rviz_tool_cursor::CircleToolCursor" base_class_type="rviz::Tool">
<library path="rviz_tool_cursor">
<class name="rviz_tool_cursor/CircleToolCursor" type="rviz_tool_cursor::CircleToolCursor" base_class_type="rviz_common::Tool">
<description>
A cursor representing a circular tool that follows the geometry of mesh surfaces
</description>
</class>
<class name="rviz_tool_cursor/MeshToolCursor" type="rviz_tool_cursor::MeshToolCursor" base_class_type="rviz::Tool">
<class name="rviz_tool_cursor/MeshToolCursor" type="rviz_tool_cursor::MeshToolCursor" base_class_type="rviz_common::Tool">
<description>
A cursor representing an input mesh that follows the geometry of mesh surfaces
</description>
Expand Down
Binary file added resources/default_10cm.stl
Binary file not shown.
9 changes: 5 additions & 4 deletions src/circle_tool_cursor.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include <OgreManualObject.h>
#include <OgreMovableObject.h>
#include <OgreSceneManager.h>
#include <OgreSceneNode.h>

#include <pluginlib/class_list_macros.h>

#include <rviz/properties/color_property.h>
#include <rviz/properties/float_property.h>
#include <rviz_common/properties/color_property.hpp>
#include <rviz_common/properties/float_property.hpp>

#include "circle_tool_cursor.h"

Expand All @@ -17,7 +18,7 @@ namespace rviz_tool_cursor
CircleToolCursor::CircleToolCursor()
: ToolCursor()
{
radius_property_ = new rviz::FloatProperty("Tool Radius", 0.210f,
radius_property_ = new rviz_common::properties::FloatProperty("Tool Radius", 0.210f,
"The radius of the tool circle display",
getPropertyContainer(), SLOT(updateToolVisualization()), this);
}
Expand Down Expand Up @@ -77,4 +78,4 @@ void CircleToolCursor::updateToolVisualization()

} // namespace rviz_tool_cursor

PLUGINLIB_EXPORT_CLASS(rviz_tool_cursor::CircleToolCursor, rviz::Tool)
PLUGINLIB_EXPORT_CLASS(rviz_tool_cursor::CircleToolCursor, rviz_common::Tool)
12 changes: 2 additions & 10 deletions src/circle_tool_cursor.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#ifndef RVIZ_TOOL_CURSOR_CIRCLE_TOOL_CURSOR_H
#define RVIZ_TOOL_CURSOR_CIRCLE_TOOL_CURSOR_H
#pragma once

#include <rviz_tool_cursor/rviz_tool_cursor.h>

namespace rviz
{
class FloatProperty;
}

namespace Ogre
{
class ManualObject;
Expand All @@ -33,11 +27,9 @@ public Q_SLOTS:

virtual Ogre::MovableObject* createToolVisualization() override;

rviz::FloatProperty* radius_property_;
rviz_common::properties::FloatProperty* radius_property_;

const std::string object_name_ = "circle_tool_cursor";
};

} // namespace rviz_tool_cursor

#endif // RVIZ_TOOL_CURSOR_CIRCLE_TOOL_CURSOR_H
Loading