Skip to content

Commit

Permalink
Port autoware-planning-rviz-plugin (autowarefoundation#103)
Browse files Browse the repository at this point in the history
* Port to ROS2

Signed-off-by: Servando German Serrano <[email protected]>

* Update deprecated

Signed-off-by: Servando German Serrano <[email protected]>

* Update namespaces

Signed-off-by: Servando German Serrano <[email protected]>
  • Loading branch information
sgermanserrano authored and tkimura4 committed Dec 3, 2021
1 parent 0b28c5f commit 23d343b
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 185 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.5)
project(autoware_planning_rviz_plugin)
add_compile_options(-std=c++14 -Wall)

find_package(catkin REQUIRED COMPONENTS
roscpp
rviz
autoware_planning_msgs
)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
add_compile_options(-Wno-unused-parameter)
endif()

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
set(QT_LIBRARIES Qt5::Widgets)
Expand All @@ -15,19 +19,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_definitions(-DQT_NO_KEYWORDS)
find_package(Eigen3 REQUIRED)

catkin_package(
CATKIN_DEPENDS
roscpp
rviz
)

include_directories(
include
${catkin_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
)

add_library(autoware_planning_rviz_plugin
ament_auto_add_library(autoware_planning_rviz_plugin
include/path/display.hpp
src/path/display.cpp
include/trajectory/display.hpp
Expand All @@ -37,21 +29,14 @@ add_library(autoware_planning_rviz_plugin
)

target_link_libraries(autoware_planning_rviz_plugin
${catkin_LIBRARIES} ${QT_LIBRARIES}
)

add_dependencies(autoware_planning_rviz_plugin
${catkin_EXPORTED_TARGETS}
)

install(TARGETS autoware_planning_rviz_plugin
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
${QT_LIBRARIES}
)

# Export the plugin to be imported by rviz2
pluginlib_export_plugin_description_file(rviz_common plugins/plugin_description.xml)

install(
DIRECTORY
icons
plugins
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
ament_auto_package(
INSTALL_TO_SHARE
icons
plugins
)
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@
#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829
#include <QObject>

#include <ros/ros.h>
#include <rclcpp/node.hpp>

#include <rviz/default_plugin/tools/pose_tool.h>
#include <rviz_default_plugins/tools/pose/pose_tool.hpp>
#include <rviz_common/display_context.hpp>
#include <rviz_common/properties/float_property.hpp>
#include <rviz_common/properties/string_property.hpp>
#endif

namespace rviz
{
class Arrow;
class DisplayContext;
class StringProperty;
class FloatProperty;
#include <geometry_msgs/msg/pose_stamped.hpp>

class MissionCheckpointTool : public PoseTool
namespace rviz_plugins
{
class MissionCheckpointTool : public rviz_default_plugins::tools::PoseTool
{
Q_OBJECT
public:
Expand All @@ -59,15 +59,15 @@ private Q_SLOTS:
void updateTopic();

private:
ros::NodeHandle nh_;
ros::Publisher pose_pub_;
rclcpp::Clock::SharedPtr clock_;
rclcpp::Publisher<geometry_msgs::msg::PoseStamped>::SharedPtr pose_pub_;

StringProperty * pose_topic_property_;
StringProperty * twist_topic_property_;
FloatProperty * std_dev_x_;
FloatProperty * std_dev_y_;
FloatProperty * std_dev_theta_;
FloatProperty * position_z_;
rviz_common::properties::StringProperty * pose_topic_property_;
rviz_common::properties::StringProperty * twist_topic_property_;
rviz_common::properties::FloatProperty * std_dev_x_;
rviz_common::properties::FloatProperty * std_dev_y_;
rviz_common::properties::FloatProperty * std_dev_theta_;
rviz_common::properties::FloatProperty * position_z_;
};

} // namespace rviz
} // namespace rviz_plugins
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,27 @@

#include <OgreBillboardSet.h>
#include <OgreManualObject.h>
#include <OgreMaterialManager.h>
#include <OgreSceneManager.h>
#include <OgreSceneNode.h>
#include <ros/ros.h>
#include <rviz/display_context.h>
#include <rviz/frame_manager.h>
#include <rviz/message_filter_display.h>
#include <rviz/properties/bool_property.h>
#include <rviz/properties/color_property.h>
#include <rviz/properties/float_property.h>
#include <rviz/validate_floats.h>
#include <rclcpp/rclcpp.hpp>
#include <rviz_common/display_context.hpp>
#include <rviz_common/frame_manager_iface.hpp>
#include <rviz_common/message_filter_display.hpp>
#include <rviz_common/properties/bool_property.hpp>
#include <rviz_common/properties/color_property.hpp>
#include <rviz_common/properties/float_property.hpp>
#include <rviz_common/properties/parse_color.hpp>
#include <rviz_common/validate_floats.hpp>

#include <deque>
#include <memory>

#include "autoware_planning_msgs/Path.h"
#include "autoware_planning_msgs/msg/path.hpp"

namespace rviz_plugins
{
class AutowarePathDisplay : public rviz::MessageFilterDisplay<autoware_planning_msgs::Path>
class AutowarePathDisplay : public rviz_common::MessageFilterDisplay<autoware_planning_msgs::msg::Path>
{
Q_OBJECT

Expand All @@ -51,28 +53,28 @@ private Q_SLOTS:
void updateVisualization();

protected:
void processMessage(const autoware_planning_msgs::PathConstPtr & msg_ptr) override;
void processMessage(const autoware_planning_msgs::msg::Path::ConstSharedPtr msg_ptr) override;
std::unique_ptr<Ogre::ColourValue> setColorDependsOnVelocity(
const double vel_max, const double cmd_vel);
std::unique_ptr<Ogre::ColourValue> gradation(
const QColor & color_min, const QColor & color_max, const double ratio);
Ogre::ManualObject * path_manual_object_;
Ogre::ManualObject * velocity_manual_object_;
rviz::BoolProperty * property_path_view_;
rviz::BoolProperty * property_velocity_view_;
rviz::FloatProperty * property_path_width_;
rviz::ColorProperty * property_path_color_;
rviz::ColorProperty * property_velocity_color_;
rviz::FloatProperty * property_path_alpha_;
rviz::FloatProperty * property_velocity_alpha_;
rviz::FloatProperty * property_velocity_scale_;
rviz::BoolProperty * property_path_color_view_;
rviz::BoolProperty * property_velocity_color_view_;
rviz::FloatProperty * property_vel_max_;
rviz_common::properties::BoolProperty * property_path_view_;
rviz_common::properties::BoolProperty * property_velocity_view_;
rviz_common::properties::FloatProperty * property_path_width_;
rviz_common::properties::ColorProperty * property_path_color_;
rviz_common::properties::ColorProperty * property_velocity_color_;
rviz_common::properties::FloatProperty * property_path_alpha_;
rviz_common::properties::FloatProperty * property_velocity_alpha_;
rviz_common::properties::FloatProperty * property_velocity_scale_;
rviz_common::properties::BoolProperty * property_path_color_view_;
rviz_common::properties::BoolProperty * property_velocity_color_view_;
rviz_common::properties::FloatProperty * property_vel_max_;

private:
autoware_planning_msgs::PathConstPtr last_msg_ptr_;
bool validateFloats(const autoware_planning_msgs::PathConstPtr & msg_ptr);
autoware_planning_msgs::msg::Path::ConstSharedPtr last_msg_ptr_;
bool validateFloats(const autoware_planning_msgs::msg::Path::ConstSharedPtr & msg_ptr);
};

} // namespace rviz_plugins
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,28 @@

#include <OgreBillboardSet.h>
#include <OgreManualObject.h>
#include <OgreMaterialManager.h>
#include <OgreSceneManager.h>
#include <OgreSceneNode.h>
#include <ros/ros.h>
#include <rviz/display_context.h>
#include <rviz/frame_manager.h>
#include <rviz/message_filter_display.h>
#include <rviz/properties/bool_property.h>
#include <rviz/properties/color_property.h>
#include <rviz/properties/float_property.h>
#include <rviz/validate_floats.h>
#include <rclcpp/rclcpp.hpp>
#include <rviz_common/display_context.hpp>
#include <rviz_common/frame_manager_iface.hpp>
#include <rviz_common/message_filter_display.hpp>
#include <rviz_common/properties/bool_property.hpp>
#include <rviz_common/properties/color_property.hpp>
#include <rviz_common/properties/float_property.hpp>
#include <rviz_common/properties/parse_color.hpp>
#include <rviz_common/validate_floats.hpp>

#include <deque>
#include <memory>

#include "autoware_planning_msgs/Trajectory.h"
#include "autoware_planning_msgs/msg/trajectory.hpp"

namespace rviz_plugins
{
class AutowareTrajectoryDisplay
: public rviz::MessageFilterDisplay<autoware_planning_msgs::Trajectory>
: public rviz_common::MessageFilterDisplay<autoware_planning_msgs::msg::Trajectory>
{
Q_OBJECT

Expand All @@ -52,28 +54,28 @@ private Q_SLOTS:
void updateVisualization();

protected:
void processMessage(const autoware_planning_msgs::TrajectoryConstPtr & msg_ptr) override;
void processMessage(const autoware_planning_msgs::msg::Trajectory::ConstSharedPtr msg_ptr) override;
std::unique_ptr<Ogre::ColourValue> setColorDependsOnVelocity(
const double vel_max, const double cmd_vel);
std::unique_ptr<Ogre::ColourValue> gradation(
const QColor & color_min, const QColor & color_max, const double ratio);
Ogre::ManualObject * path_manual_object_;
Ogre::ManualObject * velocity_manual_object_;
rviz::BoolProperty * property_path_view_;
rviz::BoolProperty * property_velocity_view_;
rviz::FloatProperty * property_path_width_;
rviz::ColorProperty * property_path_color_;
rviz::ColorProperty * property_velocity_color_;
rviz::FloatProperty * property_velocity_scale_;
rviz::FloatProperty * property_path_alpha_;
rviz::FloatProperty * property_velocity_alpha_;
rviz::BoolProperty * property_path_color_view_;
rviz::BoolProperty * property_velocity_color_view_;
rviz::FloatProperty * property_vel_max_;
rviz_common::properties::BoolProperty * property_path_view_;
rviz_common::properties::BoolProperty * property_velocity_view_;
rviz_common::properties::FloatProperty * property_path_width_;
rviz_common::properties::ColorProperty * property_path_color_;
rviz_common::properties::ColorProperty * property_velocity_color_;
rviz_common::properties::FloatProperty * property_velocity_scale_;
rviz_common::properties::FloatProperty * property_path_alpha_;
rviz_common::properties::FloatProperty * property_velocity_alpha_;
rviz_common::properties::BoolProperty * property_path_color_view_;
rviz_common::properties::BoolProperty * property_velocity_color_view_;
rviz_common::properties::FloatProperty * property_vel_max_;

private:
autoware_planning_msgs::TrajectoryConstPtr last_msg_ptr_;
bool validateFloats(const autoware_planning_msgs::TrajectoryConstPtr & msg_ptr);
autoware_planning_msgs::msg::Trajectory::ConstSharedPtr last_msg_ptr_;
bool validateFloats(const autoware_planning_msgs::msg::Trajectory::ConstSharedPtr & msg_ptr);
};

} // namespace rviz_plugins
19 changes: 12 additions & 7 deletions common/util/rviz_plugins/autoware_planning_rviz_plugin/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@
<maintainer email="[email protected]">Yukihiro Saito</maintainer>
<license>Apache2</license>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rviz</build_depend>
<build_depend>autoware_planning_msgs</build_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rviz</exec_depend>
<exec_depend>autoware_planning_msgs</exec_depend>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>autoware_planning_msgs</depend>
<depend>qtbase5-dev</depend>
<depend>libqt5-core</depend>
<depend>libqt5-gui</depend>
<depend>libqt5-widgets</depend>
<depend>rclcpp</depend>
<depend>rviz_common</depend>
<depend>rviz_default_plugins</depend>
<depend>tf2_ros</depend>
<depend>tf2_geometry_msgs</depend>

<export>
<build_type>ament_cmake</build_type>
<rviz plugin="${prefix}/plugins/plugin_description.xml"/>
</export>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<library path="lib/libautoware_planning_rviz_plugin">
<class name="rviz_plugins/Path" type="rviz_plugins::AutowarePathDisplay" base_class_type="rviz::Display">
<class name="rviz_plugins/Path"
type="rviz_plugins::AutowarePathDisplay"
base_class_type="rviz_common::Display">
<description>Display autoware_planning_msg::Path</description>
</class>
<class name="rviz_plugins/Trajectory" type="rviz_plugins::AutowareTrajectoryDisplay" base_class_type="rviz::Display">
<class name="rviz_plugins/Trajectory"
type="rviz_plugins::AutowareTrajectoryDisplay"
base_class_type="rviz_common::Display">
<description>Display autoware_planning_msg::Trajectory</description>
</class>
<class name="rviz/MissionCheckpointTool"
type="rviz::MissionCheckpointTool"
base_class_type="rviz::Tool">
<class name="rviz_plugins/MissionCheckpointTool"
type="rviz_plugins::MissionCheckpointTool"
base_class_type="rviz_common::Tool">
</class>
</library>
Loading

0 comments on commit 23d343b

Please sign in to comment.