StatusPublisher.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * The MIT License (MIT)
4 *
5 * Copyright (c) 2018 Bluewhale Robot
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 * Author: Xie fusheng
26 * Randoms
27 *******************************************************************************/
28 
29 #ifndef STATUSPUBLISHER_H
30 #define STATUSPUBLISHER_H
31 
32 #include <boost/thread.hpp>
33 #include <boost/assign/list_of.hpp>
34 #include <algorithm>
36 #include <sensor_msgs/PointField.h>
37 #include "geometry_msgs/Pose2D.h"
38 #include "geometry_msgs/Twist.h"
39 #include "geometry_msgs/Vector3.h"
40 #include "ros/ros.h"
41 #include "nav_msgs/Odometry.h"
42 #include "std_msgs/Int32.h"
43 #include "std_msgs/Float64.h"
45 
46 #define PI 3.14159265
47 
48 namespace xiaoqiang_driver
49 {
50 typedef struct
51 {
52  int status; //小车状态,0表示未初始化,1表示正常,-1表示error
53  float power; //电源电压【9 13】v
54  float theta; //方位角,【0 360)°
55  int encoder_ppr; //车轮1转对应的编码器个数
56  int encoder_delta_r; //右轮编码器增量, 个为单位
57  int encoder_delta_l; //左轮编码器增量, 个为单位
58  int encoder_delta_car; //两车轮中心位移,个为单位
59  int omga_r; //右轮转速 个每秒
60  int omga_l; //左轮转速 个每秒
61  float distance1; //第一个超声模块距离值 单位cm
62  float distance2; //第二个超声模块距离值 单位cm
63  float distance3; //第三个超声模块距离值 单位cm
64  float distance4; //第四个超声模块距离值 单位cm
65  float IMU[9]; // mpu9250 9轴数据
66  unsigned int time_stamp; //时间戳
68 
70 {
71 public:
73  StatusPublisher(double separation, double radius);
74  void Refresh();
75  void Update(const char* data, unsigned int len);
76  double get_wheel_separation();
77  double get_wheel_radius();
78  int get_wheel_ppr();
79  int get_status();
80  geometry_msgs::Pose2D get_CarPos2D();
81  void get_wheel_speed(double speed[2]);
82  geometry_msgs::Twist get_CarTwist();
83  std_msgs::Float64 get_power();
84  nav_msgs::Odometry get_odom();
86 
87 private:
88  // Wheel separation, wrt the midpoint of the wheel width: meters
90 
91  // Wheel radius (assuming it's the same for the left and right wheels):meters
92  double wheel_radius;
93 
94  geometry_msgs::Pose2D CarPos2D; //小车开始启动原点坐标系
95  geometry_msgs::Twist CarTwist; //小车自身坐标系
96  std_msgs::Float64 CarPower; // 小车电池信息
97  nav_msgs::Odometry CarOdom; // 小车位置和速度信息
106 
107  bool mbUpdated;
108 
109  boost::mutex mMutex;
110 };
111 
112 } // namespace xiaoqiang_driver
113 
114 #endif // STATUSPUBLISHER_H
geometry_msgs::Pose2D get_CarPos2D()
geometry_msgs::Pose2D CarPos2D
geometry_msgs::Twist get_CarTwist()
void get_wheel_speed(double speed[2])
void Update(const char *data, unsigned int len)


xiaoqiang_driver
Author(s): Xie fusheng
autogenerated on Mon Jun 10 2019 15:53:12