Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes locking from step() #182

Merged
merged 6 commits into from
Apr 22, 2017

Conversation

gilwoolee
Copy link
Contributor

KinematicSimulationTrajectoryExecutor::step() should no longer lock the skeleton and let the caller be responsible for locking if it's running under multi-threaded setting. This is consistent with other executors.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 80.34% when pulling 78a86de on bugfix/KinematicSimulationTrajectoryExecutor into 2af5c55 on master.

Copy link
Member

@jslee02 jslee02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I have some minor requests as below.

// 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I believe this comment is a note to be added to the original docstring of PositionCommandExecutor::step(), but this will just overwrite the original docstring. It would be nice to copy the original docstring and add this node as:

  /// \copydoc PositionCommandExecutor::step()
  ///
  /// 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.

Also, it would be great to actually add a docstring to PositionCommandExecutor::step(). Currently, it's // Step once. If it's enough then make it doxygen comment by prepending one more /.

// 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I believe the unit of time here is seconds. It would be nice to either (1) change the variable name to encode the unit or (2) add trailing comment something like // sec.

Additionally, it would be much better to comment the unit of the time parameter to the docstring of Trajectory::evaluate().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed to duration instead of duration_cast? I believe timeSinceBeginning is a duration, so duration_cast was appropriate here. 🤔

@@ -129,6 +126,7 @@ void KinematicSimulationTrajectoryExecutor::step()
mPromise->set_value();
mInExecution = false;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Could we remove this empty line?

@jslee02 jslee02 added this to the Aikido 0.1.0 milestone Apr 20, 2017
Copy link
Member

@mkoval mkoval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once @jslee02's comments are addressed.

@@ -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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed to duration instead of duration_cast? I believe timeSinceBeginning is a duration, so duration_cast was appropriate here. 🤔

@@ -105,8 +105,9 @@ void KinematicSimulationTrajectoryExecutor::step()
mInExecution = false;
}

using seconds = std::chrono::duration<float>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I believe the type of time should be double as Trajectory takes it as double.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 80.365% when pulling 38682d6 on bugfix/KinematicSimulationTrajectoryExecutor into 2af5c55 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 80.34% when pulling 38682d6 on bugfix/KinematicSimulationTrajectoryExecutor into 2af5c55 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 80.34% when pulling 38682d6 on bugfix/KinematicSimulationTrajectoryExecutor into 2af5c55 on master.

Copy link
Member

@mkoval mkoval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor comments. Otherwise, LGTM.

/// \param _t time parameter
/// \param[out] _state output state of the trajectory at time \c _t
/// \param _t time parameter (in seconds)
/// \param[out] _state output state of the trajectory at time \c _t (seconds)
virtual void evaluate(double _t,
statespace::StateSpace::State *_state) const = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really "in seconds" -it's an arbitrary path parameter.

@@ -105,8 +105,9 @@ void KinematicSimulationTrajectoryExecutor::step()
mInExecution = false;
}

using seconds = std::chrono::duration<double>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a potentially confusing alias, because std::chrono::seconds stores integers and this alias stores doubles.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 80.34% when pulling 81ec3c7 on bugfix/KinematicSimulationTrajectoryExecutor into 2af5c55 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 79.177% when pulling c3b212e on bugfix/KinematicSimulationTrajectoryExecutor into 5d19317 on master.

@gilwoolee gilwoolee merged commit 78d38af into master Apr 22, 2017
@gilwoolee gilwoolee deleted the bugfix/KinematicSimulationTrajectoryExecutor branch April 22, 2017 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants