Skip to content

Commit

Permalink
[python] Prevent users inproper setting of residual references
Browse files Browse the repository at this point in the history
  • Loading branch information
cmastalli committed Jan 15, 2025
1 parent 226b200 commit de6e095
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (C) 2020-2023, University of Duisburg-Essen, University of
// Copyright (C) 2020-2025, University of Duisburg-Essen, University of
// Edinburgh,
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
Expand Down Expand Up @@ -85,7 +85,7 @@ void exposeResidualContactCoPPosition() {
.add_property(
"reference",
bp::make_function(&ResidualModelContactCoPPosition::get_reference,
bp::return_internal_reference<>()),
bp::return_value_policy<copy_const_reference>()),
&ResidualModelContactCoPPosition::set_reference,
"reference support region of the CoP")
.def(CopyableVisitor<ResidualModelContactCoPPosition>());
Expand Down
12 changes: 6 additions & 6 deletions bindings/python/crocoddyl/multibody/residuals/contact-force.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh,
// Copyright (C) 2019-2025, LAAS-CNRS, University of Edinburgh,
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
Expand Down Expand Up @@ -95,11 +95,11 @@ void exposeResidualContactForce() {
deprecated<>(
"Deprecated. Do not use set_id, instead create a new model")),
"reference frame id")
.add_property("reference",
bp::make_function(&ResidualModelContactForce::get_reference,
bp::return_internal_reference<>()),
&ResidualModelContactForce::set_reference,
"reference spatial force")
.add_property(
"reference",
bp::make_function(&ResidualModelContactForce::get_reference,
bp::return_value_policy<copy_const_reference>()),
&ResidualModelContactForce::set_reference, "reference spatial force")
.def(CopyableVisitor<ResidualModelContactForce>());

bp::register_ptr_to_python<boost::shared_ptr<ResidualDataContactForce> >();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (C) 2021-2023, University of Edinburgh, Heriot-Watt University
// Copyright (C) 2021-2025, University of Edinburgh, Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -83,7 +83,7 @@ void exposeResidualFramePlacement() {
.add_property(
"reference",
bp::make_function(&ResidualModelFramePlacement::get_reference,
bp::return_internal_reference<>()),
bp::return_value_policy<copy_const_reference>()),
&ResidualModelFramePlacement::set_reference,
"reference frame placement")
.def(CopyableVisitor<ResidualModelFramePlacement>());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (C) 2021-2023, University of Edinburgh, Heriot-Watt University
// Copyright (C) 2021-2025, University of Edinburgh, Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -83,7 +83,7 @@ void exposeResidualFrameRotation() {
.add_property(
"reference",
bp::make_function(&ResidualModelFrameRotation::get_reference,
bp::return_internal_reference<>()),
bp::return_value_policy<copy_const_reference>()),
&ResidualModelFrameRotation::set_reference,
"reference frame rotation")
.def(CopyableVisitor<ResidualModelFrameRotation>());
Expand Down

0 comments on commit de6e095

Please sign in to comment.