Skip to content

Commit

Permalink
Add ability to leave the fixed-lag smoother stopped on construction
Browse files Browse the repository at this point in the history
  • Loading branch information
svwilliams committed Jul 30, 2024
1 parent 89be2bc commit 2c709db
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ namespace fuse_optimizers
struct FixedLagSmootherParams
{
public:
/**
* @brief If true, the state estimator will not start until the start or reset service is called
*/
bool disabled_at_startup { false };

/**
* @brief The duration of the smoothing window in seconds
*/
Expand Down Expand Up @@ -105,6 +110,8 @@ struct FixedLagSmootherParams
void loadFromROS(const ros::NodeHandle& nh)
{
// Read settings from the parameter server
nh.getParam("disabled_at_startup", disabled_at_startup);

fuse_core::getPositiveParam(nh, "lag_duration", lag_duration);

if (nh.hasParam("optimization_frequency"))
Expand Down
2 changes: 2 additions & 0 deletions fuse_optimizers/src/batch_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ BatchOptimizer::BatchOptimizer(
ros::names::resolve(params_.start_service),
&BatchOptimizer::startServiceCallback,
this);

startPlugins();
}

BatchOptimizer::~BatchOptimizer()
Expand Down
8 changes: 5 additions & 3 deletions fuse_optimizers/src/fixed_lag_smoother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ FixedLagSmoother::FixedLagSmoother(
{
params_.loadFromROS(private_node_handle);

// Test for auto-start
autostart();

// Start the optimization thread
optimization_thread_ = std::thread(&FixedLagSmoother::optimizationLoop, this);

Expand All @@ -117,6 +114,11 @@ FixedLagSmoother::FixedLagSmoother(
ros::names::resolve(params_.start_service),
&FixedLagSmoother::startServiceCallback,
this);

if (!params_.disabled_at_startup)
{
start();
}
}

FixedLagSmoother::~FixedLagSmoother()
Expand Down
3 changes: 0 additions & 3 deletions fuse_optimizers/src/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ Optimizer::Optimizer(
loadMotionModels();
loadSensorModels();
loadPublishers();

// Start all the plugins
startPlugins();
}

Optimizer::~Optimizer()
Expand Down

0 comments on commit 2c709db

Please sign in to comment.