question

Mischa Spelt avatar image
0 Likes"
Mischa Spelt asked Mischa Spelt answered

Offset travel after load?

When building a custom task executer (either a BasicTE in FlexSim, or a custom implementation in a module), is there a simple way to create an offset travel duration after the load or unload of an object?

For example, I noticed that the forklift will lift its forks to the pickup height during the offset travel, then load the item, but then lowering of the forks is 'tricked' to happen during the travel to the next destination. How would you ensure that the forks are raised back to a default position before the TE is allowed to move at all? I imagine we could override On Begin Task to insert addditional tasks after the loading task, but perhaps there is a more elegant solution?

I tested whether the return value of finishOffset happens to be a duration but that did not work :-)

FlexSim 19.2.0
offset travelbasicte
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

Mischa Spelt avatar image
1 Like"
Mischa Spelt answered

I found some useful code in the TaskExecuter that I was able to use. Noting it here in case someone ever struggles with the same thing.

void MyTE::finishLoadUnloadTask( treenode task, bool isLoad, treenode involvedItem, treenode involvedStation )
{
  bool alreadyOffset = /* check if offset is required */;
  if( alreadyOffset )
  {
    finishTask( task );
    return;
  }

  double offsettime = /* Create kinematics and calculate their duration */;
  if( offsettime <= 0 )
  {
    finishTask( task );
    return;
  }

  this->node_v_offsettingnow->value = ( v_useoffsets == OFFSET_BY_TE_LOGIC );
  this->node_v_offsetbegintime->value = now;
  this->node_v_offsettotaltime->value = offsettime;
  const char* desc = isLoad ? "Post-Load Pick Offset" : "Post-Unload Place Offset";
  createevent( FlexSimEvent::create( holder, time() + v_offsettotaltime, desc, [ = ]()
  {
    finishOffset();
    v_offsettingnow = 0;
    finishLoadUnloadTask( task, isLoad, involvedItem, involvedStation );
  } ) );
5 |100000

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