carlosluis / multiagent_planning

Implementation of several multiagent trajectory generation algorithms
GNU General Public License v3.0
84 stars 23 forks source link

Error Index in position 2 exceeds array bounds #3

Open jtorde opened 4 years ago

jtorde commented 4 years ago

Hi,

Thanks a lot for releasing this! I've a quick question: I'm trying to run the file dmpc_soft_bound2.m, but I get this error:

Index in position 2 exceeds array bounds (must not exceed 1).

Error in ReachedGoal (line 4)
    differ = squeeze(p(:,length_t,:))- squeeze(pf);

Error in dmpc_soft_bound2 (line 156)
    reached_goal = ReachedGoal(pk,pf,k,error_tol,N);

I've tried to comment the call to ReachedGoal() to see if the error was only in that function, but then a similar error appear in a different line of dmpc_soft_bound2.m.

Thanks!

carlosluis commented 4 years ago

Hello,

Sadly I currently don't have MATLAB access so helping you on this will be a bit harder, but I'll try my best.

As far as I remember, I left the main files ready to be executed without much issues. I was using MATLAB2018a to run these experiments, what's your version?

Did you modify anything in dmpc_soft_bound2.m? The example I setup is for two vehicles.

You could probably setup a breakpoint in the ReachedGoal function before the line triggering the error and take a look at the variables going into the squeeze function.

jtorde commented 4 years ago

Yeah, I'm using MATLAB2020a, I guess that's probably the reason why, I didn't modify anything inside dmpc_soft_bound2.m.

I've MATLAB2018a installed on a different machine, so I'll try to run it there, I'll let you know if I still have this issue.

Thanks!

carlosluis commented 4 years ago

Sure, let me know how it goes!

Based on the error message the way I would debug this is to put a break point in line 3 of ReachedGoal, and see the dimensions of the "p" 3-D array. The error message is suggesting that length_t > size(p, 2) which should be easy to verify using the breakpoint.

Also check out if the dimensions of the "p" array make sense. From memory I would say that the first dimension corresponds to the coordinate x-y-z (so size = 3), the second dimension is time (so size = number of time steps) and the third dimension is the agent's index (so size = # of agents).

jtorde commented 4 years ago

Hi!

Running it with MATLAB2018a has solved most of the errors I was getting in dmpc_soft_bound2.m and in other files. I still have the error Index in position 2 exceeds array bounds (must not exceed 1)., but it disappears when I use 4 agents or more (the cases I'm interested in) instead of 2.

Thanks!

jtorde commented 4 years ago

I've done more testing, and the issue also happens when N>=4.

After some debugging, it seems that the issue happens when this condition is true. The variables returned here are outbound = 0 success = 1 coll = 1

As success==1, the code reaches this line, which crashes because size(pk) =[ 3, 48, 8] and k=49

I guess the main question is if feasible should be 0 or 1 here (right now it returns feasible even when it collides).

I'd appreciate any other comments/ideas you may have.

Thanks!

carlosluis commented 4 years ago

Hey, I just checked and this is at least part of the problem. We're setting up a minimum distance r_min = 0.5 but here we're setting up the initial positions only 0.4m apart.

Naturally, the algorithm thinks they collided! Try to put initial positions that are separted by more than r_min and then it should work. Let me know how it goes, actually your debug results is what made me look at those variables in the first place, thanks and sorry for the buggy script! For my paper I ended up running other type of tests and I guess I never checked this particular script was running before pushing

carlosluis commented 4 years ago

You can also try running this script instead, those initial positions seem correct

Also, here the call should probably be to this function instead. From the top of my head I can't remember what was the difference between the two, but I know from the names that the 2's must be consistent here.

carlosluis commented 4 years ago

At some point I need to come back to this and cleanu it up to make it usable, sorry you are encountering all these problems to run it