How to use OpenStreetMap data on Rviz?
I am new to ROS. I want to use data provided by OpenStreetMap and visualize using Rviz. The data is in .osm format.
please help
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
I am new to ROS. I want to use data provided by OpenStreetMap and visualize using Rviz. The data is in .osm format.
please help
See if #q276809 provides some clues.
Possibly osm_cartography could be of use.
There is the osm_cartography
package ( http://wiki.ros.org/osm_cartography?d... ) which might help you.
It transforms OSM data like roads etc. and publishes this as markers.
Maybe try Google next time. This leads you directly to this package. If you then have more questions, you can still come asking questions here.
namespace koordinat_publisher { KoordinatPublisher::KoordinatPublisher(ros::NodeHandle &nodeHandle) : nodeHandle_(nodeHandle) {
if (!readParameters())
{
ROS_ERROR("Could not read parameters.");
ros::requestShutdown();
}
// load the map
m_map_ = lanelet::load(harita, lanelet::Origin({0,0}));
for (auto point : m_map_->pointLayer)
{
point.x() = point.attribute("local_x").asDouble().value();
point.y() = point.attribute("local_y").asDouble().value();
}
path_subscriber_ = nodeHandle_.createTimer(ros::Duration(1), &KoordinatPublisher::markerCallback, this);
marker_pub_ = nodeHandle_.advertise<visualization_msgs::MarkerArray>("visualization_marker", 0);
ROS_INFO("Successfully launched node.");
}
bool KoordinatPublisher::readParameters()
{
if (!nodeHandle_.getParam("harita", harita))
{
return false;
}
return true;
}
}
void koordinat_publisher::KoordinatPublisher::markerCallback(const ros::TimerEvent &) { int i = 785;
visualization_msgs::MarkerArray marker_array;
for (auto lanelet : m_map_->laneletLayer)
{
visualization_msgs::Marker marker;
marker.header.frame_id = "map";
marker.header.stamp = ros::Time();
marker.ns = "my_namespace";
marker.type = visualization_msgs::Marker::LINE_STRIP;
marker.action = visualization_msgs::Marker::ADD;
marker.scale.x = 1.0;
marker.scale.y = 1.0;
marker.scale.z = 1.0;
marker.color.a = 1.0;
marker.color.r = 1.0;
marker.color.g = 0.0;
marker.color.b = 0.0;
std::vector<geometry_msgs::Point> right_bound;
for (auto point : lanelet.rightBound())
{
geometry_msgs::Point tmp;
tmp.x = point.x();
tmp.y = point.y();
tmp.z = 0.0;
right_bound.push_back(tmp);
}
marker.id = i;
marker.points = right_bound;
marker_array.markers.push_back(marker);
i++;
std::vector<geometry_msgs::Point> left_bound;
for (auto point : lanelet.leftBound())
{
geometry_msgs::Point tmp;
tmp.x = point.x();
tmp.y = point.y();
tmp.z = 0.0;
left_bound.push_back(tmp);
}
marker.id = i;
marker.points = left_bound;
marker_array.markers.push_back(marker);
i++;
}
marker_pub_.publish(marker_array);
}
ps: i hope it can help you. i just added the code. there are also one header file and one node(cpp) file.
Asked: 2018-01-12 02:31:29 -0500
Seen: 3,010 times
Last updated: Jan 12 '18
Ros + openstreetmap (osm cartography package)
How to use your custom map for turtlebot navigation in simulation?
Hector Slam Rviz - LIDAR overlapping points [closed]
Is it possible to add topic to Rviz from command line??
base_footprint not being updated on map
Accessing rviz view (Camera + Marker) in rospy