Skip to content

Commit

Permalink
Add merge radius option for vertices (#480)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael X. Grey <[email protected]>
  • Loading branch information
mxgrey authored Dec 12, 2023
1 parent 90455dc commit 678b405
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions rmf_traffic_editor/gui/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,7 @@ void Level::draw(
v.draw(
scene,
vertex_radius / drawing_meters_per_pixel,
drawing_meters_per_pixel,
vertex_name_font,
coordinate_system);

Expand Down
24 changes: 24 additions & 0 deletions rmf_traffic_editor/gui/vertex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const vector<pair<string, Param::Type>> Vertex::allowed_params
{ "is_passthrough_point", Param::Type::BOOL },
{ "human_goal_set_name", Param::Type::STRING },
{ "mutex", Param::Type::STRING },
{ "merge_radius", Param::Type::DOUBLE },
};


Expand Down Expand Up @@ -132,6 +133,7 @@ YAML::Node Vertex::to_yaml(const CoordinateSystem& coordinate_system) const
void Vertex::draw(
QGraphicsScene* scene,
const double radius,
const double drawing_meters_per_pixel,
const QFont& font,
const CoordinateSystem& coordinate_system) const
{
Expand Down Expand Up @@ -164,6 +166,19 @@ void Vertex::draw(
const double icon_ring_radius = radius * 2.5;
const double icon_scale = 2.0 * radius / 128.0;

if (const auto r_merge_opt = merge_radius())
{
const double r_merge = *r_merge_opt / drawing_meters_per_pixel;
const QPen radius_pen(selected ? selected_color : Qt::black);
auto* radius_item = scene->addEllipse(
x - r_merge,
y - r_merge,
2 * r_merge,
2 * r_merge,
radius_pen);
radius_item->setZValue(19.0);
}

if (is_holding_point())
{
const double icon_bearing = -135.0 * M_PI / 180.0;
Expand Down Expand Up @@ -343,6 +358,15 @@ bool Vertex::is_charger() const
return it->second.value_bool;
}

std::optional<double> Vertex::merge_radius() const
{
const auto it = params.find("merge_radius");
if (it == params.end())
return std::nullopt;

return it->second.value_double;
}

bool Vertex::is_cleaning_zone() const
{
const auto it = params.find("is_cleaning_zone");
Expand Down
3 changes: 3 additions & 0 deletions rmf_traffic_editor/gui/vertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <map>
#include <string>
#include <vector>
#include <optional>
#include <yaml-cpp/yaml.h>

#include <QColor>
Expand Down Expand Up @@ -58,13 +59,15 @@ class Vertex
void draw(
QGraphicsScene* scene,
const double radius,
const double drawing_meters_per_pixel,
const QFont& font,
const CoordinateSystem& coordinate_system) const;

bool is_parking_point() const;
bool is_holding_point() const;
bool is_cleaning_zone() const;
bool is_charger() const;
std::optional<double> merge_radius() const;

std::string dropoff_ingestor() const;
std::string pickup_dispenser() const;
Expand Down

0 comments on commit 678b405

Please sign in to comment.