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 & improvements for deleting all markers #189

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
39 changes: 39 additions & 0 deletions include/rviz_visual_tools/rviz_visual_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ class RvizVisualTools
*/
bool deleteAllMarkers();

/**
* \brief Tell Rviz to clear all markers on a particular display in a particular namespace
* \return true if we published a marker message
*/
bool deleteAllMarkers(const std::string& ns);

/**
* \brief Reset the id's of all published markers so that they overwrite themselves in the future
* NOTE you may prefer deleteAllMarkers()
Expand Down Expand Up @@ -1093,6 +1099,39 @@ class RvizVisualTools
/** \brief Pre-load remote control */
void loadRemoteControl();

/** \brief Get the latest ID of arrow_marker_ */
int32_t getArrowId() const;

/** \brief Get the latest ID of sphere_marker_ */
int32_t getSphereId() const;

/** \brief Get the latest ID of block_marker_*/
int32_t getBlockId() const;

/** \brief Get the latest ID of cylinder_marker_*/
int32_t getCylinderId() const;

/** \brief Get the latest ID of mesh_marker_*/
int32_t getMeshId() const;

/** \brief Get the latest ID of text_marker_*/
int32_t getTextId() const;

/** \brief Get the latest ID of cuboid_marker_*/
int32_t getCuboidId() const;

/** \brief Get the latest ID of line_strip_marker_*/
int32_t getLineStripId() const;

/** \brief Get the latest ID of line_list_marker_*/
int32_t getLineListId() const;

/** \brief Get the latest ID of spheres_marker_*/
int32_t getSpheresId() const;

/** \brief Get the latest ID of triangle_marker_*/
int32_t getTriangleId() const;

protected:
// A shared node handle
ros::NodeHandle nh_;
Expand Down
65 changes: 64 additions & 1 deletion src/rviz_visual_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ bool RvizVisualTools::deleteAllMarkers()
return publishMarker(reset_marker_);
}

bool RvizVisualTools::deleteAllMarkers(const std::string& ns)
{
visualization_msgs::Marker delete_ns_marker = reset_marker_;
delete_ns_marker.header.stamp = ros::Time();
delete_ns_marker.ns = ns;
return publishMarker(delete_ns_marker);
}

void RvizVisualTools::resetMarkerCounts()
{
arrow_marker_.id++;
Expand All @@ -101,7 +109,7 @@ bool RvizVisualTools::loadRvizMarkers()
// Load reset marker -------------------------------------------------
reset_marker_.header.frame_id = base_frame_;
reset_marker_.header.stamp = ros::Time();
reset_marker_.ns = "deleteAllMarkers"; // helps during debugging
reset_marker_.ns = ""; // needs to be empty in order for rviz to delete all markers in all namespaces
reset_marker_.action = 3; // TODO(davetcoleman): In ROS-J set to visualization_msgs::Marker::DELETEALL;
reset_marker_.pose.orientation.w = 1;

Expand Down Expand Up @@ -2875,4 +2883,59 @@ void RvizVisualTools::loadRemoteControl()
}
}

int32_t RvizVisualTools::getArrowId() const
{
return arrow_marker_.id;
}

int32_t RvizVisualTools::getSphereId() const
{
return sphere_marker_.id;
}

int32_t RvizVisualTools::getBlockId() const
{
return block_marker_.id;
}

int32_t RvizVisualTools::getCylinderId() const
{
return cylinder_marker_.id;
}

int32_t RvizVisualTools::getMeshId() const
{
return mesh_marker_.id;
}

int32_t RvizVisualTools::getTextId() const
{
return text_marker_.id;
}

int32_t RvizVisualTools::getCuboidId() const
{
return cuboid_marker_.id;
}

int32_t RvizVisualTools::getLineStripId() const
{
return line_strip_marker_.id;
}

int32_t RvizVisualTools::getLineListId() const
{
return line_list_marker_.id;
}

int32_t RvizVisualTools::getSpheresId() const
{
return spheres_marker_.id;
}

int32_t RvizVisualTools::getTriangleId() const
{
return triangle_marker_.id;
}

} // namespace rviz_visual_tools