question

Shinya O avatar image
0 Likes"
Shinya O asked Jason Lightfoot commented

How to create a path vertically and create a CP in the middle of it

Hi,

I would like to use FlexScript to create a path vertically and create a CP in the middle of it. Is it possible?

I tried the code below, but it doesn't work. When finalizeSpatialChanges is executed on the last line, the z coordinate of the control point becomes -nan(ind).

Vec3 startloc = Vec3(0,0,0);
Vec3 endloc = Vec3(0,0,10);
Vec3 diff = endloc - startloc;
Vec2 xydiff = Vec2(diff.x, diff.y);
double xylength = xydiff.magnitude;
double zlenght = Math.fabs(diff.z);

Object path = Object.create("AGV::StraightPath");

path.size.x = xylength;
path.size.z = zlenght;
path.location = startloc;
path.rotation.z = xydiff.angle(Vec2(1,0));

function_s(path, "setZ", startloc.z, 1);
function_s(path, "setZ", endloc.z, 0);

function_s(path, "finalizeSpatialChanges");

Vec3 cploc = Vec3(0,0,5);

Object cp = Object.create("AGV::ControlPoint");

cp.location = cploc;

function_s(cp, "finalizeSpatialChanges");

Thanks in advance.

FlexSim 23.0.11
agvflexscriptagv pathcontrolpoint
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
1 Like"
Jason Lightfoot answered Jason Lightfoot commented

Note that you can avoid using function_s calls directly by instead setting the properties:

Object path = Object.create("AGV::StraightPath");
path.setProperty("StartLocation", Vec3(1,0,0));
path.setProperty("EndLocation",Vec3(5,1,10));
Object cp = Object.create("AGV::ControlPoint");
cp.setProperty("Location", Vec3(3,0.5,5));

However it looks like you cannot position a control point on a vertical path. This still results in a -nan(ind) cp z value and also doesn't accept the startlocation of (0,0,0). I will send this into the developers.

Also note that construction is also possible (and seems to work better) using Table.query:

Table.query("INSERT INTO Objects() (Class, Name, StartLocation, EndLocation, Location) SELECT Class, Name, StartLocation, EndLocation, Location FROM Locs")

Where the Locs table is :

1708498690089.png

InsertVerticalPathandControlPoint.fsm


· 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.

Shinya O avatar image Shinya O commented ·

Thank you for your information. I would like to model AGVs that moves in 3-dimensions like a skypod. It would be helpful if this issue was resolved.

https://youtu.be/Mj8DMcsWAAE?t=67

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Shinya O commented ·
You can also try using network nodes or your own kinematics.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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