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

怎么做一个免费的网站网站建设与管理 教学视频

怎么做一个免费的网站,网站建设与管理 教学视频,wordpress文章缩略图地址标签,嵊州市建设局网站sensor_msgs中常用的一些传感器有imu、图像、点云、激光雷达点云、里程计信息等等信息。接下来&#xff0c;我们俩看一下这些传感器数据&#xff0c;以及数据如何操作。一、pointcloud21&#xff09;随即点云生成pcl::PointCloud<pcl::PointXYZI> pointxyz;pointxyz.widt…

sensor_msgs中常用的一些传感器有imu、图像、点云、激光雷达点云、里程计信息等等信息。

接下来,我们俩看一下这些传感器数据,以及数据如何操作。

一、pointcloud2

1)随即点云生成

   pcl::PointCloud<pcl::PointXYZI> pointxyz;pointxyz.width = 100;pointxyz.height = 1;pointxyz.resize(pointxyz.height * pointxyz.width);srand(time(nullptr));for(int i = 0;i < 100; i ++){pointxyz.points[i].x = (rand()% 1000) / 10.0;pointxyz.points[i].y = (rand()% 1000) / 10.0;pointxyz.points[i].z = (rand()% 1000) / 10.0;}

2)点云的发布和接收

 //-------------------------------------------点云的生成和转化----------------------------顺利完成---------------------// 这个函数在pcl_conversion./pcl_conversion.h文件中sensor_msgs::PointCloud2 pointCloudMsg;pointCloudMsg.header.stamp = ros::Time().now();pointCloudMsg.header.frame_id = "/camera_init";pcl::toROSMsg(pointxyz,pointCloudMsg);pcl::PointCloud<pcl::PointXYZI> pointxyzi2;pcl::fromROSMsg(pointCloudMsg, pointxyzi2);for( int i = 0; i < pointxyzi2.points.size();i ++ ){std::cout<< pointxyzi2.points[i].x<<"   "<< pointxyzi2.points[i].y<<"   "<< pointxyzi2.points[i].z<<"\n";}pcl::PointCloud<pcl::PointXYZI> point3;pcl::moveFromROSMsg(pointCloudMsg,point3);for( int i = 0; i < point3.points.size();i ++ ){std::cout<< point3.points[i].x<<"   "<< point3.points[i].y<<"   "<< point3.points[i].z<<"****\n";}

二、laserscan

  sensor_msgs::LaserScan laserMsg;laserMsg.angle_min = 0.0; // 开始扫描的角度laserMsg.angle_max = 0.0; //结束扫描的角度laserMsg.angle_increment = 60; // 每一次扫描增加的角度laserMsg.time_increment = 0.1; // 测量的时间间隔laserMsg.scan_time = 0.1; //扫描的时间间隔laserMsg.range_min = 1.0; // 距离的最大值laserMsg.range_max = 40.0;  // 距离的最小值laserMsg.ranges.push_back(10); // 激光扫描中存储的一帧数据laserMsg.intensities.push_back(1.0); // 每一个激光点的强度

三、image

1)图像的生成和消息发布

   ros::Subscriber  subImg = nh_.subscribe<sensor_msgs::Image>("/topic_image", 2, &DataProcess::imageCallback, &dp);ros::Publisher pubImg = nh_.advertise<sensor_msgs::Image>("/topic_image", 2);std::string strImgPath = "/home/zhu/pcb_test.png";cv::Mat  img = cv::imread(strImgPath,cv::IMREAD_COLOR);std::cout<< img.rows<<"  "<< img.cols<<std::endl;//发布消息std_msgs::Header header;header.stamp = ros::Time().now();header.frame_id = "/init";sensor_msgs::ImagePtr imgMsgs =   cv_bridge::CvImage(header, sensor_msgs::image_encodings::BGR8,img).toImageMsg();pubImg.publish(imgMsgs);

2)图像的消息接收

    void imageCallback(const sensor_msgs::Image::ConstPtr& imgMsg){cv_bridge::CvImagePtr  imgPtr ;try{imgPtr = cv_bridge::toCvCopy(imgMsg,"bgr8" );}catch(const cv_bridge::Exception& e){std::cerr << e.what() << '\n';return ;}cv::Mat  img = imgPtr->image;double time = imgPtr->header.stamp.toSec();std::string  strEncoding = imgPtr->encoding;std::cout<<"time:"<<time  << "   "<< img.rows<<"  "<< img.cols<<std::endl;}

四、imu

1)imu数据的生成和发布

