Skip to content

Commit 5954e37

Browse files
authored
Merge pull request #184 from pariterre/master
Fix SegFault when changing Vector3d position
2 parents d172cad + e0648c0 commit 5954e37

21 files changed

+544
-37
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ script:
107107
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
108108
cd test\\Release;
109109
xcopy ..\\models .\\models\\;
110+
xcopy ..\\models\\IMUandCustomRT .\\models\\IMUandCustomRT\\;
110111
xcopy ..\\models\\meshFiles .\\models\\meshFiles\\;
111112
xcopy ..\\models\\meshFiles\\vtp .\\models\\meshFiles\\vtp\\;
112113
./biorbd_tests.exe;

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.0")
33
cmake_policy(SET CMP0042 NEW)
44
endif()
55

6-
project(biorbd VERSION 1.3.5)
6+
project(biorbd VERSION 1.3.7)
77
set (CMAKE_CXX_STANDARD 11)
88
set (BIORBD_NAME ${PROJECT_NAME})
99

binding/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ option(BINDER_MATLAB "Build Matlab module" OFF)
1111

1212
if (BIORBD_USE_CASADI_MATH)
1313
if(BINDER_C)
14-
message("Casadi option is not compatible with BINDER_C")
15-
set(BINDER_C OFF)
14+
message(FATAL_ERROR "Casadi option is not compatible with BINDER_C")
1615
endif(BINDER_C)
1716
if(BINDER_MATLAB)
18-
message("Casadi option is not compatible with BINDER_MATLAB")
19-
set(BINDER_MATLAB OFF)
17+
message(FATAL_ERROR "Casadi option is not compatible with BINDER_MATLAB")
2018
endif(BINDER_MATLAB)
2119
endif(BIORBD_USE_CASADI_MATH)
2220

include/RigidBody/RotoTransNodes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ class BIORBD_API RotoTransNodes
7070
///
7171
unsigned int nbRTs() const;
7272

73+
///
74+
/// \brief Return the number of RTs in the set
75+
/// \return The number of RTs
76+
///
77+
unsigned int size() const;
78+
7379
///
7480
/// \brief Return the names of the RTs
7581
/// \return The names of the RTs

include/Utils/Vector3d.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ class BIORBD_API Vector3d : public RigidBodyDynamics::Math::Vector3d, public bio
148148
void applyRT(
149149
const RotoTrans& rt);
150150

151+
///
152+
/// \brief Set a new position
153+
/// \param v The new position
154+
///
155+
void setPosition(
156+
const biorbd::utils::Vector3d& v);
157+
151158
#ifndef SWIG
152159

153160
#ifdef BIORBD_USE_EIGEN3_MATH

src/ModelReader.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ void biorbd::Reader::readModelFile(
385385
biorbd::utils::Error::raise("MIMU is no more the right tag, change it to IMU!");
386386
}
387387
else if (!main_tag.tolower().compare("imu") || !main_tag.tolower().compare("mimu") || !main_tag.tolower().compare("customrt")){
388+
biorbd::utils::String rtType(main_tag.tolower());
388389
biorbd::utils::String name;
389390
file.read(name);
390391
biorbd::utils::String parent_str("root");
@@ -504,11 +505,11 @@ void biorbd::Reader::readModelFile(
504505
isAxis2End = true;
505506
}
506507
}
507-
if (! (isAxis1Beg && isAxis1End && isAxis2Beg && isAxis2End)){
508-
biorbd::utils::Error::raise("All the axes name and origin for the IMU " + name + " must be set and correspond to marker names previously defined on the same parent");
508+
if (! (isAxis1Beg && isAxis1End && isAxis2Beg && isAxis2End && isOrigin)){
509+
biorbd::utils::Error::raise("All the axes name and origin for the " + rtType + "(" + name + ") must be set and correspond to marker names previously defined on the same parent");
509510
}
510511
if (!(!axisToRecalculate.tolower().compare("firstaxis") || !axisToRecalculate.tolower().compare("secondaxis"))){
511-
biorbd::utils::Error::raise("The 'recalculate' option for IMU " + name + " must be 'firstaxis' or 'secondaxis'");
512+
biorbd::utils::Error::raise("The 'recalculate' option for " + rtType + "(" + name + ") must be 'firstaxis' or 'secondaxis'");
512513
}
513514
axisToRecalculate = !axisToRecalculate.tolower().compare("firstaxis") ? firstAxis : secondAxis;
514515

src/RigidBody/RotoTransNodes.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ unsigned int biorbd::rigidbody::RotoTransNodes::nbRTs() const
5858
return static_cast<unsigned int>(m_RTs->size());
5959
}
6060

