|
@@ -15,8 +15,13 @@
|
|
|
#include "imu_data.h"
|
|
|
#include <sensor_msgs/Imu.h>
|
|
|
#include <std_msgs/Float32.h>
|
|
|
+#include "serial_imu_hat_6dof/GetYawData.h"
|
|
|
|
|
|
-
|
|
|
+float response_yaw;
|
|
|
+bool return_yaw_data(serial_imu_hat_6dof::GetYawData::Request &req,serial_imu_hat_6dof::GetYawData::Response &res){
|
|
|
+ res.yaw = response_yaw;
|
|
|
+ return true;
|
|
|
+}
|
|
|
int main(int argc, char **argv)
|
|
|
{
|
|
|
float yaw, pitch, roll;
|
|
@@ -31,6 +36,7 @@ int main(int argc, char **argv)
|
|
|
std::string temp_topic;
|
|
|
std::string yaw_topic;
|
|
|
int pub_hz = 0;
|
|
|
+ std::string yaw_service;
|
|
|
float degree2Rad = 3.1415926/180.0;
|
|
|
float acc_factor = 9.806;
|
|
|
|
|
@@ -49,6 +55,10 @@ int main(int argc, char **argv)
|
|
|
ros::param::get("~yaw_topic", yaw_topic);
|
|
|
ros::param::get("~pub_hz", pub_hz);
|
|
|
|
|
|
+ ros::param::get("~yaw_service", yaw_service);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
int ret = initSerialPort(imu_dev.c_str(), baud, dataBit, parity.c_str(), stopBit);
|
|
|
if(ret < 0)
|
|
|
{
|
|
@@ -60,6 +70,7 @@ int main(int argc, char **argv)
|
|
|
|
|
|
ros::Publisher imu_pub = handle.advertise<sensor_msgs::Imu>(imu_topic, 1);
|
|
|
ros::Publisher yaw_pub = handle.advertise<std_msgs::Float32>(yaw_topic, 1);
|
|
|
+ ros::ServiceServer yaw_srv = handle.advertiseService(yaw_service, return_yaw_data);
|
|
|
ros::Rate loop_rate(pub_hz);
|
|
|
|
|
|
sensor_msgs::Imu imu_msg;
|
|
@@ -77,6 +88,7 @@ int main(int argc, char **argv)
|
|
|
if(yaw >= 3.1415926)
|
|
|
yaw -= 6.2831852;
|
|
|
|
|
|
+ response_yaw = yaw;
|
|
|
//publish yaw data
|
|
|
yaw_msg.data = yaw;
|
|
|
yaw_pub.publish(yaw_msg);
|