39 #include "sensor_msgs/Imu.h" 40 #include "std_msgs/Float32.h" 41 #include "geometry_msgs/Vector3Stamped.h" 42 #include "geometry_msgs/QuaternionStamped.h" 44 #include <boost/bind.hpp> 55 void msg(
const std_msgs::Float32ConstPtr declination_msg)
64 const sensor_msgs::Imu& imu_in,
65 sensor_msgs::Imu& imu_out)
69 orient_in.
frame_id_ = imu_in.header.frame_id;
75 vel_in.
frame_id_ = imu_in.header.frame_id;
81 accel_in.
frame_id_ = imu_in.header.frame_id;
85 imu_out.header.stamp = imu_in.header.stamp;
86 imu_out.header.frame_id = tf_link;
90 static void handle_imu(
const sensor_msgs::ImuConstPtr& imu_ptr,
103 orient = transform * orient;
110 int main(
int argc,
char **argv)
112 ros::init(argc, argv,
"apply_declination_to_imu");
116 np.
param<std::string>(
"tf_link", tf_link,
"base_link");
118 double declination_rads;
119 np.
param<
double>(
"default", declination_rads, 0.0);
130 boost::bind(
handle_imu, _1, boost::ref(pub_imu), boost::ref(tf_listener),
131 boost::ref(declination_transform), tf_link));
static void handle_imu(const sensor_msgs::ImuConstPtr &imu_ptr, const ros::Publisher &pub_imu, const tf::TransformListener &tf_listener, const DeclinationTransform &transform, std::string tf_link)
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)
static void vector3TFToMsg(const Vector3 &bt_v, geometry_msgs::Vector3 &msg_v)
ROSCPP_DECL void spin(Spinner &spinner)
static void vector3MsgToTF(const geometry_msgs::Vector3 &msg_v, Vector3 &bt_v)
static void quaternionMsgToTF(const geometry_msgs::Quaternion &msg, Quaternion &bt)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
static void quaternionTFToMsg(const Quaternion &bt, geometry_msgs::Quaternion &msg)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void setEuler(const tfScalar &yaw, const tfScalar &pitch, const tfScalar &roll)
int main(int argc, char **argv)
static void imu_to_frame(const tf::TransformListener &tf_listener, std::string &tf_link, const sensor_msgs::Imu &imu_in, sensor_msgs::Imu &imu_out)