Skip to content

Commit db847ca

Browse files
committed
Added try-catch ifor glider optimize
1 parent 763c260 commit db847ca

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

glider/ros/glider_node.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,17 @@ void GliderNode::interpolationCallback()
121121
{
122122
return;
123123
}
124-
int64_t timestamp = latest_imu_timestamp_;
125-
Glider::Odometry odom = glider_->interpolate(timestamp);
126-
124+
int64_t timestamp = latest_imu_timestamp_;
125+
Glider::Odometry odom;
126+
try {
127+
odom = glider_->interpolate(timestamp);
128+
}
129+
catch (const std::exception& e)
130+
{
131+
RCLCPP_WARN(this->get_logger(), "Interpolation error: %s", e.what());
132+
return;
133+
}
134+
127135
if (!odom.isInitialized()) return;
128136
if (publish_nsf_)
129137
{
@@ -178,7 +186,14 @@ void GliderNode::gpsCallback(const sensor_msgs::msg::NavSatFix::ConstSharedPtr m
178186

179187
glider_->addGPS(timestamp, gps);
180188

181-
current_state_ = glider_->optimize();
189+
try {
190+
current_state_ = glider_->optimize();
191+
}
192+
catch (const std::exception& e)
193+
{
194+
RCLCPP_WARN(this->get_logger(), "Optimization error: %s", e.what());
195+
return;
196+
}
182197
if (gps_counter_++ > gps_init_count_)
183198
{
184199
if (!initialized_) initialized_ = true;

0 commit comments

Comments
 (0)