61+
unsigned int biorbd::rigidbody::RotoTransNodes::size() const
62+
{
63+
return static_cast<unsigned int>(m_RTs->size());
64+
}
6165

6266
// Get the markers in the global reference
6367
const std::vector<biorbd::utils::RotoTransNode>& biorbd::rigidbody::RotoTransNodes::RTs() const

src/Utils/Rotation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ biorbd::utils::Matrix biorbd::utils::Rotation::fromMarkersNonNormalized(
107107
const std::pair<biorbd::utils::String, biorbd::utils::String>& axesNames,
108108
const biorbd::utils::String &axisToRecalculate)
109109
{
110+
if (!axesNames.first.compare("") || !axesNames.second.compare("")){
111+
biorbd::utils::Error::raise("axesNames must be defined with a pair of \"x\", \"y\" or \"z\"");
112+
}
113+
110114
// Figure out where to put the axes
111115
std::vector<unsigned int> map(3);
112116
std::vector<unsigned int> toMultiply(2);

src/Utils/Vector3d.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,24 @@ biorbd::utils::Vector3d biorbd::utils::Vector3d::applyRT(const biorbd::utils::Ro
100100
return static_cast<RigidBodyDynamics::Math::VectorNd>((rt * v).block(0, 0, 3, 1));
101101
}
102102

103-
void biorbd::utils::Vector3d::applyRT(const biorbd::utils::RotoTrans &rt){
103+
void biorbd::utils::Vector3d::applyRT(
104+
const biorbd::utils::RotoTrans &rt){
104105
RigidBodyDynamics::Math::Vector4d v;
105106
v.block(0, 0, 3, 1) = *this;
106107
v[3] = 1;
107-
*this = (rt * v).block(0, 0, 3, 1);
108+
setPosition((rt * v).block(0, 0, 3, 1));
109+
}
110+
111+
void biorbd::utils::Vector3d::setPosition(
112+
const biorbd::utils::Vector3d& v)
113+
{
114+
#ifdef BIORBD_USE_CASADI_MATH
115+
(*this)(0) = v(0);
116+
(*this)(1) = v(1);
117+
(*this)(2) = v(2);
118+
#else
119+
*this = v;
120+
#endif
108121
}
109122

110123
void biorbd::utils::Vector3d::setType()

test/CMakeLists.txt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,8 @@ if (CMAKE_BUILD_TYPE STREQUAL "Coverage")
8888
endif() #CMAKE_BUILD_TYPE STREQUAL "Coverage"
8989

9090
# Copy the necessary file for the tests
91-
file(GLOB BIORBD_TEST_FILES
92-
"${CMAKE_SOURCE_DIR}/test/models/*.bioMod")
93-
file(COPY ${BIORBD_TEST_FILES}
94-
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/models/")
95-
file(GLOB BIORBD_TEST_FILES
96-
"${CMAKE_SOURCE_DIR}/test/models/meshFiles/*.bioMesh")
97-
file(COPY ${BIORBD_TEST_FILES}
98-
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/models/meshFiles/")
99-
file(GLOB BIORBD_TEST_FILES
100-
"${CMAKE_SOURCE_DIR}/test/models/meshFiles/vtp/*.vtp")
101-
file(COPY ${BIORBD_TEST_FILES}
102-
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/models/meshFiles/vtp/")
103-
file(GLOB BIORBD_TEST_FILES
104-
"${CMAKE_SOURCE_DIR}/test/models/meshFiles/*.obj")
105-
file(COPY ${BIORBD_TEST_FILES}
106-
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/models/meshFiles/")
91+
file(COPY "${CMAKE_SOURCE_DIR}/test/models/"
92+
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/models/")
10793

10894
set(ALL_TESTS "${PROJECT_NAME}")
10995
if (BINDER_C)

0 commit comments

Comments
 (0)