question

Filippo C5 avatar image
0 Likes"
Filippo C5 asked Filippo C5 commented

How to set the value of a label based on the position of an object?

Hello,

I am creating a model using GIS Navigation and I have a token (token.truck) that acquires a Truck type task executer. I want to assign a label to this token (token.truck.dest_tab_row) based on where the truck is.

I tried to write the code like this, but it doesn't work, can you tell me where am I wrong please?

  1. Object locTO = Model.find("GISNavigator/BSS Torino");
  2. Object locTruck = Model.find(token.truck);
  3.  
  4. if(locTruck.location == locTO.location)
  5. {
  6. token.truck.dest_tab_row = 1;    
  7. }
  8. else
  9. {
  10. token.truck.dest_tab_row = 3;
  11. }
FlexSim 22.0.0
locationgispositionnavigationobject position
· 2
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

Felix Möhlmann avatar image
2 Likes"
Felix Möhlmann answered Filippo C5 commented

What your code is doing is comparing the 3d-coordinates of the GIS point with the coordinates of the task executer that's stationary somewhere in the model, not the minitiature version that gets drawn on the map.

What you want to do instead is check if the current location (object not coordinates) of the task executer stored in the navigator is equal to the point.

Since the feature is pretty new I don't know if there are any commands for this and I couldn't find any in a quick search of the manual, but the data can also be read directly from the tree.

  1. getsdtvalue(TaskExecuter.find(">variables/navigator/1+"), "currentPoint");

This code follows the link node in the task executers tree that links it to the navigator and then reads the current location from the respective travelmember node in the navigator's tree.

Note1: "currentPoint" only returns a valid path if the task executer is currently at a GIS point. If it is traveling this will return a null/<no path> value. In that case you can use "destPoint" to get the point it is currently traveling to.

Note2: There is no guarantee for forward compatibility because the data format/location in the navigator's nodes might change in future versions.

In the attached model I use the above code in the "On Finish Task" trigger of the task executer to update a label on it that shows the last visited location when a travel task finished.

GetGISLocation.fsm


getgislocation.fsm (125.5 KiB)
· 4
5 |100000

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