Skip to content

Commit

Permalink
Merge pull request #20 from marip8/fix/visualization-speed
Browse files Browse the repository at this point in the history
Fixed speed of loading interactive markers
  • Loading branch information
marip8 authored Jun 15, 2024
2 parents 6168ec6 + 17aa0fa commit c740743
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/reach_ros/display/ros_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class ROSDisplay : public reach::Display
const std::string kinematic_base_frame_;
const double marker_scale_;
const bool use_full_color_range_;

mutable reach::ReachResult db_;
visualization_msgs::Marker collision_marker_;

// ROS comoponents
Expand Down
13 changes: 10 additions & 3 deletions src/display/ros_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,17 @@ void ROSDisplay::showResults(const reach::ReachResult& db) const
{
server_.clear();

// Copy the reach result once into a mutable member variable in order to use it within the lambda
// without having to copy it into every instance of the lambda (which gets expensive for > 300 points)
db_ = db;

// Create a callback for when a marker is clicked on
auto show_goal_cb = [this, db](const visualization_msgs::InteractiveMarkerFeedbackConstPtr& fb) {
std::size_t idx = std::strtoul(fb->marker_name.c_str(), nullptr, 10);
updateRobotPose(db.at(idx).goal_state);
auto show_goal_cb = [this](const visualization_msgs::InteractiveMarkerFeedbackConstPtr& fb) {
if (fb->event_type == visualization_msgs::InteractiveMarkerFeedback::MOUSE_UP)
{
std::size_t idx = std::strtoul(fb->marker_name.c_str(), nullptr, 10);
updateRobotPose(db_.at(idx).goal_state);
}
};

Eigen::MatrixX3f heatmap_colors = reach::computeHeatMapColors(db, use_full_color_range_);
Expand Down

0 comments on commit c740743

Please sign in to comment.