-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add shape messages and converters * Add autonomy messages and associated converters * Remove deleted items (i.e. sing) from Robot * Fix conversions and usage to reflect RobotIntent changes * Debug drawer * Formatting * Formatting * Formatting * Fix include * Fix RTP conversions with new intent format * Link to rj_drawing_msgs * Make song optional in log frame * Fix test * Fix tests 2 electric boogaloo * Tidy * Formatting and nolint * Fix TODO * Pretty fixes and TODO #s * Trailing newline * Fix review comments, cleanup
- Loading branch information
Showing
19 changed files
with
207 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# ====================================================================== | ||
# Preamble | ||
# ====================================================================== | ||
cmake_minimum_required(VERSION 3.16) | ||
project(rj_drawing_msgs) | ||
|
||
# ====================================================================== | ||
# Find package | ||
# ====================================================================== | ||
find_package(ament_cmake REQUIRED) | ||
find_package(rosidl_default_generators REQUIRED) | ||
find_package(rj_geometry_msgs REQUIRED) | ||
find_package(std_msgs REQUIRED) | ||
find_package(builtin_interfaces REQUIRED) | ||
|
||
# ====================================================================== | ||
# Define Targets | ||
# ====================================================================== | ||
# This creates the target rj_drawing_msgs__rosidl_typesupport_cpp | ||
rosidl_generate_interfaces( | ||
rj_drawing_msgs | ||
# Messages | ||
msg/DebugDraw.msg | ||
msg/DrawColor.msg | ||
msg/DrawShapes.msg | ||
msg/DrawSegment.msg | ||
msg/DrawPose.msg | ||
msg/DrawPath.msg | ||
msg/DrawText.msg | ||
|
||
DEPENDENCIES | ||
std_msgs | ||
builtin_interfaces | ||
rj_geometry_msgs) | ||
|
||
# ====================================================================== | ||
# ROS2 packaging | ||
# ====================================================================== | ||
ament_export_dependencies(rosidl_default_runtime) | ||
ament_package() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
builtin_interfaces/Time stmp | ||
|
||
string layer | ||
|
||
DrawShapes[] shapes | ||
DrawSegment[] segments | ||
DrawPose[] poses | ||
DrawPath[] paths | ||
DrawText[] debug_text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
int8 r | ||
int8 g | ||
int8 b | ||
int8 a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Represents a 2-dimensional path (with no velocity/time component). | ||
rj_geometry_msgs/Point[] points | ||
|
||
# If this has one element, the whole path is the same color. Otherwise, each point gets its own color. | ||
DrawColor[] colors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
rj_geometry_msgs/Pose pose | ||
DrawColor color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
rj_geometry_msgs/Segment segment | ||
DrawColor color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
rj_geometry_msgs/ShapeSet shapes | ||
DrawColor color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
string text | ||
rj_geometry_msgs/Point position | ||
DrawColor color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>rj_drawing_msgs</name> | ||
<version>0.0.0</version> | ||
<description>TODO: Package description</description> | ||
<maintainer email="[email protected]">Kyle Stachowicz</maintainer> | ||
<maintainer email="[email protected]">Oswin So</maintainer> | ||
<license>TODO: License declaration</license> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
<buildtool_depend>rosidl_default_generators</buildtool_depend> | ||
|
||
<depend>std_msgs</depend> | ||
<depend>rj_geometry_msgs</depend> | ||
|
||
<member_of_group>rosidl_interface_packages</member_of_group> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "debug_draw_interface.hpp" | ||
|
||
#include <rj_constants/topic_names.hpp> | ||
|
||
namespace ros2_temp { | ||
|
||
constexpr size_t kDebugDrawQueueSize = 10; | ||
|
||
DebugDrawInterface::DebugDrawInterface(Context* context, rclcpp::Executor* executor) | ||
: context_(context) { | ||
node_ = std::make_shared<rclcpp::Node>("_debug_draw_interface"); | ||
debug_draw_sub_ = node_->create_subscription<rj_drawing_msgs::msg::DebugDraw>( | ||
viz::topics::kDebugDrawPub, rclcpp::QoS(kDebugDrawQueueSize), | ||
[this](rj_drawing_msgs::msg::DebugDraw::SharedPtr debug_draw) { // NOLINT | ||
latest_[debug_draw->layer] = debug_draw; | ||
}); | ||
|
||
executor->add_node(node_); | ||
} | ||
|
||
void DebugDrawInterface::run() { | ||
const auto& color_to_qt = [](const rj_drawing_msgs::msg::DrawColor& color) { | ||
return QColor::fromRgb(color.r, color.g, color.b, color.a); | ||
}; | ||
|
||
for (const auto& [layer, debug_draw] : latest_) { | ||
for (const auto& shapes : debug_draw->shapes) { | ||
context_->debug_drawer.draw_shape_set(rj_convert::convert_from_ros(shapes.shapes), | ||
color_to_qt(shapes.color), | ||
QString::fromStdString(layer)); | ||
} | ||
for (const auto& segment : debug_draw->segments) { | ||
context_->debug_drawer.draw_segment(rj_convert::convert_from_ros(segment.segment), | ||
color_to_qt(segment.color), | ||
QString::fromStdString(layer)); | ||
} | ||
for (const auto& pose : debug_draw->poses) { | ||
// TODO(#1584): Handle poses | ||
} | ||
for (const auto& path : debug_draw->paths) { | ||
auto* debug_path = context_->debug_drawer.add_debug_path(); | ||
for (const auto& point : path.points) { | ||
auto* new_point = debug_path->add_points(); | ||
new_point->mutable_pos()->set_x(point.x); | ||
new_point->mutable_pos()->set_y(point.y); | ||
|
||
// TODO(#1584): Use color in trajectory | ||
} | ||
} | ||
for (const auto& text : debug_draw->debug_text) { | ||
context_->debug_drawer.draw_text( | ||
QString::fromStdString(text.text), rj_convert::convert_from_ros(text.position), | ||
color_to_qt(text.color), QString::fromStdString(layer)); | ||
} | ||
} | ||
} | ||
|
||
} // namespace ros2_temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <rj_drawing_msgs/msg/debug_draw.hpp> | ||
|
||
#include "context.hpp" | ||
|
||
namespace ros2_temp { | ||
|
||
class DebugDrawInterface : public Node { | ||
public: | ||
DebugDrawInterface(Context* context, rclcpp::Executor* executor); | ||
|
||
void run() override; | ||
|
||
private: | ||
rclcpp::Node::SharedPtr node_; | ||
Context* context_; | ||
rclcpp::Subscription<rj_drawing_msgs::msg::DebugDraw>::SharedPtr debug_draw_sub_; | ||
std::unordered_map<std::string, rj_drawing_msgs::msg::DebugDraw::SharedPtr> latest_; | ||
}; | ||
|
||
} // namespace ros2_temp |