ROS 中订阅odom消息并按行保存到txt中

  系统ubuntu16.04  kinetic     20.04 noetic

想写一个小车寻迹程序,用rostopic echo odom/pose/pose/position > odom.txt  ,保存的数据类型不好用,而且还要用到orientation数据,最好还是自己写一个程序吧程序如下,

#include "ros/ros.h"  //ros需要的头文件
#include <geometry_msgs/Twist.h>
#include <nav_msgs/Odometry.h>
#include "std_msgs/String.h"
//以下为串口通讯需要的头文件
#include <string>        
#include <iostream>
#include <cstdio>
#include <unistd.h>
#include <math.h>
#include <fstream>

/****************************************************************************/
using std::string;
using std::exception;
using std::cout;
using std::cerr;
using std::endl;
using std::vector;

//float x_pre,y_pre,z_pre;
 float x_pre=0.0f;
float y_pre=0.0f;
/************************************************************/

void callback_odom(const nav_msgs::Odometry::ConstPtr& odom)//订阅/odom主题回调函数
{


     
   // geometry_msgs::PoseStamped th
  • 3
    点赞
  • 43
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值