Closed hichamhendy closed 1 year ago
I was expecting there to be a command I execute to reproduce the bug (after cloning this repository)
I am sorry, such a command is hard to implement. This is a micro aerial vehicle swarm module and usually one needs to send a goal over GUI, and subsequently path planning will be called then the trajectory tracking using CppAD and Ipopt. There's also another modules dependencies which hasn't yet a repo. I kind of figured out that there is a memory leak, but I can't locate the problem. I am ready to share with you all error message if you wish. But as I said it seems that solving itself isn't working properly.
It would be much better if I could reproduce the error message instead of my guessing at the cause. Perhaps you need to use the CPPAD_DEBUG_AND_RELEASE flag see https://cppad.readthedocs.io/en/latest/preprocessor.html#cppad-debug-and-release
yes sir. I got this
Begin test group swarm/Node memory_leak Error 1 tests failed. [ INFO] [1678434301.953998247, 44.164000000]: [Swarm Commanding]: Summary (mem): 0 [ INFO] [1678434301.954011563, 44.164000000]: [Swarm Commanding]: Solution found!!! [ INFO] [1678434301.954023362, 44.164000000]: [Swarm Commanding]: Cost: 0 { } cppad-20180000.0 error from a known source: vector: index greater than or equal vector size Error detected by false result for i < length_ at line 473 in the file /usr/include/cppad/utility/vector.hpp mav_swarm_commander_node: /usr/include/cppad/utility/error_handler.hpp:206: static void CppAD::ErrorHandler::Default(bool, int, const char*, const char*, const char*): Assertion
false' failed.
Stack trace (most recent call last) in thread 18739:
Aborted (Signal sent by tkill() 18697 1000) Aborted (core dumped) `
I tried that radically different over a subscriber instead action and got `#26 Object "", at 0xffffffffffffffff, in
Aborted (Signal sent by tkill() 11282 1000) Aborted (core dumped) `
What I can see that there is a problem to boost::shared_ptr. beutiI ain't sure. Could you guess where the problem here could be?
My last try was by executing that in a thread
boost::thread(&SwarmCommander::modelPredictivePlanning, this, current_path_).detach();
and I got
Begin test group swarm/Node memory_leak Error 1 tests failed. [ INFO] [1678439911.824434053, 22.848000000]: [Swarm Commanding]: Summary (mem): 0 [ INFO] [1678439911.824450138, 22.848000000]: [Swarm Commanding]: Solution found!!! [ INFO] [1678439911.824463658, 22.848000000]: [Swarm Commanding]: Cost: 6.9339e-310 { } cppad-20180000.0 error from a known source: vector: index greater than or equal vector size Error detected by false result for i < length_ at line 473 in the file /usr/include/cppad/utility/vector.hpp mav_swarm_commander_node: /usr/include/cppad/utility/error_handler.hpp:206: static void CppAD::ErrorHandler::Default(bool, int, const char*, const char*, const char*): Assertion
false' failed.
Stack trace (most recent call last) in thread 24512:
Aborted (Signal sent by tkill() 24237 1000) Aborted (core dumped) `
cppad-20180000.0 error from a known source: vector: index greater than or equal vector size Error detected by false result for i < length_ at line 473 in the file /usr/include/cppad/utility/vector.hpp
It looks like you are accessing a cppad vector with a invalid index value. You should run in the debugger so you can go back up the stack and find the source code that has the bad index.
I used "backward_ros" to answer this question precisely and actually It's no problem
for(i = 0; i < n_vars; i++) std::cout << solution.x[i];
Even a desperate try std::cout << solution.x[1];
got me an error. I expect to find the solution here! Am I wrong?
Yes, the question is why is it not there.
If you look in the file https://github.com/coin-or/CppAD/blob/master/include/cppad/ipopt/solve_callback.hpp at the line solution.x.resize(nx); I suspect that this line is no being executed; i.e., finalize_solution is not being called by ipopt (which should only happen if ipopt fails). Since I cannot reproduce the problem, you will have to try an debug it on your machine; i.e., figure out why finalize_solution is not being called by Ipopt.
The thing is I tried a simple code on a model of car (solution room is almost half of a quadrotor) on my machine and it worked fine and got solution!! The only difference was build system. The one that doesn't work is build using catkin and run on ROS and the who does work is built using Cmake. So the problem is somehow related to ROS! I will try to get deeper.
By the way, finalize_solution gets called. The reason is simply that ipopt doesn't fail otherwise
bool ok = true; ok &= solution.status == CppAD::ipopt::solve_result<Dvector>::success; if(CppAD::ipopt::solve_result<Dvector>::success) ROS_INFO_STREAM(kStreamPrefix <<"Solution found!!!");
would have given false.
Then you should be able run a debug version and put a breakpoint just after solution_.x.resize(nx_);
in solvecallback.hpp and to see why solution.x has size zero ?
I found the problem https://github.com/hichamhendy/mav_swarm_commander/blob/develop/src/SwarmCommander.cpp#L449
Everything was alright I just made a stupid mistake by switching upper and lower limits
Thank your Prof. Brad. It was an honor.
Please add comments to https://github.com/coin-or/CppAD/issues/170 explaining what happened and close that issue.
Sure. I intend to do that.
The solution vector has no solution inside even though the solver succeeds.
CppAD::ipopt::solve<Dvector, FG_eval>(options, vars, vars_lowerbound, vars_upperbound, constraints_lowerbound, constraints_upperbound, fg_eval, solution);