ZJU-FAST-Lab / GCOPTER

A General-Purpose Trajectory Optimizer for Multicopters
MIT License
792 stars 156 forks source link

The code seems not work in the free space (no obstacles information) #6

Closed Zyhlibrary closed 2 years ago

Zyhlibrary commented 2 years ago

Hi, when i use the code in our own environment, the code always meets the error in the part of convexCover if there are no obstacles info around the route. Is there a bug in the code or just caused by our incorrect using?

ZhepeiWang commented 2 years ago

It seems to be a corner case that is not well handled. Could you please provide the input information of convexCover? The inputs are: const std::vector &path, const std::vector &points, const Eigen::Vector3d &lowCorner, const Eigen::Vector3d &highCorner, const double &progress, const double &range

Zyhlibrary commented 2 years ago

Screenshot from 2022-05-19 14-03-19 Thanks for your reply. The path and the obstacle points are shown in the figure. The lowCorner: (-20,-20,0) highCorner: (20,20,2),progress: 7, range: 3. The error occurred in the function firi::firi(bd, pc, a, b, hp) Screenshot from 2022-05-19 14-14-00 ;

Zyhlibrary commented 2 years ago

Actually, once the environment has no obstacles, the obstacle points will be empty, it should be easier to build the flight corridor and get the optimal path, but the code seems not work in this case. I guess there are no constraint on the maximum construction range when build the flight corridor in the environment without obstacles.

ZhepeiWang commented 2 years ago

I wonder if there is a call where pc contained no points. If this is the truth, it can be simply resolved by return the bd with normalized normal vectors. Could you print valid_pc.size() before the call to firi::firi? Or I will do the test later.

Zyhlibrary commented 2 years ago

valid_pc: 2108 valid_pc: 418 valid_pc: 125 valid_pc: 0 This is the results in one construction process.

Zyhlibrary commented 2 years ago

It perfectly solves the problem. Thanks for your time and detailed explanation~

ZhepeiWang commented 2 years ago

I have found a bug when no obstacles exist which is caused by distRs.minCoeff(&pcMinId) When pc is empty, distRs is also an empty vec. In Eigen, find the minimum element in an empty vec causes crashes.

I have fixed it in the commit.

Please check it in your case and see if it solves your problem. Whether it works or not, please tell me the results.

ZhepeiWang commented 2 years ago

It perfectly solves the problem. Thanks for your time and detailed explanation~

Hey, I made a typo in an old commit but some how it hides the crash.

Please check the commit mentioned above.

ZhepeiWang commented 2 years ago

0 The typos are fixed now.

Zyhlibrary commented 2 years ago

OK, thanks for that, it also works. hhh~