rviz TRIANGLE_LIST三角网的画法

7 篇文章 0 订阅

https://github.com/iralabdisco/ira_open_street_map/blob/master/src/osm_query_node.cpp

这里面有个例子,可以实现

void load_buildinglist()
 {
 buildings.header.frame_id = "map";
 buildings.header.stamp = ros::Time();
 buildings.ns = "buildings";
 buildings.id = 3;
 buildings.type = visualization_msgs::Marker::TRIANGLE_LIST;
 buildings.action = visualization_msgs::Marker::ADD;
 buildings.scale.x = 1.0;
 buildings.scale.y = 1.0;
 buildings.scale.z = 1.0;
 buildings.color.r = 0.0f;
 buildings.color.g = 0.9f;
 buildings.color.b = 0.7f;
 buildings.color.a = 0.75f;
  
 Xy coords_A, coords_B;
 float height = 3.0f;
 geometry_msgs::Point A, h_A, B, h_B;
  
 for(std::set<shared_ptr<Osmium::OSM::Way const> >::iterator way_itr = oh.m_ways.begin(); way_itr != oh.m_ways.end(); way_itr++)
 {
 // Get way-node list
 Osmium::OSM::WayNodeList waylist = (*way_itr)->nodes();
  
 // Use only ways with Key:building
 const char* building_tag = (*way_itr)->tags().get_value_by_key("building");
  
 if(!building_tag)
 continue;
  
 for(Osmium::OSM::WayNodeList::iterator node_list_itr = waylist.begin(); node_list_itr != waylist.end() - 1; node_list_itr++ )
 {
 // Get way-node coordinates
 coords_A = latlon2xy_helper(node_list_itr->position().lat(),node_list_itr->position().lon());
 coords_B = latlon2xy_helper((node_list_itr + 1)->position().lat(),(node_list_itr + 1)->position().lon());
  
 A.x = coords_A.x;
 A.y = coords_A.y;
 A.z = 0.0;
  
 h_A.x = A.x;
 h_A.y = A.y;
 h_A.z = A.z + height;
  
 B.x = coords_B.x;
 B.y = coords_B.y;
 B.z = 0.0;
  
 h_B.x = B.x;
 h_B.y = B.y;
 h_B.z = B.z + height;
  
 buildings.points.push_back(A);
 buildings.points.push_back(h_A);
 buildings.points.push_back(B);
 buildings.points.push_back(B);
 buildings.points.push_back(h_A);
 buildings.points.push_back(h_B);
 }
 }
 }
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值