Skip to content

Commit

Permalink
Removes locking from step()
Browse files Browse the repository at this point in the history
  • Loading branch information
gilwoolee committed Apr 19, 2017
1 parent 2af5c55 commit 78a86de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class BarrettHandKinematicSimulationPositionCommandExecutor
/// \return Future which becomes available when the execution completes.
std::future<void> execute(const Eigen::VectorXd& goalPositions) override;

// Documentation inherited.
/// If multiple threads are accessing this function or the skeleton associated
/// with this executor, it is necessary to lock the skeleton before
/// calling this method.
void step() override;

/// Resets CollisionGroup to check collision with fingers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class KinematicSimulationTrajectoryExecutor : public TrajectoryExecutor
std::future<void> execute(
trajectory::TrajectoryPtr traj) override;

// Documentation inherited.
/// If multiple threads are accessing this function or the skeleton associated
/// with this executor, it is necessary to lock the skeleton before
/// calling this method.
void step() override;

private:
Expand Down
6 changes: 2 additions & 4 deletions src/control/KinematicSimulationTrajectoryExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void KinematicSimulationTrajectoryExecutor::step()
}

auto timeSinceBeginning = system_clock::now() - mExecutionStartTime;
double t = duration_cast<seconds>(timeSinceBeginning).count();
auto t = duration<double>(timeSinceBeginning).count();

// Can't do static here because MetaSkeletonStateSpace inherits
// CartesianProduct which inherits virtual StateSpace
Expand All @@ -117,10 +117,7 @@ void KinematicSimulationTrajectoryExecutor::step()

mTraj->evaluate(t, state);

// Lock the skeleton, set state.
std::unique_lock<std::mutex> skeleton_lock(mSkeleton->getMutex());
space->setState(state);
skeleton_lock.unlock();

// Check if trajectory has completed.
bool const is_done = (t >= mTraj->getEndTime());
Expand All @@ -129,6 +126,7 @@ void KinematicSimulationTrajectoryExecutor::step()
mPromise->set_value();
mInExecution = false;
}

}

}
Expand Down

0 comments on commit 78a86de

Please sign in to comment.