当前位置:网站首页>ROS (25): release a static odometer Odom information
ROS (25): release a static odometer Odom information
2022-07-18 08:54:00 【biter0088】
Sometimes in order to verify that the program can run , You need to enter a odometer information into the program ; Sometimes in order to verify the program before the real vehicle experiment , Need to modify different odometer data ( You can add one in the following code odom_tmp Array of , Or use a cycle to odom_tmp Value change ), The following c++ The code can realize this function :
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();
// Parameters can be changed
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;
// Around the z Shaft rotation 90°
// Parameters can be changed
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);// Show vehicle / The position of radar in the map
ros::Rate rate_10hz(10);
while(ros::ok())
{
odom_pub();
rate_10hz.sleep();
}
return 0;
}
rviz effect :

边栏推荐
- GET 请求和 POST 请求的区别与使用示例
- [2023 school recruitment questions] column planning (non final presentation status, for bloggers' personal reference)
- Application of spectral normalization in Gan with LSTM as discriminator (tensorflow2)
- Trojan virus removal method
- 【LeetCode】11. Lowest Common Ancestor of a Binary Search Tree· 二叉搜索树的最近公共祖先
- In the process of emergency response, what is a good way to find files created on a certain date?
- 数字藏品的版权保护该如何进行
- 移动应用的专项测试【转载~测试工程师全栈技术进阶与实践】
- MySQL中KEY、PRIMARY KEY、UNIQUE KEY、INDEX 的区别
- Leetcode exercise - Sword finger offer 32 - ii Print binary tree II from top to bottom
猜你喜欢

【LeetCode】11. Lowest Common Ancestor of a Binary Search Tree· 二叉搜索树的最近公共祖先

简约不简单的编程语言go

Da Vinci pro's FPGA learning notes 6.2 -- VCs and Verdi development hummingbird e203

【集训DAY4】 Card game【贪心】

(2021 Niuke multi school V) k-king of range (monotonous queue /st table)

(2021 Niuke multi school V) B-boxes (probability expectation)

Modifying background photos and using skills of idea

Innftnews | les billets NFT changeront la façon dont vous participez à l'événement

290页11万字数字农业农村项目规划建设方案2022

【集训DAY3】 Reconstruction of roads【SPFA】
随机推荐
[leetcode string -- public prefix] bm84 Longest Common Prefix
(2021牛客多校五)B-Boxes(概率期望)
国内外知名的待办事项app
如何清理你的电子邮件订阅者名单以改善电子邮件营销
STM32与物联网02-网络数据收发
【Renesas RA6M4开发板之两路PWM驱动】
In the process of emergency response, what is a good way to find files created on a certain date?
【LeetCode】10. Maximum Subarray·最大子数组和
(2021 Niuke multi school V) B-boxes (probability expectation)
【集训DAY2】Torch bearer【暴力】【DFS】
黑龙江“智慧林草”顶层规划方案
[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
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) - B, C, D
sql计算前top n%的数据
(codeforce319) b.psychos in a line (monotone stack)
How to open slow query log in docker MySQL container
【Leetcode周赛--字符串】6114.移动片段得到字符串
简约不简单的编程语言go
Lambda expression 2: method reference
同花顺开户安全吗,同属顺是证券公司吗?