sensor_msgs::Imu  imuMsg;imuMsg.angular_velocity.x = 0.0;imuMsg.angular_velocity.y = 0;imuMsg.angular_velocity.z = 0;imuMsg.angular_velocity_covariance[0] = 0.0;imuMsg.angular_velocity_covariance.elems[0] = 0.0;imuMsg.header.frame_id = "/camera_init";imuMsg.header.stamp = ros::Time().now();imuMsg.linear_acceleration.x = 0;imuMsg.linear_acceleration.y = 0;imuMsg.linear_acceleration.z = 0;imuMsg.orientation.w = 1.0;imuMsg.orientation.x = 0;imuMsg.orientation.y = 0;imuMsg.orientation.z = 0;ros::Subscriber subImu  =  nh_.subscribe<sensor_msgs::Imu>("/topic_imu", 200, &DataProcess::imuCallback, &dp);ros::Publisher  pubImu = nh_.advertise<sensor_msgs::Imu>("/topic_imu", 200);pubImu.publish(imuMsg);

2)imu的接收

    void imuCallback(const sensor_msgs::Imu::ConstPtr& imuMsg){std::cout<< imuMsg->linear_acceleration.x<< "   "<<  imuMsg->linear_acceleration.y<< "   "<<  imuMsg->linear_acceleration.z<< " \n";}

五、nav_msg

1)由于nav_msg并没有需要什么转换的,直接赋值和直接使用就可以了,所以之介绍一下数据类型。

  nav_msgs::Odometry  odomMsg;odomMsg.header.frame_id = "/camera_init";odomMsg.header.stamp = ros::Time().now();odomMsg.child_frame_id = " child";odomMsg.pose.pose.position.x = 0.0;odomMsg.pose.pose.position.y = 0;odomMsg.pose.pose.position.z = 0;odomMsg.pose.pose.orientation.w = 0.0;odomMsg.pose.pose.orientation.x = 0.0;odomMsg.pose.pose.orientation.y = 0.0;odomMsg.pose.pose.orientation.z = 0.0;odomMsg.twist.twist.angular.x = 0;odomMsg.twist.twist.angular.y = 0;odomMsg.twist.twist.angular.z = 0;odomMsg.twist.twist.linear.x = 0;odomMsg.twist.twist.linear.y = 0;odomMsg.twist.twist.linear.z = 0;

最后来看一个合并后的代码

