Skip to content

Commit

Permalink
pydrake: Add {start,end}_time() to Trajectory (RobotLocomotion#14049)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Valenzuela authored Sep 11, 2020
1 parent 1c89da9 commit 2e5bef1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bindings/pydrake/test/trajectories_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
from pydrake.math import RotationMatrix
from pydrake.polynomial import Polynomial
from pydrake.trajectories import (
PiecewisePolynomial, PiecewiseQuaternionSlerp
PiecewisePolynomial, PiecewiseQuaternionSlerp, Trajectory
)


class TestTrajectories(unittest.TestCase):
def test_trajectory_start_end_time(self):
# Acceptance check to ensure we have these base methods exposed.
Trajectory.start_time
Trajectory.end_time

def test_piecewise_polynomial_empty_constructor(self):
pp = PiecewisePolynomial()

Expand Down
5 changes: 5 additions & 0 deletions bindings/pydrake/trajectories_py.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ PYBIND11_MODULE(trajectories, m) {
py::arg("derivative_order") = 1, doc.Trajectory.EvalDerivative.doc)
.def("MakeDerivative", &Trajectory<T>::MakeDerivative,
py::arg("derivative_order") = 1, doc.Trajectory.MakeDerivative.doc)
.def("start_time", &Trajectory<T>::start_time,
doc.Trajectory.start_time.doc)
.def("end_time", &Trajectory<T>::end_time, doc.Trajectory.end_time.doc)
.def("rows", &Trajectory<T>::rows, doc.Trajectory.rows.doc)
.def("cols", &Trajectory<T>::cols, doc.Trajectory.cols.doc);

Expand All @@ -49,6 +52,8 @@ PYBIND11_MODULE(trajectories, m) {
py::arg("segment_index"), doc.PiecewiseTrajectory.end_time.doc)
.def("duration", &PiecewiseTrajectory<T>::duration,
py::arg("segment_index"), doc.PiecewiseTrajectory.duration.doc)
// N.B. We must redefine these two overloads, as we cannot use the base
// classes' overloads. See: https://github.com/pybind/pybind11/issues/974
.def("start_time",
overload_cast_explicit<double>(&PiecewiseTrajectory<T>::start_time),
doc.PiecewiseTrajectory.start_time.doc)
Expand Down

0 comments on commit 2e5bef1

Please sign in to comment.