当前位置: 首页 > news >正文

hexo到WordPress班级优化大师使用心得

hexo到WordPress,班级优化大师使用心得,国内做视频课程的网站有哪些,晋城 网站建设文章目录 概要解算过程获取初始化点经纬度坐标系转UTM计算航向角发布odom坐标 完整代码 概要 这篇博客主要介绍,如何将GPS_fix、磁偏角转成odom信息。 PS:官方的驱动包中是自带odom信息,但是对于原点的定义尚未找到出处,故自己另外写了一套发…

文章目录

  • 概要
  • 解算过程
    • 获取初始化点
    • 经纬度坐标系转UTM
    • 计算航向角
    • 发布odom坐标
  • 完整代码

概要

这篇博客主要介绍,如何将GPS_fix、磁偏角转成odom信息。
PS:官方的驱动包中是自带odom信息,但是对于原点的定义尚未找到出处,故自己另外写了一套发布odom信息。

解算过程

获取初始化点

第一个获取的GPS_fix点为初始点

initPose.latitude = gpsFix->latitude;
initPose.longitude = gpsFix->longitude;
initPose.altitude = 0;
init = true;

经纬度坐标系转UTM

/*原点经纬度转UTM*/
geographic_msgs::GeoPoint gpInit;
gpInit.latitude = initPose.latitude;
gpInit.longitude = initPose.longitude;
geodesy::UTMPoint ptInit(gpInit);
initX = ptInit.easting;
initY = ptInit.northing;

计算航向角

记得减去当地的磁偏角,在这个网站进行查询。

tf::Quaternion qua;
tf::quaternionMsgToTF(odomMsg->pose.pose.orientation, qua);
double roll, pitch, yaw;//定义存储roll,pitch and yaw的容器
tf::Matrix3x3(qua).getRPY(roll, pitch, yaw); //进行转换
yaw = yaw - 0.5 * M_PI + MagDec / 180.0 * M_PI;

发布odom坐标

  /***publish gps_odom**/
nav_msgs::Odometry odom;
odom.header.stamp = ros::Time::now();
odom.header.frame_id = "odom";
odom.pose.pose.position.x = fixX - initX;
odom.pose.pose.position.y = fixY - initY;
odom.pose.pose.orientation.x=qua.x();
odom.pose.pose.orientation.y=qua.y();
odom.pose.pose.orientation.z=qua.z();
odom.pose.pose.orientation.w=qua.w();        
gpsOdomPub.publish(odom);

完整代码