#include<ros/ros.h>
#include<rosbag/bag.h>
#include<rosbag/view.h>
#include<std_msgs/String.h>
#include<pcl/point_types.h>
#include<pcl/point_cloud.h>
#include<pcl/conversions.h>
#include<pcl_conversions/pcl_conversions.h>
#include<opencv2/opencv.hpp>#include<image_transport/image_transport.h>
#include<cv_bridge/cv_bridge.h>
#include<sensor_msgs/PointCloud2.h>
#include<sensor_msgs/Imu.h>
#include<nav_msgs/Odometry.h>
#include<sensor_msgs/LaserScan.h>class DataProcess
{public:DataProcess(){}public:void processPointCloud2(const sensor_msgs::PointCloud2::ConstPtr& pc){}void imageCallback(const sensor_msgs::Image::ConstPtr& imgMsg){cv_bridge::CvImagePtr  imgPtr ;try{imgPtr = cv_bridge::toCvCopy(imgMsg,"bgr8" );}catch(const cv_bridge::Exception& e){std::cerr << e.what() << '\n';return ;}cv::Mat  img = imgPtr->image;double time = imgPtr->header.stamp.toSec();std::string  strEncoding = imgPtr->encoding;std::cout<<"time:"<<time  << "   "<< img.rows<<"  "<< img.cols<<std::endl;}void imuCallback(const sensor_msgs::Imu::ConstPtr& imuMsg){std::cout<< imuMsg->linear_acceleration.x<< "   "<<  imuMsg->linear_acceleration.y<< "   "<<  imuMsg->linear_acceleration.z<< " \n";}};int main(int argc, char** argv)
{ros::init(argc,argv,"rosbaglearn");ros::NodeHandle nh_;DataProcess  dp;/*第一、消息的订阅和发布*/ros::Subscriber subPointclod2 = nh_.subscribe<sensor_msgs::PointCloud2>("/pointcloud2",2, &DataProcess::processPointCloud2, &dp);//  ros::Publisher pbuLaserCloud = ros::Publisher()ros::Subscriber subPointCLoud2 = nh_.subscribe<sensor_msgs::PointCloud2>("/topic_cloud2", 2, &DataProcess::processPointCloud2, &dp);ros::Publisher pubPointCloud2 = nh_.advertise<sensor_msgs::PointCloud2>("/topic_cloud2", 2);/*点云的转换*/pcl::PointCloud<pcl::PointXYZI> pointxyz;pointxyz.width = 100;pointxyz.height = 1;pointxyz.resize(pointxyz.height * pointxyz.width);srand(time(nullptr));for(int i = 0;i < 100; i ++){pointxyz.points[i].x = (rand()% 1000) / 10.0;pointxyz.points[i].y = (rand()% 1000) / 10.0;pointxyz.points[i].z = (rand()% 1000) / 10.0;}//-------------------------------------------点云的生成和转化----------------------------顺利完成---------------------// 这个函数在pcl_conversion./pcl_conversion.h文件中sensor_msgs::PointCloud2 pointCloudMsg;pointCloudMsg.header.stamp = ros::Time().now();pointCloudMsg.header.frame_id = "/camera_init";pcl::toROSMsg(pointxyz,pointCloudMsg);pcl::PointCloud<pcl::PointXYZI> pointxyzi2;pcl::fromROSMsg(pointCloudMsg, pointxyzi2);for( int i = 0; i < pointxyzi2.points.size();i ++ ){std::cout<< pointxyzi2.points[i].x<<"   "<< pointxyzi2.points[i].y<<"   "<< pointxyzi2.points[i].z<<"\n";}pcl::PointCloud<pcl::PointXYZI> point3;pcl::moveFromROSMsg(pointCloudMsg,point3);for( int i = 0; i < point3.points.size();i ++ ){std::cout<< point3.points[i].x<<"   "<< point3.points[i].y<<"   "<< point3.points[i].z<<"****\n";}// std::cout<< int(pointCloudMsg.data) <<"   "<< int(&point3.points[0])<<"   \n";//--------------------------------------------------------------------------------------------/*---------------------------------------------图像的生成和转化--------------------------------------------------*/ros::Subscriber  subImg = nh_.subscribe<sensor_msgs::Image>("/topic_image", 2, &DataProcess::imageCallback, &dp);ros::Publisher pubImg = nh_.advertise<sensor_msgs::Image>("/topic_image", 2);std::string strImgPath = "/home/zhu/pcb_test.png";cv::Mat  img = cv::imread(strImgPath,cv::IMREAD_COLOR);std::cout<< img.rows<<"  "<< img.cols<<std::endl;//发布消息std_msgs::Header header;header.stamp = ros::Time().now();header.frame_id = "/init";sensor_msgs::ImagePtr imgMsgs =   cv_bridge::CvImage(header, sensor_msgs::image_encodings::BGR8,img).toImageMsg();pubImg.publish(imgMsgs);//  所以图像的中间桥梁就是cv_bridge::CvImagePtr 哈哈哈,这个世界太完美了。/*-----------------------------------------------------------------------------------------------*//*---------------------------------------------------imu消息的收发------start--------------------------------------*/sensor_msgs::Imu  imuMsg;imuMsg.angular_velocity.x = 0.0;imuMsg.angular_velocity.y = 0;imuMsg.angular_velocity.z = 0;imuMsg.angular_velocity_covariance[0] = 0.0;imuMsg.angular_velocity_covariance.elems[0] = 0.0;imuMsg.header.frame_id = "/camera_init";imuMsg.header.stamp = ros::Time().now();imuMsg.linear_acceleration.x = 0;imuMsg.linear_acceleration.y = 0;imuMsg.linear_acceleration.z = 0;imuMsg.orientation.w = 1.0;imuMsg.orientation.x = 0;imuMsg.orientation.y = 0;imuMsg.orientation.z = 0;ros::Subscriber subImu  =  nh_.subscribe<sensor_msgs::Imu>("/topic_imu", 200, &DataProcess::imuCallback, &dp);ros::Publisher  pubImu = nh_.advertise<sensor_msgs::Imu>("/topic_imu", 200);pubImu.publish(imuMsg);ros::Rate loop_rate(10);loop_rate.sleep();/*---------------------------------------------------imu消息的收发------end--------------------------------------*/nav_msgs::Odometry  odomMsg;odomMsg.header.frame_id = "/camera_init";odomMsg.header.stamp = ros::Time().now();odomMsg.child_frame_id = " child";odomMsg.pose.pose.position.x = 0.0;odomMsg.pose.pose.position.y = 0;odomMsg.pose.pose.position.z = 0;odomMsg.pose.pose.orientation.w = 0.0;odomMsg.pose.pose.orientation.x = 0.0;odomMsg.pose.pose.orientation.y = 0.0;odomMsg.pose.pose.orientation.z = 0.0;odomMsg.twist.twist.angular.x = 0;odomMsg.twist.twist.angular.y = 0;odomMsg.twist.twist.angular.z = 0;odomMsg.twist.twist.linear.x = 0;odomMsg.twist.twist.linear.y = 0;odomMsg.twist.twist.linear.z = 0;sensor_msgs::LaserScan laserMsg;laserMsg.angle_min = 0.0; // 开始扫描的角度laserMsg.angle_max = 0.0; //结束扫描的角度laserMsg.angle_increment = 60; // 每一次扫描增加的角度laserMsg.time_increment = 0.1; // 测量的时间间隔laserMsg.scan_time = 0.1; //扫描的时间间隔laserMsg.range_min = 1.0; // 距离的最大值laserMsg.range_max = 40.0;  // 距离的最小值laserMsg.ranges.push_back(10); // 激光扫描中存储的一帧数据laserMsg.intensities.push_back(1.0); // 每一个激光点的强度ros::spin();return 0;
}


