2 #include "rosabridge_msgs/Imu.h" 3 #include "rosabridge_msgs/ImuCovariances.h" 4 #include "rosabridge_msgs/RequestImuCovariances.h" 5 #include <sensor_msgs/Imu.h> 15 ROS_INFO(
"Received SIGINT signal, shutting down...");
26 void imu_callback(
const rosabridge_msgs::Imu::ConstPtr& imuMsg);
52 ROS_INFO_STREAM(
"imu_topic: " << imu_topic);
55 imu_msg.orientation_covariance.assign(0);
56 imu_msg.angular_velocity_covariance.assign(0);
57 imu_msg.linear_acceleration_covariance.assign(0);
63 imu_msg.header.stamp = imuMsg->header.stamp;
67 imu_msg.header.frame_id = imuMsg->header.frame_id;
68 imu_msg.orientation.x = imuMsg->orientation.x;
69 imu_msg.orientation.y = imuMsg->orientation.y;
70 imu_msg.orientation.z = imuMsg->orientation.z;
71 imu_msg.orientation.w = imuMsg->orientation.w;
72 imu_msg.linear_acceleration.x = imuMsg->linear_acceleration.x;
73 imu_msg.linear_acceleration.y = imuMsg->linear_acceleration.y;
74 imu_msg.linear_acceleration.z = imuMsg->linear_acceleration.z;
75 imu_msg.angular_velocity.x = imuMsg->angular_velocity.x;
76 imu_msg.angular_velocity.y = imuMsg->angular_velocity.y;
77 imu_msg.angular_velocity.z = imuMsg->angular_velocity.z;
78 imu_msg.orientation_covariance[0] = imuMsg->orientation_covariance[0];
79 imu_msg.orientation_covariance[4] = imuMsg->orientation_covariance[1];
80 imu_msg.orientation_covariance[8] = imuMsg->orientation_covariance[2];
81 imu_msg.linear_acceleration_covariance[0] = imuMsg->linear_acceleration_covariance[0];
82 imu_msg.linear_acceleration_covariance[4] = imuMsg->linear_acceleration_covariance[1];
83 imu_msg.linear_acceleration_covariance[8] = imuMsg->linear_acceleration_covariance[2];
84 imu_msg.angular_velocity_covariance[0] = imuMsg->angular_velocity_covariance[0];
85 imu_msg.angular_velocity_covariance[4] = imuMsg->angular_velocity_covariance[1];
86 imu_msg.angular_velocity_covariance[8] = imuMsg->angular_velocity_covariance[2];
94 ROS_INFO(
"Requesting Imu Covariances");
95 imu_client =
nh.
serviceClient<rosabridge_msgs::RequestImuCovariances>(
"rosabridge/imu_covar_srv");
96 rosabridge_msgs::RequestImuCovariances imuCovarSrv;
97 if (imu_client.call(imuCovarSrv))
99 imu_msg.orientation_covariance[0] = imuCovarSrv.response.orientation_covariance[0];
100 imu_msg.orientation_covariance[1] = imuCovarSrv.response.orientation_covariance[1];
101 imu_msg.orientation_covariance[2] = imuCovarSrv.response.orientation_covariance[2];
102 imu_msg.orientation_covariance[3] = imuCovarSrv.response.orientation_covariance[3];
103 imu_msg.orientation_covariance[4] = imuCovarSrv.response.orientation_covariance[4];
104 imu_msg.orientation_covariance[5] = imuCovarSrv.response.orientation_covariance[5];
105 imu_msg.orientation_covariance[6] = imuCovarSrv.response.orientation_covariance[6];
106 imu_msg.orientation_covariance[7] = imuCovarSrv.response.orientation_covariance[7];
107 imu_msg.orientation_covariance[8] = imuCovarSrv.response.orientation_covariance[8];
108 imu_msg.linear_acceleration_covariance[0] = imuCovarSrv.response.linear_acceleration_covariance[0];
109 imu_msg.linear_acceleration_covariance[1] = imuCovarSrv.response.linear_acceleration_covariance[1];
110 imu_msg.linear_acceleration_covariance[2] = imuCovarSrv.response.linear_acceleration_covariance[2];
111 imu_msg.linear_acceleration_covariance[3] = imuCovarSrv.response.linear_acceleration_covariance[3];
112 imu_msg.linear_acceleration_covariance[4] = imuCovarSrv.response.linear_acceleration_covariance[4];
113 imu_msg.linear_acceleration_covariance[5] = imuCovarSrv.response.linear_acceleration_covariance[5];
114 imu_msg.linear_acceleration_covariance[6] = imuCovarSrv.response.linear_acceleration_covariance[6];
115 imu_msg.linear_acceleration_covariance[7] = imuCovarSrv.response.linear_acceleration_covariance[7];
116 imu_msg.linear_acceleration_covariance[8] = imuCovarSrv.response.linear_acceleration_covariance[8];
117 imu_msg.angular_velocity_covariance[0] = imuCovarSrv.response.angular_velocity_covariance[0];
118 imu_msg.angular_velocity_covariance[1] = imuCovarSrv.response.angular_velocity_covariance[1];
119 imu_msg.angular_velocity_covariance[2] = imuCovarSrv.response.angular_velocity_covariance[2];
120 imu_msg.angular_velocity_covariance[3] = imuCovarSrv.response.angular_velocity_covariance[3];
121 imu_msg.angular_velocity_covariance[4] = imuCovarSrv.response.angular_velocity_covariance[4];
122 imu_msg.angular_velocity_covariance[5] = imuCovarSrv.response.angular_velocity_covariance[5];
123 imu_msg.angular_velocity_covariance[6] = imuCovarSrv.response.angular_velocity_covariance[6];
124 imu_msg.angular_velocity_covariance[7] = imuCovarSrv.response.angular_velocity_covariance[7];
125 imu_msg.angular_velocity_covariance[8] = imuCovarSrv.response.angular_velocity_covariance[8];
129 ROS_WARN(
"Failed to retrieve Imu Covariances");
135 ROS_INFO(
"Subscribing to topic rosabridge/imu");
138 ROS_INFO(
"Relaying between topics...");
146 int main(
int argc,
char **argv)
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL void spin(Spinner &spinner)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
int main(int argc, char **argv)
#define ROS_INFO_STREAM(args)
ROSCPP_DECL void shutdown()
void imu_callback(const rosabridge_msgs::Imu::ConstPtr &imuMsg)
void mySigintHandler(int sig)