-
Notifications
You must be signed in to change notification settings - Fork 112
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
Expose Ceres Solver, Problem and Covariance Options as ROS parameters #78
Expose Ceres Solver, Problem and Covariance Options as ROS parameters #78
Conversation
@@ -58,7 +58,7 @@ | |||
#include <memory> | |||
#include <string> | |||
|
|||
// Required by make_aligned_shared, that uses Eigen::aligned_allocator<T>(). | |||
// Required by __MAKE_SHARED_ALIGNED_DEFINITION, that uses Eigen::aligned_allocator<T>(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply updating the comment, because we finally don't use make_aligned_shared
, which doesn't exist.
* | ||
* @param[in] node_handle - The node handle used to load the parameter | ||
* @param[in] parameter_name - The parameter name to load | ||
* @param[in] default_value - A default value to use if the provided parameter name does not exist | ||
* @return The loaded (or default) value | ||
*/ | ||
double getPositiveParam(const ros::NodeHandle& node_handle, const std::string& parameter_name, double default_value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the end I don't really use getPositiveParam
for integral types, but I think this change is for good, although it'd be great to have this function in a more generic place. Either way, if you don't like this, it's in its own commit, so it's easy drop it from this PR.
0ed3490
to
c2949ba
Compare
Sorry it is taking me so long to go through this one. I will eventually get some version of this merged, hopefully next week. It was on my ToDo list to support setting Ceres parameters, so thanks for beating me to it. |
c2949ba
to
ef1180f
Compare
There shouldn't be any |
ef1180f
to
96c8e41
Compare
I've just rebased this PR and added the changes from locusrobotics/fuse_rl#22 here. FYI @ayrton04 @svwilliams |
@efernandez on your slam toolbox link, trust me the fact that nearly the defaults were the best is not lost on me. I probably spent 2 weeks thinking how much smarter I was than the Ceres guys trying out combinations to come crawling back. I learned alot so shrug. Anyhow reason I comment- there are some parameters I did not include as a "don't give them enough rope to hang themselves" I see that you've exposed parameters for both line search and trust region strategies, which for most applications (at least I'm imagining this being used for) line search seems to be a bad choice, and many of the parameters only do things in certain modes. Removing those would simplify the overwhelming number of choices to the things that people will actually want to focus in on. |
Thanks for you comment @SteveMacenski . I really appreciate your effort to analyse the different options. It's a shame though that defaults are almost the best combination, except fo the pre-conditioner, which is actually slightly faster with I decided to expose all options because I don't know if someone wants to play with any of them, but you're right that some options are only used for certain types of solvers. I'm happy to drop some options if that's always the case, or document which options are the most relevant ones. That way it'd be clear to the user what options are those by just looking at this package, although ceres already does a good job at documenting all options. 😃 |
@efernandez fair enough -- just thought I'd mention it. I'm always a fan of giving every single little dial they can turn, and especially since this is supposed to be general, it makes sense. I looked at the structure and think "huh this really seems designed towards localization/slam/filtering" which fit trust region over line search categorically so there's an opportunity to simplify since about 50% of the parameters don't do anything in trust region. If nothing else Ceres docs exist and this thread 👍 |
Not sure why the checks failed. I've rebased this on top of |
This is for the Xenial build. There were no errors in the Bionic build.
I'm guessing the default version of Ceres in Xenial doesn't have that parameter? |
96c8e41
to
cde1523
Compare
Thanks @svwilliams . I just fixed it. The This commit introduced that changed: ceres-solver/ceres-solver@14d8297 (also mentioned in the code now) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry this took so long to approve. And what I wouldn't give for a Ceres-maintained INI file reader.
ros::NodeHandle private_node_handle("~"); | ||
fuse_graphs::HashGraphParams hash_graph_params; | ||
hash_graph_params.loadFromROS(private_node_handle); | ||
fuse_optimizers::FixedLagSmoother optimizer(fuse_graphs::HashGraph::make_unique(hash_graph_params.problem_options)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you made a HashGraphParams object, it would probably make sense to pass the whole struct to the HashGraph constructor, rather than just the problem_options
field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Done.
@@ -0,0 +1,188 @@ | |||
/*************************************************************************** | |||
* Copyright (C) 2019 Clearpath Robotics. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This license is probably going to have to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. Would you guys change it before merging?
namespace ceres | ||
{ | ||
|
||
bool StringtoLoggingType(std::string value, LoggingType* type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, it looks like I have this the other way around. Fixing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
d337a74
to
a5d4b0e
Compare
refs CORE-13949
refs CORE-13949
refs CORE-13949
refs CORE-13949 It accepts integral and floating point types only.
That use Eigen::aligned_allocator
refs CORE-13949 Instead of ceres::Problem::Options directly.
a5d4b0e
to
e850e5e
Compare
Thanks, I just realized I removed the serialization headers by mistake while solving some conflicts after rebasing. 😃 |
This allows to set all
ceres::Solver::Options
,ceres::Problem::Options
andceres::Covariance::Options
using ROS parameters.The motivation is to tune the solver and problem for better performance or accuracy, after looking at the tuning results shown in the plots at https://github.com/SteveMacenski/slam_toolbox , which was shared with me by @svwilliams . Unfortunately, it looks like the best configuration is almost the same as the default one 😆 , except for the
preconditioner_type
option, which defaults toJACOBI
but it's set toSCHUR_JACOBI
, which indeed make things a little faster for me (from 55 to 49% CPU with myfuse_rl
configuration).Either way, I think this is useful to tune things with other goals in mind, like accuracy, debugging, and still performance. TBH I haven't played a lot with the options/parameters, other than confirming things are being set and used internally.
I also suspect the
enable_fast_removal
option doesn't make a big different for theceres::Problem
because I think it's built from scratch every time.I took the list of options from the latest version of Ceres, which will be
2.0.0
, but also supported1.13.x
: