Skip to content

Commit

Permalink
Merge pull request #217 from pariterre/master
Browse files Browse the repository at this point in the history
Added namespace so SWIG can differentiate backends
  • Loading branch information
pariterre authored Jul 21, 2021
2 parents c7b7280 + ccb6cf1 commit 3a9f4aa
Show file tree
Hide file tree
Showing 254 changed files with 7,952 additions and 7,741 deletions.
9 changes: 4 additions & 5 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ test_script:
- cmd: biorbd_casadi_tests.exe
- cd ..

# Test for the python binder
- cd test/binding/Python3
- pytest .
- cd ../../..


############################################################################
Expand Down Expand Up @@ -111,7 +107,10 @@ test_script:
- cmd: biorbd_eigen_tests_binding_c.exe
- cd ../../..

# Test for the python binder

############################################################################
# Test for the python binder (both casadi and eigen)
############################################################################
- cd test/binding/Python3
- pytest .
- cd ../../..
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.0")
cmake_policy(SET CMP0042 NEW)
endif()

project(biorbd VERSION 1.6.1)
project(biorbd VERSION 1.7.0)
set(BIORBD_ROOT_FOLDER ${PROJECT_SOURCE_DIR})
set (BIORBD_NAME_NO_SUFFIX ${PROJECT_NAME})
set (CMAKE_CXX_STANDARD 11)
Expand All @@ -25,7 +25,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build.")
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Coverage")
endif()

# Choose the math's library backend to use
Expand Down
64 changes: 32 additions & 32 deletions binding/biorbd_muscles.i.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,63 +25,63 @@
%}

// Instantiate templates
%template(VecBiorbdMuscleGroup) std::vector<biorbd::muscles::MuscleGroup>;
%template(SharedBiorbdMuscle) std::shared_ptr<biorbd::muscles::Muscle>;
%template(VecSharedBiorbdMuscle) std::vector<std::shared_ptr<biorbd::muscles::Muscle>>;
%shared_ptr(biorbd::muscles::State);
%shared_ptr(biorbd::muscles::StateDynamics);
%shared_ptr(biorbd::muscles::StateDynamicsBuchanan);
%template(VecBiorbdMuscleState) std::vector<std::shared_ptr<biorbd::muscles::State>>;
%template(MatBiorbdMuscleState) std::vector<std::vector<std::shared_ptr<biorbd::muscles::State>>>;
%template(SharedBiorbdMuscleFatigueState) std::shared_ptr<biorbd::muscles::FatigueState>;
%template(VecBiorbdMuscleGroup) std::vector<BIORBD_NAMESPACE::muscles::MuscleGroup>;
%template(SharedBiorbdMuscle) std::shared_ptr<BIORBD_NAMESPACE::muscles::Muscle>;
%template(VecSharedBiorbdMuscle) std::vector<std::shared_ptr<BIORBD_NAMESPACE::muscles::Muscle>>;
%shared_ptr(BIORBD_NAMESPACE::muscles::State);
%shared_ptr(BIORBD_NAMESPACE::muscles::StateDynamics);
%shared_ptr(BIORBD_NAMESPACE::muscles::StateDynamicsBuchanan);
%template(VecBiorbdMuscleState) std::vector<std::shared_ptr<BIORBD_NAMESPACE::muscles::State>>;
%template(MatBiorbdMuscleState) std::vector<std::vector<std::shared_ptr<BIORBD_NAMESPACE::muscles::State>>>;
%template(SharedBiorbdMuscleFatigueState) std::shared_ptr<BIORBD_NAMESPACE::muscles::FatigueState>;

// extension of muscle casting
%extend biorbd::muscles::IdealizedActuator{
static biorbd::muscles::IdealizedActuator DeepCopy(const biorbd::muscles::Muscle& other)
%extend BIORBD_NAMESPACE::muscles::IdealizedActuator{
static BIORBD_NAMESPACE::muscles::IdealizedActuator DeepCopy(const BIORBD_NAMESPACE::muscles::Muscle& other)
{
biorbd::muscles::IdealizedActuator copy;
copy.DeepCopy(dynamic_cast<const biorbd::muscles::IdealizedActuator&>(other));
BIORBD_NAMESPACE::muscles::IdealizedActuator copy;
copy.DeepCopy(dynamic_cast<const BIORBD_NAMESPACE::muscles::IdealizedActuator&>(other));
return copy;
}
}

%extend biorbd::muscles::HillType{
static biorbd::muscles::HillType DeepCopy(const biorbd::muscles::Muscle& other)
%extend BIORBD_NAMESPACE::muscles::HillType{
static BIORBD_NAMESPACE::muscles::HillType DeepCopy(const BIORBD_NAMESPACE::muscles::Muscle& other)
{
biorbd::muscles::HillType copy;
copy.DeepCopy(dynamic_cast<const biorbd::muscles::HillType&>(other));
BIORBD_NAMESPACE::muscles::HillType copy;
copy.DeepCopy(dynamic_cast<const BIORBD_NAMESPACE::muscles::HillType&>(other));
return copy;
}
}
%extend biorbd::muscles::HillThelenType{
static biorbd::muscles::HillThelenType DeepCopy(const biorbd::muscles::Muscle& other)
%extend BIORBD_NAMESPACE::muscles::HillThelenType{
static BIORBD_NAMESPACE::muscles::HillThelenType DeepCopy(const BIORBD_NAMESPACE::muscles::Muscle& other)
{
biorbd::muscles::HillThelenType copy;
copy.DeepCopy(dynamic_cast<const biorbd::muscles::HillThelenType&>(other));
BIORBD_NAMESPACE::muscles::HillThelenType copy;
copy.DeepCopy(dynamic_cast<const BIORBD_NAMESPACE::muscles::HillThelenType&>(other));
return copy;
}
}
%extend biorbd::muscles::HillThelenTypeFatigable{
static biorbd::muscles::HillThelenTypeFatigable DeepCopy(const biorbd::muscles::Muscle& other)
%extend BIORBD_NAMESPACE::muscles::HillThelenTypeFatigable{
static BIORBD_NAMESPACE::muscles::HillThelenTypeFatigable DeepCopy(const BIORBD_NAMESPACE::muscles::Muscle& other)
{
biorbd::muscles::HillThelenTypeFatigable copy;
copy.DeepCopy(dynamic_cast<const biorbd::muscles::HillThelenTypeFatigable&>(other));
BIORBD_NAMESPACE::muscles::HillThelenTypeFatigable copy;
copy.DeepCopy(dynamic_cast<const BIORBD_NAMESPACE::muscles::HillThelenTypeFatigable&>(other));
return copy;
}
}

// extension of muscle fatigueState casting
%extend biorbd::muscles::FatigueDynamicStateXia{
static biorbd::muscles::FatigueDynamicStateXia DeepCopy(const biorbd::muscles::FatigueState& other)
%extend BIORBD_NAMESPACE::muscles::FatigueDynamicStateXia{
static BIORBD_NAMESPACE::muscles::FatigueDynamicStateXia DeepCopy(const BIORBD_NAMESPACE::muscles::FatigueState& other)
{
biorbd::muscles::FatigueDynamicStateXia copy;
copy.DeepCopy(dynamic_cast<const biorbd::muscles::FatigueDynamicStateXia&>(other));
BIORBD_NAMESPACE::muscles::FatigueDynamicStateXia copy;
copy.DeepCopy(dynamic_cast<const BIORBD_NAMESPACE::muscles::FatigueDynamicStateXia&>(other));
return copy;
}
static biorbd::muscles::FatigueDynamicStateXia DeepCopy(const biorbd::muscles::FatigueDynamicState& other)
static BIORBD_NAMESPACE::muscles::FatigueDynamicStateXia DeepCopy(const BIORBD_NAMESPACE::muscles::FatigueDynamicState& other)
{
biorbd::muscles::FatigueDynamicStateXia copy;
copy.DeepCopy(dynamic_cast<const biorbd::muscles::FatigueDynamicStateXia&>(other));
BIORBD_NAMESPACE::muscles::FatigueDynamicStateXia copy;
copy.DeepCopy(dynamic_cast<const BIORBD_NAMESPACE::muscles::FatigueDynamicStateXia&>(other));
return copy;
}
}
Expand Down
33 changes: 16 additions & 17 deletions binding/biorbd_rigidbody.i.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,26 @@
#include "RigidBody/IMUs.h"
%}


namespace std {
%template(VecBiorbdGeneralizedTorque) std::vector<biorbd::rigidbody::GeneralizedTorque>;
%template(MatBiorbdGeneralizedTorque) std::vector<std::vector<biorbd::rigidbody::GeneralizedTorque>>;
%template(PairBiorbdGeneralizedTorque) std::pair<biorbd::rigidbody::GeneralizedTorque, biorbd::rigidbody::GeneralizedTorque>;
%template(VecBiorbdGeneralizedCoordinates) std::vector<biorbd::rigidbody::GeneralizedCoordinates>;
%template(MatBiorbdGeneralizedCoordinates) std::vector<std::vector<biorbd::rigidbody::GeneralizedCoordinates>>;
%template(VecBiorbdGeneralizedVelocity) std::vector<biorbd::rigidbody::GeneralizedVelocity>;
%template(MatBiorbdGeneralizedVelocity) std::vector<std::vector<biorbd::rigidbody::GeneralizedVelocity>>;
%template(VecBiorbdGeneralizedAcceleration) std::vector<biorbd::rigidbody::GeneralizedAcceleration>;
%template(MatBiorbdGeneralizedAcceleration) std::vector<std::vector<biorbd::rigidbody::GeneralizedAcceleration>>;
%template(VecBiorbdGeneralizedTorque) std::vector<BIORBD_NAMESPACE::rigidbody::GeneralizedTorque>;
%template(MatBiorbdGeneralizedTorque) std::vector<std::vector<BIORBD_NAMESPACE::rigidbody::GeneralizedTorque>>;
%template(PairBiorbdGeneralizedTorque) std::pair<BIORBD_NAMESPACE::rigidbody::GeneralizedTorque, BIORBD_NAMESPACE::rigidbody::GeneralizedTorque>;
%template(VecBiorbdGeneralizedCoordinates) std::vector<BIORBD_NAMESPACE::rigidbody::GeneralizedCoordinates>;
%template(MatBiorbdGeneralizedCoordinates) std::vector<std::vector<BIORBD_NAMESPACE::rigidbody::GeneralizedCoordinates>>;
%template(VecBiorbdGeneralizedVelocity) std::vector<BIORBD_NAMESPACE::rigidbody::GeneralizedVelocity>;
%template(MatBiorbdGeneralizedVelocity) std::vector<std::vector<BIORBD_NAMESPACE::rigidbody::GeneralizedVelocity>>;
%template(VecBiorbdGeneralizedAcceleration) std::vector<BIORBD_NAMESPACE::rigidbody::GeneralizedAcceleration>;
%template(MatBiorbdGeneralizedAcceleration) std::vector<std::vector<BIORBD_NAMESPACE::rigidbody::GeneralizedAcceleration>>;

%template(VecBiorbdNodeSegment) std::vector<biorbd::rigidbody::NodeSegment>;
%template(MatBiorbdNodeSegment) std::vector<std::vector<biorbd::rigidbody::NodeSegment>>;
%template(VecBiorbdMeshFace) std::vector<biorbd::rigidbody::MeshFace>;
%template(MatBiorbdMeshFace) std::vector<std::vector<biorbd::rigidbody::MeshFace>>;
%template(VecBiorbdNodeSegment) std::vector<BIORBD_NAMESPACE::rigidbody::NodeSegment>;
%template(MatBiorbdNodeSegment) std::vector<std::vector<BIORBD_NAMESPACE::rigidbody::NodeSegment>>;
%template(VecBiorbdMeshFace) std::vector<BIORBD_NAMESPACE::rigidbody::MeshFace>;
%template(MatBiorbdMeshFace) std::vector<std::vector<BIORBD_NAMESPACE::rigidbody::MeshFace>>;

%template(PairBiorbdNodeSegment) std::pair<biorbd::rigidbody::NodeSegment, biorbd::rigidbody::NodeSegment>;
%template(PairBiorbdNodeSegment) std::pair<BIORBD_NAMESPACE::rigidbody::NodeSegment, BIORBD_NAMESPACE::rigidbody::NodeSegment>;

%template(VecBiorbdIMU) std::vector<biorbd::rigidbody::IMU>;
%template(MatBiorbdIMU) std::vector<std::vector<biorbd::rigidbody::IMU>>;
%template(VecBiorbdIMU) std::vector<BIORBD_NAMESPACE::rigidbody::IMU>;
%template(MatBiorbdIMU) std::vector<std::vector<BIORBD_NAMESPACE::rigidbody::IMU>>;
}

%include "@CMAKE_SOURCE_DIR@/include/RigidBody/RigidBodyEnums.h"
Expand Down
44 changes: 22 additions & 22 deletions binding/biorbd_utils.i.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,44 @@

// Instantiate templates
namespace std {
%template(VecBiorbdString) std::vector<biorbd::utils::String>;
%template(PairBiorbdString) std::pair<biorbd::utils::String, biorbd::utils::String>;
%template(VecBiorbdString) std::vector<BIORBD_NAMESPACE::utils::String>;
%template(PairBiorbdString) std::pair<BIORBD_NAMESPACE::utils::String, BIORBD_NAMESPACE::utils::String>;

%template(VecBiorbdVector) std::vector<biorbd::utils::Vector>;
%template(MatBiorbdVector) std::vector<std::vector<biorbd::utils::Vector>>;
%template(VecBiorbdSpatialVector) std::vector<biorbd::utils::SpatialVector>;
%template(MatBiorbdMatrix) std::vector<biorbd::utils::Matrix>;
%template(VecBiorbdRotoTrans) std::vector<biorbd::utils::RotoTrans>;
%template(MatBiorbdRotoTrans) std::vector<std::vector<biorbd::utils::RotoTrans>>;
%template(VecBiorbdRototation) std::vector<biorbd::utils::Rotation>;
%template(MatBiorbdRototation) std::vector<std::vector<biorbd::utils::Rotation>>;
%template(VecBiorbdNode) std::vector<biorbd::utils::Vector3d>;
%template(MatBiorbdNode) std::vector<std::vector<biorbd::utils::Vector3d>>;
%template(VecBiorbdRange) std::vector<biorbd::utils::Range>;
%template(MatBiorbdRange) std::vector<std::vector<biorbd::utils::Range>>;
%template(VecBiorbdVector) std::vector<BIORBD_NAMESPACE::utils::Vector>;
%template(MatBiorbdVector) std::vector<std::vector<BIORBD_NAMESPACE::utils::Vector>>;
%template(VecBiorbdSpatialVector) std::vector<BIORBD_NAMESPACE::utils::SpatialVector>;
%template(MatBiorbdMatrix) std::vector<BIORBD_NAMESPACE::utils::Matrix>;
%template(VecBiorbdRotoTrans) std::vector<BIORBD_NAMESPACE::utils::RotoTrans>;
%template(MatBiorbdRotoTrans) std::vector<std::vector<BIORBD_NAMESPACE::utils::RotoTrans>>;
%template(VecBiorbdRototation) std::vector<BIORBD_NAMESPACE::utils::Rotation>;
%template(MatBiorbdRototation) std::vector<std::vector<BIORBD_NAMESPACE::utils::Rotation>>;
%template(VecBiorbdNode) std::vector<BIORBD_NAMESPACE::utils::Vector3d>;
%template(MatBiorbdNode) std::vector<std::vector<BIORBD_NAMESPACE::utils::Vector3d>>;
%template(VecBiorbdRange) std::vector<BIORBD_NAMESPACE::utils::Range>;
%template(MatBiorbdRange) std::vector<std::vector<BIORBD_NAMESPACE::utils::Range>>;
}


%extend biorbd::utils::String{
%extend BIORBD_NAMESPACE::utils::String{
std::string to_string(){
return *$self;
}
}

%extend biorbd::utils::Rotation{
biorbd::utils::Rotation transpose(){
%extend BIORBD_NAMESPACE::utils::Rotation{
BIORBD_NAMESPACE::utils::Rotation transpose(){
return $self->RigidBodyDynamics::Math::Matrix3d::transpose();
}

biorbd::utils::Rotation operator*(
const biorbd::utils::Rotation& other){
BIORBD_NAMESPACE::utils::Rotation operator*(
const BIORBD_NAMESPACE::utils::Rotation& other){
return $self->RigidBodyDynamics::Math::Matrix3d::operator*(other);
}
}

%extend biorbd::utils::Vector3d{
biorbd::utils::NODE_TYPE typeOfNode() const{
return $self->biorbd::utils::Node::typeOfNode();
%extend BIORBD_NAMESPACE::utils::Vector3d{
BIORBD_NAMESPACE::utils::NODE_TYPE typeOfNode() const{
return $self->BIORBD_NAMESPACE::utils::Node::typeOfNode();
}
}

Expand Down
Loading

0 comments on commit 3a9f4aa

Please sign in to comment.