#include <ros/ros.h>
#include "turtlesim/Pose.h"
#include <sensor_msgs/NavSatFix.h>
#include <geometry_msgs/PoseStamped.h>
#include <geometry_msgs/PolygonStamped.h>
#include <geometry_msgs/QuaternionStamped.h>
#include <geographic_msgs/GeoPoseStamped.h>
#include <geodesy/utm.h>
#include <nav_msgs/Odometry.h>
#include <nav_msgs/Path.h>
#include <math.h>
#include <message_filters/synchronizer.h>
#include <message_filters/subscriber.h>
#include <message_filters/sync_policies/approximate_time.h>
#include <message_filters/time_synchronizer.h>
#include <boost/thread/thread.hpp>
#include <iostream>//全局变量
static double EARTH_RADIUS = 6378.137;//地球半径class OdomPublisher
{public:OdomPublisher();void gpsCallback(const sensor_msgs::NavSatFixConstPtr& gpsFix,const nav_msgs::Odometry::ConstPtr& odomMsg);double rad(double d);private:ros::Publisher state_pub_, smallCarPub, gpsOdomPub;geometry_msgs::PolygonStamped carPolygon;nav_msgs::Path ros_path_;ros::NodeHandle n, nhPrivate;message_filters::Subscriber<sensor_msgs::NavSatFix> *subGPS;message_filters::Subscriber<nav_msgs::Odometry> *subOdom;typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::NavSatFix, nav_msgs::Odometry> syncPolicy;message_filters::Synchronizer<syncPolicy> *sync;bool init;struct my_pose{double latitude;double longitude;double altitude;};my_pose initPose, fixPose;double initX, initY, MagDec;std::string gpsFixTopic, gpsOdomTopic, gpsOdomPubTopic;
};OdomPublisher::OdomPublisher():nhPrivate("~")
{    ROS_INFO("Initialization");nhPrivate.param("gpsFixTopic", gpsFixTopic, std::string("/gps/fix"));nhPrivate.param("gpsOdomTopic", gpsOdomTopic, std::string("/odom"));nhPrivate.param("gpsOdomPubTopic", gpsOdomPubTopic, std::string("/gps_fix/odom"));nhPrivate.getParam("MagDec", MagDec);subGPS = new message_filters::Subscriber<sensor_msgs::NavSatFix> (n, gpsFixTopic.c_str(), 1);subOdom = new message_filters::Subscriber<nav_msgs::Odometry> (n, gpsOdomTopic.c_str(), 1);sync = new message_filters::Synchronizer<syncPolicy> (syncPolicy(10), *subGPS, *subOdom);sync->registerCallback(boost::bind(&OdomPublisher::gpsCallback, this, _1, _2));state_pub_ = n.advertise<nav_msgs::Path>("/trajectory/gps", 10);smallCarPub = n.advertise<geometry_msgs::PolygonStamped>("/trajectory/car", 10);gpsOdomPub = n.advertise<nav_msgs::Odometry>(gpsOdomPubTopic.c_str(),10);			init = false;
}//角度制转弧度制
double OdomPublisher::rad(double d) 
{return d * 3.1415926 / 180.0;
}void OdomPublisher::gpsCallback(const sensor_msgs::NavSatFixConstPtr& gpsFix,const nav_msgs::Odometry::ConstPtr& odomMsg)
{// ROS_INFO_STREAM("Starting to work!!!");// std::cout << "Starting to work!!!" << std::endl;//初始化if(!init){initPose.latitude = gpsFix->latitude;initPose.longitude = gpsFix->longitude;initPose.altitude = 0;init = true;/*原点经纬度转UTM*/geographic_msgs::GeoPoint gpInit;gpInit.latitude = initPose.latitude;gpInit.longitude = initPose.longitude;geodesy::UTMPoint ptInit(gpInit);initX = ptInit.easting;initY = ptInit.northing;}else{geographic_msgs::GeoPoint gp;gp.latitude = gpsFix->latitude;gp.longitude = gpsFix->longitude;geodesy::UTMPoint pt(gp);double fixX = pt.easting;double fixY = pt.northing;tf::Quaternion qua;tf::quaternionMsgToTF(odomMsg->pose.pose.orientation, qua);double roll, pitch, yaw;//定义存储roll,pitch and yaw的容器tf::Matrix3x3(qua).getRPY(roll, pitch, yaw); //进行转换yaw = yaw - 0.5 * M_PI + MagDec / 180.0 * M_PI;qua.setRPY(0,0,yaw);// ROS_INFO("After optmized, yaw is %f", yaw);/***publish gps_odom**/nav_msgs::Odometry odom;odom.header.stamp = ros::Time::now();odom.header.frame_id = "odom";odom.pose.pose.position.x = fixX - initX;odom.pose.pose.position.y = fixY - initY;odom.pose.pose.orientation.x=qua.x();odom.pose.pose.orientation.y=qua.y();odom.pose.pose.orientation.z=qua.z();odom.pose.pose.orientation.w=qua.w();        gpsOdomPub.publish(odom);ros_path_.header.frame_id = "odom";ros_path_.header.stamp = ros::Time::now();  geometry_msgs::PoseStamped pose;pose.header = ros_path_.header;pose.pose.position = odom.pose.pose.position;ros_path_.poses.push_back(pose);state_pub_.publish(ros_path_);}
}int main(int argc,char **argv)
{ros::init(argc,argv,"gps_fix");OdomPublisher op;ros::spin();return 0;
}
http://www.hkea.cn/news/159082/

相关文章:

  • 在工商网上怎么注册公司seo优化博客
  • 免费的小程序怎么赚钱历下区百度seo
  • 河北石家庄最新疫情最新消息优化防疫政策
  • 一站式做网站哪家强新闻小学生摘抄
  • 江西南昌网站建设公司哪家好谷歌google 官网下载
  • 公司网站用什么开发百度指数怎么用
  • 建站主机 wordpress济南网站万词优化
  • 哈尔滨app开发seo自学网官网
  • 网站答辩ppt怎么做全网关键词云在哪里看
  • 网站建设 视频seo关键词词库
  • 网站应用软件设计成都网站建设技术外包
  • 用哪个软件做网站网址查询域名解析
  • 网站安全优化域名停靠浏览器
  • 我做中医培训去哪个网站找学员谷歌排名算法
  • 如何将网站让百度收录网店培训班
  • wordpress旧版页面编辑界面百度seo推广计划类型包括
  • 网站建设茶店网网站换友链平台
  • 珠海建设工程信息网站网络营销百度百科
  • 帮别人做网站推广犯法吗关键词排名网站
  • 建设通网站是政府的么高端网站定制设计
  • 玉溪做网站的公司夸克搜索网页版
  • wordpress导航主题haowseo挂机赚钱
  • 广州做家教的网站深圳网络推广招聘
  • 锐捷网络公司排名seo技术介绍
  • 新圩做网站公司拼多多代运营一般多少钱
  • 免费网站可以做cpa?短视频营销的优势
  • b2b外贸营销型网站如何做电商赚钱
  • 建设无障碍网站seo分析报告怎么写
  • 电子商务网站开发进什么科目模板自助建站
  • 威海市住房和城乡建设局官方网站北京seo营销公司