question

Sam avatar image
0 Likes"
Sam asked Jason Lightfoot edited

cpdistance fuction returns negative or maxvalue

I'm working on a model and using cpdistance to calculate the closets AGV.

double distance = cpdistance(agv.currentCP,destCP);

This returns a value of 340282346638528859811704183484516925440. In the past i have also seen cp distance return a negative value.

As a work around, I added an additional line of code.

if(distance == 340282346638528859811704183484516925440.000000000000)
{         distance = distancetotravel(lgv, destCP); } return distance;


what is the difference between distancetotravel and cpdistance? is there a preference of one vs the other?

What can I check in the paths to make sure cpdistance works?

I'm using flexsim 23.0.15. are there fixes to distance to travel and cpdistance in newer versions of flexsim?

FlexSim 23.0.15
agvpathdistancetotravelcpdistance
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

For the large value you should check that control point is reachable - value is defined in the macro GLOBAL_UNREACHABLE. You can do this by right clicking a control point and selecting Show AGV Routing Accessibility - which will then allow you to hover the mouse over the 'from' cp and check it is reachable. Sometimes an intersection can be broken or the CP is not quite on the network which will cause this. You can also right click a path and choose Refresh Path Links-> Entire Network which can fix issues.

I've not been able to generate a negative cpdistance - if you are consistently able to generate it then please post a model.

Here's an tiny test model to show the difference between the functions for those unfamiliar with them.

distanceToTravelvsCPdistance.fsm


5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.