Rviz中使用Marker工具

本文是关于ROS的Rviz工具使用教程,重点介绍如何使用Marker展示基本形状。通过实例展示了在C++中发送基本形状的Marker,并解释了如何在Rviz配置中添加和显示Marker,包括交互式Marker的创建。读者可以跟随教程实现一个每秒变换的3D视图标记效果。
摘要由CSDN通过智能技术生成

上海硅步ROS连载系列43期 RViz工具使用实操

https://mp.weixin.qq.com/s?__biz=MzA5NjkyMzI2OA==&mid=2651197718&idx=2&sn=8d070f799a1af5e61fe733d4b027c89f&chksm=8b5a0afdbc2d83eb769a9940cc75cb659caae47b721a286d8f66001bcf2cf40a2ed08d649666&mpshare=1&scene=23&srcid=01064eHZkk3FH5BeL83PPE0P#rd

Rviz教程-Marker:发送基本的形状(C++)

http://blog.csdn.net/wilylcyu/article/details/56489676

rviz–显示类型-Marker

http://blog.csdn.net/wilylcyu/article/details/57080917

ROS学习笔记(八)::RVIZ::Interactive Markers: Writing a Simple Interactive Marker Server

http://blog.csdn.net/u011104647/article/details/50424687

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace

cd ~/catkin_ws/
catkin_make
source devel/setup.bash
  • 1
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在ROS,Visualiztion::marker是用于在RViz可视化数据的常用工具之一。下面是一个简单的例子: 假设我们有一个名为“/my_marker”的话题,我们想在RViz显示一个立方体,我们可以使用以下代码: ```cpp #include <ros/ros.h> #include <visualization_msgs/Marker.h> int main( int argc, char** argv ) { ros::init(argc, argv, "my_marker_publisher"); ros::NodeHandle n; ros::Publisher marker_pub = n.advertise<visualization_msgs::Marker>("my_marker", 1); // Set the frame ID and timestamp. See the TF tutorials for information on these. visualization_msgs::Marker marker; marker.header.frame_id = "my_frame"; marker.header.stamp = ros::Time::now(); // Set the namespace and id for this marker. This serves to create a unique ID // Any marker sent with the same namespace and id will overwrite the old one marker.ns = "basic_shapes"; marker.id = 0; // Set the marker type. Initially this is CUBE, and cycles between that and SPHERE, ARROW, and CYLINDER marker.type = visualization_msgs::Marker::CUBE; // Set the pose of the marker. This is a full 6DOF pose relative to the frame/time specified in the header marker.pose.position.x = 1; marker.pose.position.y = 1; marker.pose.position.z = 1; marker.pose.orientation.x = 0.0; marker.pose.orientation.y = 0.0; marker.pose.orientation.z = 0.0; marker.pose.orientation.w = 1.0; // Set the scale of the marker -- 1x1x1 here means 1m on a side marker.scale.x = 1.0; marker.scale.y = 1.0; marker.scale.z = 1.0; // Set the color -- be sure to set alpha to something non-zero! marker.color.r = 0.0f; marker.color.g = 1.0f; marker.color.b = 0.0f; marker.color.a = 1.0; marker.lifetime = ros::Duration(); // Publish the marker while (marker_pub.getNumSubscribers() < 1) { if (!ros::ok()) { return 0; } ROS_WARN_ONCE("Please create a subscriber to the marker"); sleep(1); } marker_pub.publish(marker); ros::spinOnce(); return 0; } ``` 这个例子,我们创建了一个立方体的visualization_msgs::Marker消息,并将其发布到“/my_marker”话题上。在RViz,我们可以通过添加一个“Marker”显示来查看它。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

狂迷小子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值