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

Allowing WORLD and LOCAL_WORLD_ALIGNED in ContactModel1D #1054

Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions bindings/python/crocoddyl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def rotationMatrixFromTwoVectors(a, b):


class DisplayAbstract:

def __init__(self, rate=-1, freq=1):
self.rate = rate
self.freq = freq
Expand Down Expand Up @@ -64,7 +63,6 @@ def getFrameTrajectoryFromSolver(self, solver):


class GepettoDisplay(DisplayAbstract):

def __init__(self, robot, rate=-1, freq=1, cameraTF=None, floor=True, frameNames=[], visibility=False):
DisplayAbstract.__init__(self, rate, freq)
self.robot = robot
Expand Down Expand Up @@ -338,7 +336,6 @@ def _setConeMu(self, coneName, mu):


class MeshcatDisplay(DisplayAbstract):

def __init__(self, robot, rate=-1, freq=1, openWindow=True):
DisplayAbstract.__init__(self, rate, freq)
self.robot = robot
Expand All @@ -365,7 +362,6 @@ def _addRobot(self, openWindow):


class CallbackDisplay(libcrocoddyl_pywrap.CallbackAbstract):

def __init__(self, display):
libcrocoddyl_pywrap.CallbackAbstract.__init__(self)
self.visualization = display
Expand All @@ -377,7 +373,6 @@ def __call__(self, solver):


class CallbackLogger(libcrocoddyl_pywrap.CallbackAbstract):

def __init__(self):
libcrocoddyl_pywrap.CallbackAbstract.__init__(self)
self.xs = []
Expand Down
3 changes: 0 additions & 3 deletions bindings/python/crocoddyl/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ def deprecated(instructions):
instructions: A human-friendly string of instructions, such
as: 'Please migrate to add_proxy() ASAP.'
"""

def decorator(func):
'''This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used.'''

@functools.wraps(func)
def wrapper(*args, **kwargs):
message = 'Call to deprecated function {}. {}'.format(func.__name__, instructions)
Expand All @@ -35,7 +33,6 @@ def wrapper(*args, **kwargs):


class DeprecationHelper(object):

def __init__(self, new_target, old_name):
self.new_target = new_target
self.warning_str = '%s is deprecated: Use %s' % (old_name, new_target.__name__)
Expand Down
28 changes: 21 additions & 7 deletions bindings/python/crocoddyl/multibody/contacts/contact-1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,32 @@ namespace python {
void exposeContact1D() {
bp::register_ptr_to_python<boost::shared_ptr<ContactModel1D> >();

bp::enum_<Contact1DMaskType>("Contact1DMaskType")
.value("X_MASK", X_MASK)
.value("Y_MASK", Y_MASK)
.value("Z_MASK", Z_MASK)
.export_values();
Copy link
Member

Choose a reason for hiding this comment

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

Let's make this class a bit more generic.

Suggested change
bp::enum_<Contact1DMaskType>("Contact1DMaskType")
.value("X_MASK", X_MASK)
.value("Y_MASK", Y_MASK)
.value("Z_MASK", Z_MASK)
.export_values();
bp::enum_<Vector3MaskType>("Vector3MaskType")
.value("x", x)
.value("y", y)
.value("z", z)
.export_values();


bp::class_<ContactModel1D, bp::bases<ContactModelAbstract> >(
"ContactModel1D",
"Rigid 1D contact model.\n\n"
"It defines a rigid 1D contact model (point contact) based on acceleration-based holonomic constraints, in the "
"z "
"direction.\n"
"x, y or z direction.\n"
"The calc and calcDiff functions compute the contact Jacobian and drift (holonomic constraint) or\n"
"the derivatives of the holonomic constraint, respectively.",
bp::init<boost::shared_ptr<StateMultibody>, pinocchio::FrameIndex, double, std::size_t,
bp::optional<Eigen::Vector2d> >(
bp::args("self", "state", "id", "xref", "nu", "gains"),
bp::optional<Eigen::Vector2d, Contact1DMaskType, pinocchio::ReferenceFrame> >(
Copy link
Member

Choose a reason for hiding this comment

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

You will need to adapt the code as now the class is Vector3MaskType.

Copy link
Member

Choose a reason for hiding this comment

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

You will need to adapt the code as now the class is Vector3MaskType.

bp::args("self", "state", "id", "xref", "nu", "gains", "mask", "type"),
"Initialize the contact model.\n\n"
":param state: state of the multibody system\n"
":param id: reference frame id of the contact\n"
":param xref: contact position used for the Baumgarte stabilization\n"
":param nu: dimension of control vector\n"
":param gains: gains of the contact model (default np.matrix([0.,0.]))"))
.def(bp::init<boost::shared_ptr<StateMultibody>, pinocchio::FrameIndex, double, bp::optional<Eigen::Vector2d> >(
":param gains: gains of the contact model (default np.matrix([0.,0.]))\n"
":param mask: axis of the contact constraint (0=x, 1=y or 2=z)\n"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
":param mask: axis of the contact constraint (0=x, 1=y or 2=z)\n"
":param mask: axis of the contact constraint (default z)\n"

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
":param mask: axis of the contact constraint (0=x, 1=y or 2=z)\n"
":param mask: axis of the contact constraint (default z)\n"

":param type: reference type of contact"))
.def(bp::init<boost::shared_ptr<StateMultibody>, pinocchio::FrameIndex, double,
bp::optional<Eigen::Vector2d, pinocchio::ReferenceFrame> >(
bp::args("self", "state", "id", "xref", "gains"),
"Initialize the contact model.\n\n"
":param state: state of the multibody system\n"
Expand Down Expand Up @@ -68,7 +76,13 @@ void exposeContact1D() {
&ContactModel1D::set_reference, "reference contact translation")
.add_property("gains",
bp::make_function(&ContactModel1D::get_gains, bp::return_value_policy<bp::return_by_value>()),
"contact gains");
"contact gains")
.add_property("mask",
bp::make_function(&ContactModel1D::get_mask, bp::return_value_policy<bp::return_by_value>()),
&ContactModel1D::set_mask, "mask")
.add_property("type",
bp::make_function(&ContactModel1D::get_type, bp::return_value_policy<bp::return_by_value>()),
&ContactModel1D::set_type, "type");

bp::register_ptr_to_python<boost::shared_ptr<ContactData1D> >();

Expand Down