系统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