文章转载自:

http://HloFVzxY.spLcc.cn
http://F5WdRlQZ.spLcc.cn
http://a0avhnHn.spLcc.cn
http://tQfhsAgg.spLcc.cn
http://ZSRvksMb.spLcc.cn
http://ZiYvkSEa.spLcc.cn
http://sRPZ3mSA.spLcc.cn
http://ijJ0QkIH.spLcc.cn
http://eheTVRvw.spLcc.cn
http://9ruzaXWH.spLcc.cn
http://AfeSzkXR.spLcc.cn
http://PbpkKNxH.spLcc.cn
http://oggEkSLY.spLcc.cn
http://kCxu7I9x.spLcc.cn
http://v8OWFdi6.spLcc.cn
http://KomD50pf.spLcc.cn
http://R7RxP0bG.spLcc.cn
http://AaRvhIJ4.spLcc.cn
http://RGaNcibT.spLcc.cn
http://GZNucNmI.spLcc.cn
http://F7Yv2Zec.spLcc.cn
http://ElQqHAEE.spLcc.cn
http://fc8Yk1Vq.spLcc.cn
http://yJcYzTAE.spLcc.cn
http://pbfFGJtN.spLcc.cn
http://qsQ4c3SM.spLcc.cn
http://WsyMFfkp.spLcc.cn
http://4Y5QHdlv.spLcc.cn
http://1OAgvMxK.spLcc.cn
http://ELVLzbZ2.spLcc.cn
http://www.dtcms.com/wzjs/671948.html

相关文章:

  • 如何建设互联网政务门户网站网站的建设时间
  • 汕头企业网站建站模板joomla做类似赶集网的网站
  • 龙口建网站公司价格男孩做网站
  • 阳逻开发区网站建设中企动力不符合网站外链建设原则的是
  • 网站推广 2015谷歌游戏网页制作代码
  • 人工智能在线ai写作网站最新网页游戏传奇
  • 外网进入学校内局域网建设的网站做外贸网站机构
  • 网站开发所需要的的环境页制作与网站建设技术大全
  • 精选合肥网站建设家具网站建设策划方案
  • 360网站提交wordpress评论不要地址邮箱
  • 游戏网站域名网站编程语言培训机构
  • 建站公司用wordpress网站推广员需要做什么
  • 5118站长工具快速排名推荐
  • 互联网站外推广免费落地页制作平台
  • 杭州高端网站建设公司哪家好帮客户做网站平台犯法吗
  • 一个ip可以建设多少个网站深圳系统网站开发
  • 做网站域名wordpress使用国外主题
  • 最全的数据网站网站的关键词库怎么做的那么多
  • 网站制作素材龙华网站建设多少钱
  • 怎么用python做网站wordpress连续获取下一文章
  • 个人网站设计规划注册网站域名用什么好处
  • 深圳外贸建网站网站关键词排名优化工具
  • 广州有专做网站微商营销软件商城
  • 华阴市住房和城乡建设局网站做网站公司的年终总结
  • 大连市中心是哪个区seo站长工具箱
  • 佛山企业建网站用vs2010做网站并连数据库
  • 云南省城乡住房与建设厅网站泰安求职招聘网
  • 免费网站建设域名北京高端网站建设规划
  • 网站建设教学改进wordpress手机网站模版
  • 重庆微信网站开发osx wordpress