35 #include <sensor_msgs/Imu.h>
36 #include <std_msgs/Bool.h>
37 #include <std_srvs/Empty.h>
44 : nh_(nh), nh_private_(nh_private)
46 ROS_INFO(
"Starting Phidgets Gyroscope");
54 if (!nh_private.
getParam(
"hub_port", hub_port))
64 double angular_velocity_stdev;
68 angular_velocity_stdev = 0.095 * (M_PI / 180.0);
71 angular_velocity_stdev * angular_velocity_stdev;
77 time_resync_ms = 5000;
80 static_cast<int64_t
>(time_resync_ms) * 1000 * 1000;
83 if (!nh_private.
getParam(
"data_interval_ms", data_interval_ms))
89 int cb_delta_epsilon_ms;
90 if (!nh_private.
getParam(
"callback_delta_epsilon_ms", cb_delta_epsilon_ms))
92 cb_delta_epsilon_ms = 1;
96 if (cb_delta_epsilon_ms >= data_interval_ms)
98 throw std::runtime_error(
99 "Callback epsilon is larger than the data interval; this can never "
118 ROS_INFO(
"Connecting to Phidgets Gyroscope serial %d, hub port %d ...",
119 serial_num, hub_port);
129 serial_num, hub_port,
false,
131 std::placeholders::_1, std::placeholders::_2));
135 gyroscope_->setDataInterval(data_interval_ms);
163 "Calibrating Gyro, this takes around 2 seconds to finish. "
164 "Make sure that the device is not moved during this time.");
172 std_msgs::Bool is_calibrated_msg;
173 is_calibrated_msg.data =
true;
178 std_srvs::Empty::Response &res)
188 std::shared_ptr<sensor_msgs::Imu> msg =
189 std::make_shared<sensor_msgs::Imu>();
193 for (
int i = 0; i < 3; ++i)
195 for (
int j = 0; j < 3; ++j)
200 msg->angular_velocity_covariance[idx] =
211 ROS_WARN(
"Time went backwards (%lu < %lu)! Not publishing message.",
283 uint64_t this_ts_ns =
static_cast<uint64_t
>(timestamp * 1000.0 * 1000.0);
295 if (time_since_last_cb.
toNSec() >=
297 time_since_last_cb.
toNSec() <=
307 "Data not within acceptable window for synchronization: "
308 "expected between %ld and %ld, saw %ld",
311 time_since_last_cb.
toNSec());