18 #include <geometry_msgs/Point.h> 19 #include <geometry_msgs/Vector3.h> 36 std::string typePrefix;
37 if (!
getParam(
"layer_prefix", typePrefix)) {
38 ROS_ERROR(
"VectorVisualization with name '%s' did not find a 'layer_prefix' parameter.",
name_.c_str());
41 types_.push_back(typePrefix +
"x");
42 types_.push_back(typePrefix +
"y");
43 types_.push_back(typePrefix +
"z");
46 ROS_ERROR(
"VectorVisualization with name '%s' did not find a 'position_layer' parameter.",
name_.c_str());
52 ROS_INFO(
"VectorVisualization with name '%s' did not find a 'scale' parameter. Using default.",
name_.c_str());
56 if (!
getParam(
"line_width", lineWidth_)) {
57 ROS_INFO(
"VectorVisualization with name '%s' did not find a 'line_width' parameter. Using default.",
name_.c_str());
60 int colorValue = 65280;
61 if (!
getParam(
"color", colorValue)) {
62 ROS_INFO(
"VectorVisualization with name '%s' did not find a 'color' parameter. Using default.",
name_.c_str());
73 marker_.action = visualization_msgs::Marker::ADD;
74 marker_.type = visualization_msgs::Marker::LINE_LIST;
84 for (
const auto& type :
types_) {
87 "VectorVisualization::visualize: No grid map layer with name '" << type <<
"' found.");
103 geometry_msgs::Vector3 vector;
104 vector.x = map.
at(types_[0], *iterator);
105 vector.y = map.
at(types_[1], *iterator);
106 vector.z = map.
at(types_[2], *iterator);
108 Eigen::Vector3d position;
110 geometry_msgs::Point startPoint;
111 startPoint.x = position.x();
112 startPoint.y = position.y();
113 startPoint.z = position.z();
114 marker_.points.push_back(startPoint);
116 geometry_msgs::Point endPoint;
117 endPoint.x = startPoint.x +
scale_ * vector.x;
118 endPoint.y = startPoint.y +
scale_ * vector.y;
119 endPoint.z = startPoint.z +
scale_ * vector.z;
120 marker_.points.push_back(endPoint);
VectorVisualization(ros::NodeHandle &nodeHandle, const std::string &name)
double lineWidth_
Width of the line markers [m].
Time getTimestamp() const
void publish(const boost::shared_ptr< M > &message) const
const std::string & getFrameId() const
std::vector< std::string > types_
Types that are transformed to vectors.
double scale_
Scaling of the vectors.
bool isValid(const Index &index) const
virtual ~VectorVisualization()
bool exists(const std::string &layer) const
bool visualize(const grid_map::GridMap &map)
visualization_msgs::Marker marker_
Marker to be published.
bool getParam(const std::string &name, std::string &value)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std_msgs::ColorRGBA color_
Color of the vectors.
#define ROS_WARN_STREAM(args)
float & at(const std::string &layer, const Index &index)
ros::NodeHandle & nodeHandle_
ROS nodehandle.
std::string name_
Name of the visualization.
void setColorFromColorValue(std_msgs::ColorRGBA &color, const unsigned long &colorValue, bool resetTransparency=true)
ros::Publisher publisher_
ROS publisher of the occupancy grid.
bool readParameters(XmlRpc::XmlRpcValue &config)
virtual bool readParameters(XmlRpc::XmlRpcValue &config)
bool getPosition3(const std::string &layer, const Index &index, Position3 &position) const
std::string positionLayer_
Type that is the position of the vectors.