ROS笔记之visualization_msgs-Marker的mesh_resource学习
code review!
文章目录
- ROS笔记之visualization_msgs-Marker的mesh_resource学习
- 1.运行
- 2.文件结构
- 3.main.cc
参考博文
1.kitti之ros可视化_学习笔记–第4课:车子模型的添加
2.rviz进行kitti数据集可视化时加载小车模型报错
1.运行
2.文件结构
3.main.cc
代码
#include <ros/ros.h>
#include <visualization_msgs/Marker.h>
int main(int argc, char** argv)
{
ros::init(argc, argv, "marker_example");
ros::NodeHandle nh;
ros::Publisher marker_pub = nh.advertise<visualization_msgs::Marker>("visualization_marker", 1);
ros::Rate rate(1); // 发布频率为1Hz
while (ros::ok())
{
visualization_msgs::Marker marker;
marker.header.frame_id = "map";
marker.header.stamp = ros::Time::now();
marker.ns = "mesh_object";
marker.id = 0;
marker.type = visualization_msgs::Marker::MESH_RESOURCE;
marker.action = visualization_msgs::Marker::ADD;
marker.pose.position.x = 0.0;
marker.pose.position.y = 0.0;
marker.pose.position.z = 0.0;
marker.pose.orientation.x = 0.0;
marker.pose.orientation.y = 0.0;
marker.pose.orientation.z = 0.0;
marker.pose.orientation.w = 1.0;
marker.scale.x = 1.0;
marker.scale.y = 1.0;
marker.scale.z = 1.0;
marker.color.r = 1.0;
marker.color.g = 1.0;
marker.color.b = 1.0;
marker.color.a = 1.0;
marker.mesh_resource = "package://ros_templete/mesh/PeugeotOnyxConcept.dae";
marker_pub.publish(marker);
ros::spinOnce();
rate.sleep();
}
return 0;
}