Skip to content

Commit

Permalink
Utilizes function to sequence trajectories (#1565)
Browse files Browse the repository at this point in the history
Signed-off-by: Onur Berk Tore <[email protected]>
  • Loading branch information
Onur Berk Töre authored Jul 1, 2022
1 parent 1f6c126 commit e826c71
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
7 changes: 7 additions & 0 deletions include/ignition/gazebo/rendering/SceneManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
/// \return Pointer to requested visual
public: rendering::VisualPtr VisualById(Entity _id);

/// \brief Sequences Trajectories
/// \param[in] _trajectories Actor trajectories
/// \param[in] _time Actor trajectory delay start time (miliseconds)
public: void SequenceTrajectories(
std::vector<common::TrajectoryInfo>& _trajectories,
std::chrono::steady_clock::time_point _time);

/// \brief Create an actor
/// \param[in] _id Unique actor id
/// \param[in] _actor Actor sdf dom
Expand Down
23 changes: 16 additions & 7 deletions src/rendering/SceneManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,20 @@ rendering::MaterialPtr SceneManager::LoadMaterial(
return material;
}

void SceneManager::SequenceTrajectories(
std::vector<common::TrajectoryInfo>& _trajectories,
TP _time)
{
// sequencing all trajectories
for (auto &trajectory : _trajectories)
{
auto duration = trajectory.Duration();
trajectory.SetStartTime(_time);
_time += duration;
trajectory.SetEndTime(_time);
}
}

/////////////////////////////////////////////////
rendering::VisualPtr SceneManager::CreateActor(Entity _id,
const sdf::Actor &_actor, const std::string &_name, Entity _parentId)
Expand Down Expand Up @@ -1164,13 +1178,8 @@ rendering::VisualPtr SceneManager::CreateActor(Entity _id,
auto delayStartTime = std::chrono::milliseconds(
static_cast<int>(_actor.ScriptDelayStart() * 1000));
TP time(delayStartTime);
for (auto &trajectory : trajectories)
{
auto dura = trajectory.Duration();
trajectory.SetStartTime(time);
time += dura;
trajectory.SetEndTime(time);
}
this->SequenceTrajectories(trajectories, time);


// loop flag: add a placeholder trajectory to indicate no loop
if (!_actor.ScriptLoop())
Expand Down

0 comments on commit e826c71

Please sign in to comment.