Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RST-10642] Allow the optimizer to remain disabled at startup #374

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 11 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 Expand Up @@ -456,6 +458,12 @@ bool FixedLagSmoother::startServiceCallback(std_srvs::Empty::Request&, std_srvs:

void FixedLagSmoother::start()
{
if (started_)
{
ROS_WARN_STREAM("Requested to start the optimizer while it is already running. Ignoring request.");
return;
}

ROS_INFO_STREAM("Starting optimizer.");
// Tell all the plugins to start
startPlugins();
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
Loading