36 #include "sensor_msgs/Imu.h" 37 #include "novatel_oem7_msgs/CORRIMU.h" 38 #include "novatel_oem7_msgs/IMURATECORRIMU.h" 39 #include "novatel_oem7_msgs/INSSTDEV.h" 40 #include "novatel_oem7_msgs/INSCONFIG.h" 41 #include "novatel_oem7_msgs/INSPVA.h" 42 #include "novatel_oem7_msgs/INSPVAX.h" 44 #include <boost/scoped_ptr.hpp> 61 return degrees * M_PI / 180.0;
95 std::string param_name = ns +
"/supported_imus/" + std::to_string(imu_type) +
"/" + name;
107 return std::stoi(rate);
120 insconfig_pub_.
publish(insconfig);
124 std::string imu_desc;
132 if(imu_raw_gyro_scale_factor_ == 0.0 &&
133 imu_raw_accel_scale_factor_ == 0.0)
138 imu_raw_gyro_scale_factor_,
139 imu_raw_accel_scale_factor_))
142 ROS_ERROR_STREAM(
"Scale factors not supported for IMU '" << insconfig->imu_type <<
"'; raw IMU output disabled.");
149 "IMU: " << imu_type <<
" '" << imu_desc <<
"'" 150 <<
" rate= " << imu_rate_
151 <<
" gyro scale= " << imu_raw_gyro_scale_factor_
152 <<
" accel scale= " << imu_raw_accel_scale_factor_);
166 corrimu_pub_.
publish(corrimu_);
179 if(oem7_imu_reference_frame_)
190 imu->orientation_covariance[0] = std::pow(insstdev_->roll_stdev, 2);
191 imu->orientation_covariance[4] = std::pow(insstdev_->pitch_stdev, 2);
192 imu->orientation_covariance[8] = std::pow(insstdev_->azimuth_stdev, 2);
207 imu->orientation =
tf2::toMsg(tf_orientation);
215 if(corrimu_ && corrimu_->imu_data_count && imu_rate_ > 0)
217 double instantaneous_rate_factor = imu_rate_ / corrimu_->imu_data_count;
219 imu->angular_velocity.x = corrimu_->pitch_rate * instantaneous_rate_factor;
220 imu->angular_velocity.y = corrimu_->roll_rate * instantaneous_rate_factor;
221 imu->angular_velocity.z = corrimu_->yaw_rate * instantaneous_rate_factor;
223 imu->linear_acceleration.x = corrimu_->lateral_acc * instantaneous_rate_factor;
224 imu->linear_acceleration.y = corrimu_->longitudinal_acc * instantaneous_rate_factor;
225 imu->linear_acceleration.z = corrimu_->vertical_acc * instantaneous_rate_factor;
234 static const double ZERO_DEGREES_AZIMUTH_OFFSET = 90.0;
235 double azimuth = inspva_->azimuth - ZERO_DEGREES_AZIMUTH_OFFSET;
245 imu->orientation =
tf2::toMsg(tf_orientation);
253 if(corrimu_ && corrimu_->imu_data_count > 0 && imu_rate_ > 0)
255 double instantaneous_rate_factor = imu_rate_ / corrimu_->imu_data_count;
257 imu->angular_velocity.x = corrimu_->roll_rate * instantaneous_rate_factor;
258 imu->angular_velocity.y = -corrimu_->pitch_rate * instantaneous_rate_factor;
259 imu->angular_velocity.z = corrimu_->yaw_rate * instantaneous_rate_factor;
261 imu->linear_acceleration.x = corrimu_->longitudinal_acc * instantaneous_rate_factor;
262 imu->linear_acceleration.y = -corrimu_->lateral_acc * instantaneous_rate_factor;
263 imu->linear_acceleration.z = corrimu_->vertical_acc * instantaneous_rate_factor;
271 insstdev_pub_.
publish(insstdev_);
280 return raw_gyro * imu_raw_gyro_scale_factor_ *
imu_rate_;
288 return raw_acc * imu_raw_accel_scale_factor_ *
imu_rate_;
300 imu_raw_gyro_scale_factor_ == 0.0 ||
301 imu_raw_accel_scale_factor_ == 0.0)
303 ROS_WARN_THROTTLE(10,
"Unavailable or Invalid IMU rate and/or raw scale factors: %i %f %f",
304 imu_rate_, imu_raw_gyro_scale_factor_, imu_raw_accel_scale_factor_);
331 imu_raw_gyro_scale_factor_(0.0),
332 imu_raw_accel_scale_factor_(0.0),
333 oem7_imu_reference_frame_(false)
345 imu_pub_.
setup<sensor_msgs::Imu>(
"IMU", nh);
346 raw_imu_pub_.
setup<sensor_msgs::Imu>(
"RAWIMU", nh);
347 corrimu_pub_.
setup< novatel_oem7_msgs::CORRIMU>(
"CORRIMU", nh);
348 insstdev_pub_.
setup< novatel_oem7_msgs::INSSTDEV>(
"INSSTDEV", nh);
349 inspvax_pub_.
setup< novatel_oem7_msgs::INSPVAX>(
"INSPVAX", nh);
350 insconfig_pub_.
setup<novatel_oem7_msgs::INSCONFIG>(
"INSCONFIG", nh);
354 nh.
getParam(
"imu_gyro_scale_factor", imu_raw_gyro_scale_factor_);
355 nh.
getParam(
"imu_accel_scale_factor", imu_raw_accel_scale_factor_);
357 imu_raw_gyro_scale_factor_ != 0.0 ||
358 imu_raw_accel_scale_factor_ != 0.0)
361 <<
" gyro scale factor= " << imu_raw_gyro_scale_factor_
362 <<
" accel scale factor= " << imu_raw_accel_scale_factor_);
368 if(!nh_.
getParam(
"oem7_imu_reference_frame", oem7_imu_reference_frame_))
370 if(oem7_imu_reference_frame_)
372 ROS_WARN_STREAM(
"INS Reference Frame: using OEM7 (Y-forward) instead of REP105 (X-forward).");
379 static const std::vector<int> MSG_IDS(
boost::shared_ptr< novatel_oem7_msgs::INSSTDEV > insstdev_
void setRPY(const tf2Scalar &roll, const tf2Scalar &pitch, const tf2Scalar &yaw)
void handleMsg(Oem7RawMessageIf::ConstPtr msg)
void publishCorrImuMsg(Oem7RawMessageIf::ConstPtr msg)
double degreesToRadians(double degrees)
void publishInsPVAXMsg(Oem7RawMessageIf::ConstPtr msg)
int imu_rate_t
IMU message output rate. Refer to INSCONFIG in the OEM7 manual.s.
#define ROS_LOG_STREAM(level, name, args)
const std::size_t OEM7_BINARY_MSG_SHORT_HDR_LEN
boost::shared_ptr< novatel_oem7_msgs::CORRIMU > corrimu_
const int INSCONFIG_OEM7_MSGID
void getImuParam(oem7_imu_type_t imu_type, const std::string &name, std::string ¶m)
Oem7RosPublisher inspvax_pub_
const int INSPVAX_OEM7_MSGID
std::map< std::string, std::string > imu_config_map_t
imu_rate_t imu_rate_
IMU output rate.
double imu_raw_gyro_scale_factor_
IMU-specific raw gyroscope scaling.
Oem7RosPublisher insconfig_pub_
bool getImuRawScaleFactors(oem7_imu_type_t imu_type, imu_rate_t imu_rate, double &gyro_scale, double &acc_scale)
boost::shared_ptr< novatel_oem7_msgs::INSPVA > inspva_
double computeLinearAccelerationFromRaw(double raw_acc)
ROSCPP_DECL const std::string & getNamespace()
#define ROS_FATAL_STREAM(args)
#define ROS_WARN_THROTTLE(period,...)
bool getParam(const std::string &key, std::string &s) const
const int INSPVAS_OEM7_MSGID
const int RAWIMUSX_OEM7_MSGID
const std::vector< int > & getMessageIds()
Oem7RosPublisher corrimu_pub_
imu_config_map_t imu_config_map
#define ROS_WARN_STREAM(args)
void publish(boost::shared_ptr< M > &msg)
#define ROS_DEBUG_STREAM(args)
Oem7RosPublisher raw_imu_pub_
void getImuDescription(oem7_imu_type_t imu_type, std::string &desc)
int getImuRate(oem7_imu_type_t imu_type)
PLUGINLIB_EXPORT_CLASS(novatel_oem7_driver::Oem7ConfigNodelet, nodelet::Nodelet)
void processInsConfigMsg(Oem7RawMessageIf::ConstPtr msg)
void initialize(ros::NodeHandle &nh)
const int IMURATECORRIMUS_OEM7_MSGID
void setup(const std::string &name, ros::NodeHandle &nh)
#define ROS_INFO_STREAM(args)
void MakeROSMessage(const Oem7RawMessageIf::ConstPtr &msg, boost::shared_ptr< T > &rosmsg)
const double DATA_NOT_AVAILABLE
Used to initialized unpopulated fields.
Oem7RosPublisher insstdev_pub_
void publishInsStDevMsg(Oem7RawMessageIf::ConstPtr msg)
const int INSSTDEV_OEM7_MSGID
const int CORRIMUS_OEM7_MSGID
double imu_raw_accel_scale_factor_
IMU-specific raw acceleration scaling.
void processRawImuMsg(Oem7RawMessageIf::ConstPtr msg)
oem7_imu_type_t
IMUs supported on OEM7 products; refer to INSCONFIG in the OEM7 manual.
#define ROS_ERROR_STREAM(args)
bool oem7_imu_reference_frame_
Backwards compatibility: use OEM7 reference frame, not compliant with REP105.
Oem7RosPublisher imu_pub_
#define ROSCONSOLE_DEFAULT_NAME
void publishImuMsg_ROS(boost::shared_ptr< sensor_msgs::Imu > &imu)
void publishImuMsg_OEM7(boost::shared_ptr< sensor_msgs::Imu > &imu)
double computeAngularVelocityFromRaw(double raw_gyro)