Skip to content

Commit

Permalink
Remove warnings related to Raw classes
Browse files Browse the repository at this point in the history
  • Loading branch information
traversaro committed Sep 17, 2023
1 parent afb7840 commit ef54f72
Show file tree
Hide file tree
Showing 42 changed files with 159 additions and 85 deletions.
11 changes: 3 additions & 8 deletions bindings/iDynTree.i
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include "iDynTree/VectorFixSize.h"

// Basic Vectors: Point Vectors and Spatial Vectors
#include "iDynTree/PositionRaw.h"
#include "iDynTree/Position.h"
#include "iDynTree/SpatialForceVector.h"
#include "iDynTree/SpatialMotionVector.h"
Expand All @@ -62,14 +61,13 @@
#include "iDynTree/Axis.h"

// Inertias
#include "iDynTree/RotationalInertiaRaw.h"
#include "iDynTree/SpatialInertiaRaw.h"
#include "iDynTree/RotationalInertia.h"
#include "iDynTree/SpatialInertia.h"
#include "iDynTree/SpatialInertia.h"
#include "iDynTree/ArticulatedBodyInertia.h"
#include "iDynTree/InertiaNonLinearParametrization.h"

// Transformations: Rotation and Transform
#include "iDynTree/RotationRaw.h"
#include "iDynTree/Rotation.h"
#include "iDynTree/Transform.h"
#include "iDynTree/TransformDerivative.h"
Expand Down Expand Up @@ -184,7 +182,6 @@ namespace std {
%template(Vector16) iDynTree::VectorFixSize<16>;

// Basic Vectors: Point Vectors and Spatial Vectors
%include "iDynTree/PositionRaw.h"
%include "iDynTree/Position.h"

%include "iDynTree/GeomVector3.h"
Expand Down Expand Up @@ -216,14 +213,12 @@ namespace std {
%include "iDynTree/Axis.h"

// Inertias
%include "iDynTree/RotationalInertiaRaw.h"
%include "iDynTree/SpatialInertiaRaw.h"
%include "iDynTree/RotationalInertia.h"
%include "iDynTree/SpatialInertia.h"
%include "iDynTree/ArticulatedBodyInertia.h"
%include "iDynTree/InertiaNonLinearParametrization.h"

// Transformations: Rotation and Transform
%include "iDynTree/RotationRaw.h"
%include "iDynTree/Rotation.h"
%include "iDynTree/Transform.h"
%include "iDynTree/TransformDerivative.h"
Expand Down
38 changes: 16 additions & 22 deletions bindings/pybind11/idyntree_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
#include <iDynTree/MatrixDynSize.h>
#include <iDynTree/MatrixFixSize.h>
#include <iDynTree/Position.h>
#include <iDynTree/PositionRaw.h>
#include <iDynTree/Rotation.h>
#include <iDynTree/RotationRaw.h>
#include <iDynTree/RotationalInertiaRaw.h>
#include <iDynTree/RotationalInertia.h>
#include <iDynTree/SpatialInertia.h>
#include <iDynTree/Transform.h>
#include <iDynTree/Twist.h>
Expand Down Expand Up @@ -197,23 +195,20 @@ void iDynTreeCoreBindings(pybind11::module& module) {
createFixSizeMatrix<6, 6>(module, "Matrix6x6");

// Positions, Rotations and Transforms.
py::class_<PositionRaw, VectorFixSize<3>>(module, "_PositionRaw")
py::class_<Position, >(module, "Position")
// Do not expose constructor as we do not want users to use this class.
.def("__repr__", &PositionRaw::toString);

py::class_<Position, PositionRaw>(module, "Position")
py::class_<Position, VectorFixSize<3>>(module, "Position")
.def(py::init())
.def(py::init<double, double, double>())
.def(py::self + py::self)
.def(py::self - py::self)
.def(-py::self)
.def("__repr__", &Position::toString)
.def_static("Zero", &Position::Zero);

py::class_<RotationRaw, MatrixFixSize<3, 3>>(module, "_RotationRaw")
// Do not expose constructor as we do not want users to use this class.
.def("__repr__", &RotationRaw::toString);

py::class_<Rotation, RotationRaw>(module, "Rotation")
py::class_<Rotation, MatrixFixSize<3, 3>>(module, "Rotation")
.def(py::init())
.def(py::init<double, double, double, //
double, double, double, //
Expand All @@ -228,6 +223,7 @@ void iDynTreeCoreBindings(pybind11::module& module) {
py::is_operator())
.def("as_rpy", &Rotation::asRPY)
.def("as_quaternion", &Rotation::asQuaternion)
.def("__repr__", &Rotation::toString)
.def_static("Identity", &Rotation::Identity)
.def_static("RotX", &Rotation::RotX)
.def_static("RotY", &Rotation::RotY)
Expand All @@ -248,23 +244,21 @@ void iDynTreeCoreBindings(pybind11::module& module) {
.def_property("origin", &Axis::getOrigin, &Axis::setOrigin)
.def("__repr__", &Axis::toString);

py::class_<RotationalInertiaRaw, MatrixFixSize<3, 3>>(module,
"RotationalInertia")
py::class_<RotationalInertia, MatrixFixSize<3, 3>>(module,
"RotationalInertia")
.def(py::init());

py::class_<SpatialInertiaRaw>(module, "_SpatialInertiaRaw")
py::class_<SpatialInertia>(module, "SpatialInertia")
.def(py::init())
.def(py::init<double, const Position&, const RotationalInertia&>())
.def("from_rotational_inertia_wrt_center_of_mass",
&SpatialInertiaRaw::fromRotationalInertiaWrtCenterOfMass)
.def("get_mass", &SpatialInertiaRaw::getMass)
.def("get_center_of_mass", &SpatialInertiaRaw::getCenterOfMass)
&SpatialInertia::fromRotationalInertiaWrtCenterOfMass)
.def("get_mass", &SpatialInertia::getMass)
.def("get_center_of_mass", &SpatialInertia::getCenterOfMass)
.def("get_rotational_inertia_wrt_frame_origin",
&SpatialInertiaRaw::getRotationalInertiaWrtFrameOrigin)
&SpatialInertia::getRotationalInertiaWrtFrameOrigin)
.def("get_rotational_inertia_wrt_center_of_mass",
&SpatialInertiaRaw::getRotationalInertiaWrtCenterOfMass);

py::class_<SpatialInertia, SpatialInertiaRaw>(module, "SpatialInertia")
.def(py::init())
.def(py::init<double, const PositionRaw&, const RotationalInertiaRaw&>())
&SpatialInertia::getRotationalInertiaWrtCenterOfMass);
.def_static("Zero", &SpatialInertia::Zero)
.def("as_matrix", &SpatialInertia::asMatrix)
.def(py::self + py::self)
Expand Down
20 changes: 10 additions & 10 deletions bindings/python/python.i
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,13 @@ import_array();
if (i != 3 || j != 3)
throw std::runtime_error("Wrong size of input matrix");

return iDynTree::RotationRaw(in, static_cast<unsigned>(i), static_cast<unsigned>(j));
return iDynTree::Rotation(in, static_cast<unsigned>(i), static_cast<unsigned>(j));
}

Rotation(const double* in_data, const std::ptrdiff_t in_rows, const std::ptrdiff_t in_cols) {
iDynTree::Rotation* rot = new iDynTree::Rotation(iDynTree::RotationRaw(in_data,
static_cast<unsigned>(in_rows),
static_cast<unsigned>(in_cols)));
iDynTree::Rotation* rot = new iDynTree::Rotation(in_data,
static_cast<unsigned>(in_rows),
static_cast<unsigned>(in_cols));
return rot;
}
};
Expand All @@ -340,27 +340,27 @@ import_array();
if (size != 3)
throw std::runtime_error("Wrong size of input array");

