Skip to content

Commit

Permalink
ci(pre-commit): autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Dec 3, 2021
1 parent 650ec61 commit 4f9a775
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 101 deletions.
2 changes: 1 addition & 1 deletion common/autoware_auto_perception_rviz_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ Overwrite prediction results with tracking results.

## References/External links

[1] https://gitlab.com/autowarefoundation/autoware.auto/AutowareAuto/-/tree/master/src/tools/visualization/autoware_rviz_plugins
[1] <https://gitlab.com/autowarefoundation/autoware.auto/AutowareAuto/-/tree/master/src/tools/visualization/autoware_rviz_plugins>

## Future extensions / Unimplemented parts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
#ifndef COMMON__COLOR_ALPHA_PROPERTY_HPP_
#define COMMON__COLOR_ALPHA_PROPERTY_HPP_

#include <memory>
#include <rviz_common/display.hpp>
#include <rviz_common/properties/color_property.hpp>
#include <rviz_common/properties/float_property.hpp>
#include <std_msgs/msg/color_rgba.hpp>
#include <visibility_control.hpp>

#include <std_msgs/msg/color_rgba.hpp>

#include <memory>

namespace autoware
{
namespace rviz_plugins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
#ifndef OBJECT_DETECTION__DETECTED_OBJECTS_DISPLAY_HPP_
#define OBJECT_DETECTION__DETECTED_OBJECTS_DISPLAY_HPP_

#include <autoware_auto_perception_msgs/msg/detected_objects.hpp>
#include <object_detection/object_polygon_display_base.hpp>

#include <autoware_auto_perception_msgs/msg/detected_objects.hpp>

namespace autoware
{
namespace rviz_plugins
Expand All @@ -25,7 +26,7 @@ namespace object_detection
{
/// \brief Class defining rviz plugin to visualize DetectedObjects
class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC DetectedObjectsDisplay
: public ObjectPolygonDisplayBase<autoware_auto_perception_msgs::msg::DetectedObjects>
: public ObjectPolygonDisplayBase<autoware_auto_perception_msgs::msg::DetectedObjects>
{
Q_OBJECT

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@
#ifndef OBJECT_DETECTION__OBJECT_POLYGON_DETAIL_HPP_
#define OBJECT_DETECTION__OBJECT_POLYGON_DETAIL_HPP_

#include <rclcpp/logging.hpp>
#include <rclcpp/rclcpp.hpp>
#include <visibility_control.hpp>

#include <autoware_auto_perception_msgs/msg/object_classification.hpp>
#include <autoware_auto_perception_msgs/msg/predicted_path.hpp>
#include <autoware_auto_perception_msgs/msg/shape.hpp>
#include <algorithm>
#include <geometry_msgs/msg/pose_with_covariance.hpp>
#include <geometry_msgs/msg/twist.hpp>
#include <geometry_msgs/msg/twist_with_covariance.hpp>
#include <visualization_msgs/msg/marker.hpp>

#include <algorithm>
#include <map>
#include <rclcpp/logging.hpp>
#include <rclcpp/rclcpp.hpp>
#include <string>
#include <vector>
#include <visibility_control.hpp>
#include <visualization_msgs/msg/marker.hpp>

namespace autoware
{
Expand All @@ -53,20 +55,20 @@ struct ObjectPropertyValues
// Map defining colors according to value of label field in ObjectClassification msg
const std::map<
autoware_auto_perception_msgs::msg::ObjectClassification::_label_type, ObjectPropertyValues>
// Color map is based on cityscapes color
kDefaultObjectPropertyValues = {
{autoware_auto_perception_msgs::msg::ObjectClassification::UNKNOWN,
{"UNKNOWN", {255, 255, 255}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::CAR, {"CAR", {30, 144, 255}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::BUS, {"BUS", {30, 144, 255}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::PEDESTRIAN,
{"PEDESTRIAN", {255, 192, 203}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::BICYCLE, {"CYCLIST", {119, 11, 32}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::MOTORCYCLE,
{"MOTORCYCLE", {119, 11, 32}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::TRAILER,
{"TRAILER", {30, 144, 255}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::TRUCK, {"TRUCK", {30, 144, 255}}}};
// Color map is based on cityscapes color
kDefaultObjectPropertyValues = {
{autoware_auto_perception_msgs::msg::ObjectClassification::UNKNOWN,
{"UNKNOWN", {255, 255, 255}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::CAR, {"CAR", {30, 144, 255}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::BUS, {"BUS", {30, 144, 255}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::PEDESTRIAN,
{"PEDESTRIAN", {255, 192, 203}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::BICYCLE, {"CYCLIST", {119, 11, 32}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::MOTORCYCLE,
{"MOTORCYCLE", {119, 11, 32}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::TRAILER,
{"TRAILER", {30, 144, 255}}},
{autoware_auto_perception_msgs::msg::ObjectClassification::TRUCK, {"TRUCK", {30, 144, 255}}}};

/// \brief Convert the given polygon into a marker representing the shape in 3d
/// \param shape_msg Shape msg to be converted. Corners should be in object-local frame
Expand Down Expand Up @@ -182,14 +184,14 @@ inline AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC geometry_msgs::msg::Pose init
/// \param labels List of ObjectClassificationMsg objects
/// \param logger_name Name to use for logger in case of a warning (if labels is empty)
/// \return Id of the best classification, Unknown if there is no best label
template<typename ClassificationContainerT>
template <typename ClassificationContainerT>
AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC
autoware_auto_perception_msgs::msg::ObjectClassification::_label_type
get_best_label(ClassificationContainerT labels, const std::string & logger_name)
autoware_auto_perception_msgs::msg::ObjectClassification::_label_type
get_best_label(ClassificationContainerT labels, const std::string & logger_name)
{
const auto best_class_label = std::max_element(
labels.begin(), labels.end(),
[](const auto & a, const auto & b) -> bool {return a.probability < b.probability;});
[](const auto & a, const auto & b) -> bool { return a.probability < b.probability; });
if (best_class_label == labels.end()) {
RCLCPP_WARN(
rclcpp::get_logger(logger_name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@
#ifndef OBJECT_DETECTION__OBJECT_POLYGON_DISPLAY_BASE_HPP_
#define OBJECT_DETECTION__OBJECT_POLYGON_DISPLAY_BASE_HPP_

#include <autoware_auto_perception_msgs/msg/object_classification.hpp>
#include <bitset>
#include <common/color_alpha_property.hpp>
#include <list>
#include <memory>
#include <object_detection/object_polygon_detail.hpp>
#include <rviz_common/display.hpp>
#include <rviz_common/properties/color_property.hpp>
#include <rviz_common/properties/float_property.hpp>
#include <rviz_default_plugins/displays/marker/marker_common.hpp>
#include <rviz_default_plugins/displays/marker_array/marker_array_display.hpp>
#include <string>
#include <visibility_control.hpp>

#include <autoware_auto_perception_msgs/msg/object_classification.hpp>
#include <unique_identifier_msgs/msg/uuid.hpp>

#include <bitset>
#include <list>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include <visibility_control.hpp>

namespace autoware
{
Expand All @@ -41,9 +43,9 @@ namespace object_detection
/// for the plugin and also defines common helper functions that can be used by its derived
/// classes.
/// \tparam MsgT PredictedObjects or TrackedObjects or DetectedObjects type
template<typename MsgT>
template <typename MsgT>
class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
: public rviz_common::RosTopicDisplay<MsgT>
: public rviz_common::RosTopicDisplay<MsgT>
{
public:
using Color = std::array<float, 3U>;
Expand Down Expand Up @@ -109,15 +111,15 @@ class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
m_marker_common.load(config);
}

void update(float wall_dt, float ros_dt) override {m_marker_common.update(wall_dt, ros_dt);}
void update(float wall_dt, float ros_dt) override { m_marker_common.update(wall_dt, ros_dt); }

void reset() override
{
RosTopicDisplay::reset();
m_marker_common.clearMarkers();
}

void clear_markers() {m_marker_common.clearMarkers();}
void clear_markers() { m_marker_common.clearMarkers(); }

void add_marker(visualization_msgs::msg::Marker::ConstSharedPtr marker_ptr)
{
Expand All @@ -132,7 +134,7 @@ class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
/// \param orientation Orientation of the shape in Object.header.frame_id frame
/// \param labels List of ObjectClassificationMsg objects
/// \return Marker ptr. Id and header will have to be set by the caller
template<typename ClassificationContainerT>
template <typename ClassificationContainerT>
std::optional<Marker::SharedPtr> get_shape_marker_ptr(
const autoware_auto_perception_msgs::msg::Shape & shape_msg,
const geometry_msgs::msg::Point & centroid, const geometry_msgs::msg::Quaternion & orientation,
Expand All @@ -152,7 +154,7 @@ class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
/// \param centroid Centroid position of the shape in Object.header.frame_id frame
/// \param labels List of ObjectClassificationMsg objects
/// \return Marker ptr. Id and header will have to be set by the caller
template<typename ClassificationContainerT>
template <typename ClassificationContainerT>
std::optional<Marker::SharedPtr> get_label_marker_ptr(
const geometry_msgs::msg::Point & centroid, const geometry_msgs::msg::Quaternion & orientation,
const ClassificationContainerT & labels) const
Expand All @@ -166,7 +168,7 @@ class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
}
}

template<typename ClassificationContainerT>
template <typename ClassificationContainerT>
std::optional<Marker::SharedPtr> get_uuid_marker_ptr(
const unique_identifier_msgs::msg::UUID & uuid, const geometry_msgs::msg::Point & centroid,
const ClassificationContainerT & labels) const
Expand All @@ -190,7 +192,7 @@ class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
}
}

template<typename ClassificationContainerT>
template <typename ClassificationContainerT>
std::optional<Marker::SharedPtr> get_velocity_text_marker_ptr(
const geometry_msgs::msg::Twist & twist, const geometry_msgs::msg::Point & vis_pos,
const ClassificationContainerT & labels) const
Expand Down Expand Up @@ -246,7 +248,7 @@ class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
/// \param labels list of classifications
/// \return Color and alpha for the best class in the given list. Unknown class is used in
/// degenerate cases
template<typename ClassificationContainerT>
template <typename ClassificationContainerT>
std_msgs::msg::ColorRGBA get_color_rgba(const ClassificationContainerT & labels) const
{
static const std::string kLoggerName("ObjectPolygonDisplayBase");
Expand All @@ -262,7 +264,7 @@ class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
/// \tparam ClassificationContainerT Container of ObjectClassification
/// \param labels list of classifications
/// \return best label string
template<typename ClassificationContainerT>
template <typename ClassificationContainerT>
std::string get_best_label(const ClassificationContainerT & labels) const
{
static const std::string kLoggerName("ObjectPolygonDisplayBase");
Expand All @@ -287,7 +289,7 @@ class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC ObjectPolygonDisplayBase
get_color_from_uuid(const std::string & uuid) const
{
int i = (static_cast<int>(uuid.at(0)) * 4 + static_cast<int>(uuid.at(1))) %
static_cast<int>(predicted_path_colors.size());
static_cast<int>(predicted_path_colors.size());

std_msgs::msg::ColorRGBA color;
color.r = predicted_path_colors.at(i).r;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
#ifndef OBJECT_DETECTION__PREDICTED_OBJECTS_DISPLAY_HPP_
#define OBJECT_DETECTION__PREDICTED_OBJECTS_DISPLAY_HPP_

#include <object_detection/object_polygon_display_base.hpp>

#include <autoware_auto_perception_msgs/msg/predicted_objects.hpp>

#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>

#include <list>
#include <map>
#include <object_detection/object_polygon_display_base.hpp>
#include <string>
#include <vector>

Expand All @@ -31,7 +34,7 @@ namespace object_detection
{
/// \brief Class defining rviz plugin to visualize PredictedObjects
class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC PredictedObjectsDisplay
: public ObjectPolygonDisplayBase<autoware_auto_perception_msgs::msg::PredictedObjects>
: public ObjectPolygonDisplayBase<autoware_auto_perception_msgs::msg::PredictedObjects>
{
Q_OBJECT

Expand Down Expand Up @@ -65,8 +68,7 @@ class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC PredictedObjectsDisplay
auto itr = id_map.begin();
while (itr != id_map.end()) {
if (
std::find(tracked_uuids.begin(), tracked_uuids.end(), itr->first) == tracked_uuids.end())
{
std::find(tracked_uuids.begin(), tracked_uuids.end(), itr->first) == tracked_uuids.end()) {
unused_marker_ids.push_back(itr->second);
itr = id_map.erase(itr);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
#ifndef OBJECT_DETECTION__TRACKED_OBJECTS_DISPLAY_HPP_
#define OBJECT_DETECTION__TRACKED_OBJECTS_DISPLAY_HPP_

#include <object_detection/object_polygon_display_base.hpp>

#include <autoware_auto_perception_msgs/msg/tracked_objects.hpp>

#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>

#include <list>
#include <map>
#include <object_detection/object_polygon_display_base.hpp>
#include <string>
#include <vector>

Expand All @@ -31,7 +34,7 @@ namespace object_detection
{
/// \brief Class defining rviz plugin to visualize TrackedObjects
class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC TrackedObjectsDisplay
: public ObjectPolygonDisplayBase<autoware_auto_perception_msgs::msg::TrackedObjects>
: public ObjectPolygonDisplayBase<autoware_auto_perception_msgs::msg::TrackedObjects>
{
Q_OBJECT

Expand Down Expand Up @@ -65,8 +68,7 @@ class AUTOWARE_AUTO_PERCEPTION_RVIZ_PLUGIN_PUBLIC TrackedObjectsDisplay
auto itr = id_map.begin();
while (itr != id_map.end()) {
if (
std::find(tracked_uuids.begin(), tracked_uuids.end(), itr->first) == tracked_uuids.end())
{
std::find(tracked_uuids.begin(), tracked_uuids.end(), itr->first) == tracked_uuids.end()) {
unused_marker_ids.push_back(itr->second);
itr = id_map.erase(itr);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// Co-developed by Tier IV, Inc. and Apex.AI, Inc.

#include <common/color_alpha_property.hpp>

#include <memory>

namespace autoware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
//
// Co-developed by Tier IV, Inc. and Apex.AI, Inc.

#include <memory>
#include <object_detection/detected_objects_display.hpp>

#include <memory>

namespace autoware
{
namespace rviz_plugins
{
namespace object_detection
{
DetectedObjectsDisplay::DetectedObjectsDisplay()
: ObjectPolygonDisplayBase("detected_objects") {}
DetectedObjectsDisplay::DetectedObjectsDisplay() : ObjectPolygonDisplayBase("detected_objects") {}

void DetectedObjectsDisplay::processMessage(DetectedObjects::ConstSharedPtr msg)
{
Expand Down
Loading

0 comments on commit 4f9a775

Please sign in to comment.