question

Maryam H2 avatar image
0 Likes"
Maryam H2 asked Maryam H2 commented

Floor Spot_on Enter location

Hi - How I can make the operator to walk to the center of floor spot and face toward the workbench?

model_op_walks_to_centeral_loc.fsm

FlexSim 24.0.2
operatorfloorspot
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 Maryam H2 commented

Here's a user command and example model where you can call faceObject and it will figure out the rotation and apply it to the te (or any object you supply as the first parameter). Also attached is a library to autoinstall the command to any model.

The user command code is:

/**Custom Code*/
Object te=param(1);
Object involved=param(2);
Variant p3=param(3);
Vec3 midbaseFactors=Vec3(0.5,0.5,0);
Vec3 factors=midbaseFactors;
Vec3 unitx=Vec3(1,0,0);
if (p3.type==VAR_TYPE_ARRAY)
    factors=p3;
Vec3 targetloc=involved.getLocation(factors).project(involved.up,te.up);
Vec3 tepos=te.getLocation(midbaseFactors);
targetloc.z=0;
tepos.z=0;
Vec3 heading=targetloc-tepos;
double angle=heading.angle(unitx);
te.rotation.z=angle;
return angle;

faceObject.fsmfaceObject.fsl

Attached is your updated model.

model-op-walks-to-centeral-loc_jl.fsmfaceObject.fsm


· 1
5 |100000

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

Maryam H2 avatar image Maryam H2 commented ·
got it, very useful. thanks!
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.