return iDynTree::PositionRaw(in, static_cast<unsigned>(size));
return iDynTree::Position(in, static_cast<unsigned>(size));
}

Position(const double* in_data, const unsigned in_size) {
iDynTree::Position* pos = new iDynTree::Position(iDynTree::PositionRaw(in_data, in_size));
iDynTree::Position* pos = new iDynTree::Position(in_data, in_size);
return pos;
}
};

%extend iDynTree::Transform {

void setPosition(const double* in_data, const unsigned in_size) {
$self->setPosition(iDynTree::PositionRaw(in_data, static_cast<unsigned>(in_size)));
$self->setPosition(iDynTree::Position(in_data, static_cast<unsigned>(in_size)));
}

void setRotation(const double* in_data,
const std::ptrdiff_t in_rows,
const std::ptrdiff_t in_cols) {
$self->setRotation(iDynTree::RotationRaw(in_data,
static_cast<unsigned>(in_rows),
static_cast<unsigned>(in_cols)));
$self->setRotation(iDynTree::Rotation(in_data,
static_cast<unsigned>(in_rows),
static_cast<unsigned>(in_cols)));
}
};

Expand Down
5 changes: 5 additions & 0 deletions src/core/include/iDynTree/Direction.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ namespace iDynTree
*/
Direction(const double* in_data, const unsigned int in_size);

/**
* Assignment operator: assign a Direction from another Direction
*/
Direction& operator=(const Direction& other);

/**
* Normalize the representation of the direction, useful if
* the coordinates of the direction has been manually setted
Expand Down
5 changes: 5 additions & 0 deletions src/core/include/iDynTree/Position.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ namespace iDynTree
*/
Position(const Position & other);

/**
* Assignment operator: assign a Position from another Position
*/
Position& operator=(const Position& other);

/**
* Constructor from a raw buffer of 3 doubles.
*/
Expand Down
1 change: 1 addition & 0 deletions src/core/include/iDynTree/Rotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ namespace iDynTree
/**
* overloaded operators
*/
Rotation& operator=(const Rotation & other);
Rotation operator*(const Rotation & other) const;
Rotation inverse() const;
Position operator*(const Position & other) const;
Expand Down
3 changes: 2 additions & 1 deletion src/core/include/iDynTree/RotationalInertia.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace iDynTree
class Position;

/**
* Class providing the raw coordinates for a 3d inertia matrix.
* Class providing the coordinates for a 3d inertia matrix.
*
* \ingroup iDynTreeCore
*
Expand All @@ -35,6 +35,7 @@ namespace iDynTree
RotationalInertia();
RotationalInertia(const double * in_data, const unsigned int in_rows, const unsigned int in_cols);
RotationalInertia(const RotationalInertia & other);
RotationalInertia& operator=(const RotationalInertia& other);

/**
* Initializer helper: return a zero matrix.
Expand Down
1 change: 1 addition & 0 deletions src/core/include/iDynTree/SpatialAcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace iDynTree
SpatialAcc(const SpatialAcc& other);

// overloaded operator
SpatialAcc& operator=(const SpatialAcc &other);
SpatialAcc operator+(const SpatialAcc &other) const;
SpatialAcc operator-(const SpatialAcc &other) const;
SpatialAcc operator-() const;
Expand Down
10 changes: 5 additions & 5 deletions src/core/include/iDynTree/SpatialForceVector.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-FileCopyrightText: Fondazione Istituto Italiano di Tecnologia (IIT)
// SPDX-License-Identifier: BSD-3-Clause

#ifndef IDYNTREE_SPATIAL_FORCE_RAW_H
#define IDYNTREE_SPATIAL_FORCE_RAW_H
#ifndef IDYNTREE_SPATIAL_FORCE_VECTOR_H
#define IDYNTREE_SPATIAL_FORCE_VECTOR_H

#include <iDynTree/VectorFixSize.h>
#include <iDynTree/GeomVector3.h>
Expand All @@ -21,8 +21,8 @@ namespace iDynTree
*
* This is just a basic vector, used to implement the adjoint transformations in
* a general way. The relative adjoint transformation is contained in
* TransformRaw::apply(SpatialForceRaw),
* for consistency with the iDynTree::PositionRaw class.
* Transform::apply(SpatialForce),
* for consistency with the iDynTree::Position class.
*
* \note in iDynTree, the spatial vector follows this serialization: the first three elements are
* the linear part and the second three elements are the angular part.
Expand Down Expand Up @@ -53,4 +53,4 @@ namespace iDynTree
};
}

#endif /* IDYNTREE_SPATIAL_FORCE_RAW_H */
#endif /* IDYNTREE_SPATIAL_FORCE_VECTOR_H */
1 change: 1 addition & 0 deletions src/core/include/iDynTree/SpatialMomentum.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace iDynTree
SpatialMomentum(const SpatialMomentum & other);

// overloaded operators
SpatialMomentum& operator=(const SpatialMomentum &other);
SpatialMomentum operator+(const SpatialMomentum &other) const;
SpatialMomentum operator-(const SpatialMomentum &other) const;
SpatialMomentum operator-() const;
Expand Down
10 changes: 5 additions & 5 deletions src/core/include/iDynTree/SpatialMotionVector.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-FileCopyrightText: Fondazione Istituto Italiano di Tecnologia (IIT)
// SPDX-License-Identifier: BSD-3-Clause

#ifndef IDYNTREE_SPATIAL_MOTION_RAW_H
#define IDYNTREE_SPATIAL_MOTION_RAW_H
#ifndef IDYNTREE_SPATIAL_MOTION_VECTOR_H
#define IDYNTREE_SPATIAL_MOTION_VECTOR_H

#include <iDynTree/VectorFixSize.h>
#include <iDynTree/GeomVector3.h>
Expand All @@ -15,7 +15,7 @@ namespace iDynTree
class Dummy {};

/**
* Class providing the raw coordinates for any motion spatial vector
* Class providing the coordinates for any motion spatial vector
* (i.e. vector form of an element of se(3)).
*
* \ingroup iDynTreeCore
Expand All @@ -28,8 +28,8 @@ namespace iDynTree
*
* This is just a basic vector, used to implement the adjoint transformations in
* a general way. The relative adjoint transformation is contained in
* TransformRaw::apply(SpatialMotionRaw),
* for consistency with the iDynTree::PositionRaw class.
* Transform::apply(SpatialMotion),
* for consistency with the iDynTree::Position class.
*
* \note in iDynTree, the spatial vector follows this serialization: the first three elements are
* the linear part and the second three elements are the angular part.
Expand Down
9 changes: 9 additions & 0 deletions src/core/include/iDynTree/SpatialVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ SpatialVector<DerivedSpatialVecT>
/**
* overloaded operators
*/
DerivedSpatialVecT& operator=(const DerivedSpatialVecT &other);
DerivedSpatialVecT operator+(const DerivedSpatialVecT &other) const;
DerivedSpatialVecT operator-(const DerivedSpatialVecT &other) const;
DerivedSpatialVecT operator-() const;
Expand Down Expand Up @@ -334,6 +335,14 @@ SpatialVector<DerivedSpatialVecT>
}

// overloaded operators
SPATIALVECTOR_TEMPLATE_HDR
DerivedSpatialVecT& SPATIALVECTOR_INSTANCE_HDR::operator=(const DerivedSpatialVecT &other)
{
this->getLinearVec3() = other.getLinearVec3();
this->getAngularVec3() = other.getAngularVec3();
return &this;
}

SPATIALVECTOR_TEMPLATE_HDR
DerivedSpatialVecT SPATIALVECTOR_INSTANCE_HDR::operator+(const DerivedSpatialVecT &other) const
{
Expand Down
1 change: 1 addition & 0 deletions src/core/include/iDynTree/Twist.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace iDynTree
Twist(const Twist& other);

/** overloaded operators **/
Twist& operator=(const Twist & other);
Twist operator+(const Twist &other) const;
Twist operator-(const Twist &other) const;
Twist operator-() const;
Expand Down
1 change: 1 addition & 0 deletions src/core/include/iDynTree/Wrench.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace iDynTree
Wrench(const Wrench & other);

// overloaded operators
Wrench& operator=(const Wrench & other);
Wrench operator+(const Wrench &other) const;
Wrench operator-(const Wrench &other) const;
Wrench operator-() const;
Expand Down
4 changes: 2 additions & 2 deletions src/core/src/ClassicalAcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <iDynTree/ClassicalAcc.h>
#include <iDynTree/SpatialAcc.h>
#include <iDynTree/Twist.h>
#include <iDynTree/RotationRaw.h>
#include <iDynTree/Rotation.h>

#include <Eigen/Dense>

Expand All @@ -29,7 +29,7 @@ ClassicalAcc::ClassicalAcc(const ClassicalAcc& other):
}


const ClassicalAcc& ClassicalAcc::changeCoordFrame(const RotationRaw& newCoordFrame)
const ClassicalAcc& ClassicalAcc::changeCoordFrame(const Rotation& newCoordFrame)
{
Eigen::Map<Vector6d> thisData(this->data());
Eigen::Map<const Matrix3dRowMajor> rotData(newCoordFrame.data());
Expand Down
7 changes: 7 additions & 0 deletions src/core/src/Direction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ namespace iDynTree
this->m_data[2] = other.m_data[2];
}

Direction& Direction::operator=(const Direction& other)
{
this->m_data[0] = other.m_data[0];
this->m_data[1] = other.m_data[1];
this->m_data[2] = other.m_data[2];
return *this;
}

void Direction::setToDefault()
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/src/InertiaNonLinearParametrization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void RigidBodyInertiaNonLinearParametrization::fromRigidBodyInertia(const Spatia
this->com = inertia.getCenterOfMass();

// We get the inertia at the COM
RotationalInertiaRaw inertiaAtCOM = inertia.getRotationalInertiaWrtCenterOfMass();
RotationalInertia inertiaAtCOM = inertia.getRotationalInertiaWrtCenterOfMass();

// We get the inertia at the principal axis using eigen
JacobiSVD<Matrix<double,3,3,RowMajor> > eigenValuesSolver;
Expand Down Expand Up @@ -163,7 +163,7 @@ void RigidBodyInertiaNonLinearParametrization::fromRigidBodyInertia(const Spatia
SpatialInertia RigidBodyInertiaNonLinearParametrization::toRigidBodyInertia() const
{
// Compute the inertia wrt to the center of mass
RotationalInertiaRaw rotInertia;
RotationalInertia rotInertia;

Eigen::Vector3d principalMomentOfInertiaAtCOM;

Expand Down
Loading

0 comments on commit ef54f72

Please sign in to comment.