Start actor trajectory from plugin

asked 2023-08-01 04:23:30 -0600

nahan-chbt gravatar image

Hello,

I'm new to plugin development in Gazebo, i am trying to start an Actor trajectory from a Plugin during simulation execution.

I added a simple actor in my world description (sdf file).

Like this :

<actor name="animated_box">
  <link name="link">
    <visual name="visual">
      <geometry>
        <box>
          <size>.2 .2 .2</size>
        </box>
      </geometry>
    </visual>
  </link>
  <script>
    <loop>true</loop>
    <delay_start>80</delay_start>
    <auto_start>true</auto_start>
    <trajectory id="0" type="square">
    <waypoint>
      <time>0.0</time>
      <pose>-1 -1 1 0 0 0</pose>
    </waypoint>
....
    </trajectory>
  </script>
</actor>

This actor is working well, but my needs is to start the trajectory from a plugin, in PreUpdate function.

For doing this i get the actor object from EntityComponentManager like this :

auto targetActorComponent = _ecm.Component<sim::components::Actor>(
      this->dataPtr->targetEntity)->Data();

And i can access functions like :

targetActorComponent.SetScriptDelayStart(0.0);
targetActorComponent.SetScriptLoop(true);
targetActorComponent.SetScriptAutoStart(true);

But these does not affect the trajectory of the actor at all.

I also tried to reload the component after making changes, but same result.

targetActorComponent.Load(targetActorComponent.Element());

I probably misunderstood how this component works and how to modify its parameters.

How should I go about it? I couldn't find any examples.

Thanks in advance

edit retag flag offensive close merge delete