Skip to content
Snippets Groups Projects
Commit 94aeca93 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Added optional default layer

parent aeff0300
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,16 @@ namespace armarx
setTopic(component.getTopic<DebugDrawerInterfacePrx>(TOPIC_NAME));
}
const std::string& DebugDrawerTopic::getLayer() const
{
return layerDefault;
}
void DebugDrawerTopic::setLayer(const std::string& layer)
{
this->layerDefault = layer;
}
float DebugDrawerTopic::getPoseScale() const
{
return poseScale;
......@@ -70,6 +80,11 @@ namespace armarx
}
}
void DebugDrawerTopic::clearLayer(bool sleep)
{
clearLayer(layerDefault, sleep);
}
void DebugDrawerTopic::clearLayer(const std::string& layer, bool sleep)
{
if (topic)
......@@ -94,7 +109,7 @@ namespace armarx
{
if (topic)
{
topic->setBoxVisu(layer, name, new Pose(new Vector3(position), new Quaternion(orientation)),
topic->setBoxVisu(theLayer(layer), name, new Pose(new Vector3(position), new Quaternion(orientation)),
new Vector3(extents), color);
}
}
......@@ -137,7 +152,7 @@ namespace armarx
{
if (topic)
{
topic->setArrowVisu(layer, name, new armarx::Vector3(position),
topic->setArrowVisu(theLayer(layer), name, new armarx::Vector3(position),
new armarx::Vector3(direction), color, length, width);
}
}
......@@ -157,6 +172,11 @@ namespace armarx
this->sleepFor(shortSleepDuration);
}
const std::string& DebugDrawerTopic::theLayer(const std::string& passedLayer) const
{
return passedLayer.empty() ? layerDefault : passedLayer;
}
DebugDrawerTopic::operator bool() const
{
return topic;
......
......@@ -53,6 +53,11 @@ namespace armarx
/// Get the topic by calling getTopic([topicName]) on the given component.
void getTopic(ManagedIceObject& component);
/// Get the default layer (used if no layer is passed to the method).
const std::string& getLayer() const;
/// Set the default layer (used if no layer is passed to the method).
void setLayer(const std::string& layerDefault);
/// Get the scale for pose visualization.
float getPoseScale() const;
......@@ -72,9 +77,15 @@ namespace armarx
/// Set the duration for "short sleeps".
void setShortSleepDuration(const std::chrono::milliseconds& duration);
/// Clear all layers.
/// @param sleep If true, do a short sleep clearing.
void clearAll(bool sleep = false);
/// Clear the (set default) layer.
/// @param sleep If true, do a short sleep clearing.
void clearLayer(bool sleep = false);
/// Clear the given layer.
/// @param sleep If true, do a short sleep clearing.
void clearLayer(const std::string& layer, bool sleep = false);
......@@ -83,20 +94,21 @@ namespace armarx
void drawBox(const Eigen::Vector3f& position, const Eigen::Quaternionf& orientation,
const Eigen::Vector3f& extents,
const DrawColor& color, const std::string& name, const std::string& layer);
const DrawColor& color, const std::string& name, const std::string& layer = "");
void drawBox(const Eigen::Matrix4f& pose, const Eigen::Vector3f& extents,
const DrawColor& color, const std::string& name, const std::string& layer);
const DrawColor& color, const std::string& name, const std::string& layer = "");
void drawPose(const Eigen::Matrix4f& pose,
const std::string& name, const std::string& layer = "pose");
const std::string& name, const std::string& layer = "");
void drawPose(const Eigen::Vector3f& pos, const Eigen::Quaternionf& ori,
const std::string& name, const std::string& layer = "pose");
const std::string& name, const std::string& layer = "");
void drawArrow(const Eigen::Vector3f& position, const Eigen::Vector3f& direction,
float length, float width, const DrawColor& color,
const std::string& name, const std::string& layer);
const std::string& name, const std::string& layer = "");
void drawArrowFromTo(const Eigen::Vector3f& from, const Eigen::Vector3f& to, float width,
const DrawColor& color, const std::string& name, const std::string& layer);
const DrawColor& color, const std::string& name, const std::string& layer = "");
/// Indicate whether a topic is set, i.e. visualization is enabled.
......@@ -115,6 +127,9 @@ namespace armarx
/// Sleep for the shortSleepDuration. Useful after clearing.
void shortSleep();
/// Get the layer to draw on. (passedLayer if not empty, otherwise layerDefault).
const std::string& theLayer(const std::string& passedLayer) const;
/// The name of the debug drawer topic.
static const std::string TOPIC_NAME;
......@@ -122,6 +137,9 @@ namespace armarx
/// The debug drawer topic.
DebugDrawerInterfacePrx topic = nullptr;
/// The default layer (used if none is passed to the method).
std::string layerDefault = "debug";
/// Scaling for pose visualization (1 is good when drawing in millimeters).
float poseScale = 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment