当前位置:网站首页>ros(25):发布一个静态的里程计odom信息
ros(25):发布一个静态的里程计odom信息
2022-07-15 18:41:00 【biter0088】
有时为了验证程序可以运行,需要给程序输入一个里程计信息;有时为了在实车实验前验证程序,需要修改不同的里程计数据(可以在下面代码中增加一个odom_tmp的数组,或者用循环来使odom_tmp值变化),下面这个c++代码可以实现这个功能:
pub_odom.cpp
#include "ros/ros.h"
#include "std_msgs/String.h"
#include <geometry_msgs/PoseWithCovarianceStamped.h>
#include <iostream>
#include <geometry_msgs/PoseStamped.h>
#include "nav_msgs/OccupancyGrid.h"
#include "nav_msgs/Odometry.h"
#include <tf/transform_datatypes.h>
#include <tf/transform_broadcaster.h>
#include <Eigen/Dense>
ros::Publisher pubCarpositiopn;
void odom_pub(){
nav_msgs::Odometry odom_tmp;
odom_tmp.header.frame_id = "/camera_init";
odom_tmp.child_frame_id ="/aft_mapped";
odom_tmp.header.stamp = ros::Time::now();
//参数可以改动
odom_tmp.pose.pose.position.x=-0.1;
odom_tmp.pose.pose.position.y=9;
odom_tmp.pose.pose.position.z=0;
// odom_tmp.pose.pose.orientation.x=0;
// odom_tmp.pose.pose.orientation.y=0;
// odom_tmp.pose.pose.orientation.z=0;
// odom_tmp.pose.pose.orientation.w=1;
// 绕z轴旋转90°
//参数可以改动
odom_tmp.pose.pose.orientation.x=0.707;
odom_tmp.pose.pose.orientation.y=0;
odom_tmp.pose.pose.orientation.z=0;
odom_tmp.pose.pose.orientation.w=0.707;
pubCarpositiopn.publish(odom_tmp);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "pub_odom");
ros::NodeHandle nh;
pubCarpositiopn = nh.advertise<nav_msgs::Odometry>("/aft_mapped_to_init", 1);//显示车辆/雷达在地图中的位置
ros::Rate rate_10hz(10);
while(ros::ok())
{
odom_pub();
rate_10hz.sleep();
}
return 0;
}
rviz效果:

边栏推荐
- 【集训DAY2】Sculpture【状压DP】
- 【集训DAY1】Maximum benefit【离散化】【贪心】
- 【集训DAY4】Sequence transformation【思维】
- 【集训DAY4】 Card game【贪心】
- 类加载机制(类如何被加载)
- 【集训DAY4】Forging【期望DP】
- Trial version of several common methods of database table query in SAP ABAP system
- 使用EventLog Analyzer进行实时用户会话跟踪
- 【Leetcode字符串--公共前缀】BM84.最长公共前缀
- 档案的逻辑 | 全宗区分和示例
猜你喜欢

QT (II) UI control introduction and optional tree control demonstration

WPF Visifire.Charts4.6.1使用教程 附含源码

九联科技开发板正式合入OpenHarmony主干

开发命令行工具

蓝帽杯2022初赛电子取证
![[untitled]](/img/1d/f0519a7cd66c1e5a4dd048c71707b9.jpg)
[untitled]

Logic of archives | holonomic distinction and examples

(2021牛客多校三)J-Counting Triangles(思维)

【集训DAY4】Sequence transformation【思维】

290 pages 110000 words digital agriculture rural project planning and construction scheme 2022
随机推荐
Common differences between MySQL and Oracle (2)
IDEA的修改背景照片and使用技巧
[in depth study of 4g/5g/6g topic -36]: urllc-7 - in depth interpretation of 3GPP urllc related protocols, specifications and technical principles -1- business scenarios, evolution routes and performa
Set round avatar -- canvas and paint
Basic learning about MySQL
如何清理你的电子邮件订阅者名单以改善电子邮件营销
Flink 资源管理详解
290页11万字数字农业农村项目规划建设方案2022
Go1.18 upgrade function - fuzzy test | go language from scratch
uniapp自定义头部组件
(codeforce453)A.Little Pony and Expected Maximum(数学期望)
档案的逻辑 | 档案收集工作
一文搞懂Go整合captcha实现验证码功能
Top ten cases of "enterprise digital transformation"!
阿左的心声
建立自己的网站(23)
Selenium使用之解决‘chromedriver‘ executable needs to be in PATH.报错信息
[2023 school recruitment questions] column planning (non final presentation status, for bloggers' personal reference)
无需训练代码,推理性能提升1.4~7.1倍,业界首个自动模型压缩工具开源
[leetcode weekly -- string] 6114 Move the clip to get the string