How to stop ceres::Solve immediately before reaching the termination conditions

341 views
Skip to first unread message

Xiaozhi QU

unread,
May 16, 2018, 6:20:38 AM5/16/18
to Ceres Solver
Hi Sameer, 

I am using Ceres Solver to solve the BA problem for key frames in a sliding window for visual SLAM. Sometimes,  a new key frame is inserted, but the BA for last step is not finished yet. In this case, I would like to stop the old ceres::Solve immediately and launch a new one including the new key frame.  I have already set  the max_solver_time_in_seconds as a small value (0.1s),  but the drift would increase quickly if the value is tool small. Is there any way to set a force stop flag for  ceres::Solve function that I can terminate the function when I want ? 

Many thanks. 

Xiaozhi
Regards

Alex Stewart

unread,
May 16, 2018, 6:23:48 AM5/16/18
to ceres-...@googlegroups.com
You can use a custom IterationCallback to return: SOLVER_CONTINUE or SOLVER_TERMINATE_SUCCESSFULLY after each iteration to respectively continue the solve, or stop it.

-Alex

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/ed1dca07-6294-4ea7-a561-c756bc09deaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Xiaozhi QU

unread,
May 16, 2018, 8:11:41 AM5/16/18
to Ceres Solver
Hi Alex, 

Many thanks for your answer,  it works for me :). 

Regards
Xiaozhi

Vivek Bagaria

unread,
May 11, 2022, 10:35:26 AM5/11/22
to Ceres Solver
Hi Team,

The above technique stops the Solver at the start of an iteration. Is it possible to stop midway of the previous iteration for faster response times? Any hacks using EvaluationCallback?

Thanks in advance
Cheers,
--Vivek

Sameer Agarwal

unread,
May 11, 2022, 10:59:55 AM5/11/22
to ceres-...@googlegroups.com
Run it in a separate thread and kill the thread?

Vivek Bagaria

unread,
May 12, 2022, 12:16:57 AM5/12/22
to ceres-...@googlegroups.com
That is a possible solution. However, I want to use the latest optimized value of the variables (Bundle Adjustment in this case)

--Vivek

You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/qN3Y964uziM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUC5syW4%3DL7q_ZXTQDP2X1tkDkrX_%2BVJk-qLnV1-CgsaYw%40mail.gmail.com.

Sameer Agarwal

unread,
May 12, 2022, 12:20:25 AM5/12/22
to ceres-...@googlegroups.com
Solver::Options:: update_state_every_iteration is your friend.

Vivek Bagaria

unread,
May 12, 2022, 1:51:21 PM5/12/22
to ceres-...@googlegroups.com
Two questions
  1. If IterationCallback terminates the program with `CallbackReturnType::SOLVER_TERMINATE_SUCCESSFULLY`, the update_every_iteration need not be set to true right?
  2. Killing a thread could potentially update the state partially, producing incorrect results. I might be missing something...   

Thanks again!

Vivek

Sameer Agarwal

unread,
May 12, 2022, 6:25:43 PM5/12/22
to ceres-...@googlegroups.com
On Thu, May 12, 2022 at 10:51 AM Vivek Bagaria <vi...@matician.com> wrote:
Two questions
  1. If IterationCallback terminates the program with `CallbackReturnType::SOLVER_TERMINATE_SUCCESSFULLY`, the update_every_iteration need not be set to true right?
Yes. 
  1. Killing a thread could potentially update the state partially, producing incorrect results. I might be missing something...   
Yes.

Sameer
 
Reply all
Reply to author
Forward
0 new messages