Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed speed of loading interactive markers #20

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading