|
9 | 9 | #include "RigidBody/GeneralizedVelocity.h" |
10 | 10 | #include "RigidBody/GeneralizedAcceleration.h" |
11 | 11 | #include "RigidBody/GeneralizedTorque.h" |
| 12 | +#include "RigidBody/NodeSegment.h" |
12 | 13 | #ifdef MODULE_MUSCLES |
13 | 14 | #include "Muscles/all.h" |
14 | 15 | #include "Utils/String.h" |
@@ -275,29 +276,56 @@ TEST(IdealizedActuator, copy) |
275 | 276 | EXPECT_NEAR(deepCopyLaterLength, 0.066381977535807504, requiredPrecision); |
276 | 277 | } |
277 | 278 |
|
278 | | - // Change the position of the insertion and pennation angle and compare again (length and insertion in Local) |
279 | | - biorbd::muscles::Characteristics charac(idealizedActuator.characteristics()); |
280 | | - charac.setPennationAngle(0.523599); |
281 | | - biorbd::utils::Vector3d insertion(idealizedActuator.position().insertionInLocal()); |
282 | | - insertion.set(0.2, 0.2, 0.2); |
283 | | - biorbd::utils::String oldName(insertion.biorbd::utils::Node::name()); |
284 | | - biorbd::utils::String newName("MyNewName"); |
285 | | - insertion.setName(newName); |
286 | | - idealizedActuator.updateOrientations(model, Q, qDot, 2); |
| 279 | + { |
| 280 | + // Change the position of the insertion and pennation angle and compare again (length and insertion in Local) |
| 281 | + biorbd::muscles::Characteristics charac(idealizedActuator.characteristics()); |
| 282 | + charac.setPennationAngle(0.523599); |
| 283 | + biorbd::utils::Vector3d insertion(idealizedActuator.position().insertionInLocal()); |
| 284 | + insertion.set(0.2, 0.2, 0.2); |
| 285 | + biorbd::utils::String oldName(insertion.biorbd::utils::Node::name()); |
| 286 | + biorbd::utils::String newName("MyNewName"); |
| 287 | + insertion.setName(newName); |
| 288 | + idealizedActuator.updateOrientations(model, Q, qDot, 2); |
| 289 | + |
| 290 | + { |
| 291 | + SCALAR_TO_DOUBLE(length, idealizedActuator.position().length()); |
| 292 | + SCALAR_TO_DOUBLE(shallowCopyLength, shallowCopy.position().length()); |
| 293 | + SCALAR_TO_DOUBLE(deepCopyNowLength, deepCopyNow.position().length()); |
| 294 | + SCALAR_TO_DOUBLE(deepCopyLaterLength, deepCopyLater.position().length()); |
| 295 | + EXPECT_NEAR(length, 0.07570761027741163, requiredPrecision); |
| 296 | + EXPECT_NEAR(shallowCopyLength, 0.07570761027741163, requiredPrecision); |
| 297 | + EXPECT_NEAR(deepCopyNowLength, 0.066381977535807504, requiredPrecision); |
| 298 | + EXPECT_NEAR(deepCopyLaterLength, 0.066381977535807504, requiredPrecision); |
| 299 | + EXPECT_EQ(idealizedActuator.position().insertionInLocal().biorbd::utils::Node::name(), newName); |
| 300 | + EXPECT_EQ(shallowCopy.position().insertionInLocal().biorbd::utils::Node::name(), newName); |
| 301 | + EXPECT_EQ(deepCopyNow.position().insertionInLocal().biorbd::utils::Node::name(), oldName); |
| 302 | + EXPECT_EQ(deepCopyLater.position().insertionInLocal().biorbd::utils::Node::name(), oldName); |
| 303 | + } |
| 304 | + |
| 305 | + } |
287 | 306 |
|
288 | 307 | { |
289 | | - SCALAR_TO_DOUBLE(length, idealizedActuator.position().length()); |
290 | | - SCALAR_TO_DOUBLE(shallowCopyLength, shallowCopy.position().length()); |
291 | | - SCALAR_TO_DOUBLE(deepCopyNowLength, deepCopyNow.position().length()); |
292 | | - SCALAR_TO_DOUBLE(deepCopyLaterLength, deepCopyLater.position().length()); |
293 | | - EXPECT_NEAR(length, 0.07570761027741163, requiredPrecision); |
294 | | - EXPECT_NEAR(shallowCopyLength, 0.07570761027741163, requiredPrecision); |
295 | | - EXPECT_NEAR(deepCopyNowLength, 0.066381977535807504, requiredPrecision); |
296 | | - EXPECT_NEAR(deepCopyLaterLength, 0.066381977535807504, requiredPrecision); |
297 | | - EXPECT_EQ(idealizedActuator.position().insertionInLocal().biorbd::utils::Node::name(), newName); |
298 | | - EXPECT_EQ(shallowCopy.position().insertionInLocal().biorbd::utils::Node::name(), newName); |
299 | | - EXPECT_EQ(deepCopyNow.position().insertionInLocal().biorbd::utils::Node::name(), oldName); |
300 | | - EXPECT_EQ(deepCopyLater.position().insertionInLocal().biorbd::utils::Node::name(), oldName); |
| 308 | + // Change the position giving an actual vector |
| 309 | + biorbd::utils::Vector3d newPosition(1, 2, 3); |
| 310 | + biorbd::utils::String oldName("MyNewName"); |
| 311 | + biorbd::utils::String newName("MyNewNewName"); |
| 312 | + biorbd::rigidbody::NodeSegment newNode(newPosition, newName, "", true, true, "", 0); |
| 313 | + { |
| 314 | + const_cast<biorbd::muscles::Geometry&>(idealizedActuator.position()).setOrigin(newPosition); |
| 315 | + const_cast<biorbd::muscles::Geometry&>(idealizedActuator.position()).setInsertionInLocal(newPosition); |
| 316 | + const biorbd::utils::Vector3d& origin = idealizedActuator.position().originInLocal(); |
| 317 | + const biorbd::utils::Vector3d& insertion = idealizedActuator.position().insertionInLocal(); |
| 318 | + EXPECT_STREQ(origin.biorbd::utils::Node::name().c_str(), "TRImed_origin"); |
| 319 | + EXPECT_STREQ(insertion.biorbd::utils::Node::name().c_str(), oldName.c_str()); |
| 320 | + } |
| 321 | + { |
| 322 | + const_cast<biorbd::muscles::Geometry&>(idealizedActuator.position()).setOrigin(newNode); |
| 323 | + const_cast<biorbd::muscles::Geometry&>(idealizedActuator.position()).setInsertionInLocal(newNode); |
| 324 | + const biorbd::utils::Vector3d& origin = idealizedActuator.position().originInLocal(); |
| 325 | + const biorbd::utils::Vector3d& insertion = idealizedActuator.position().insertionInLocal(); |
| 326 | + EXPECT_STREQ(origin.biorbd::utils::Node::name().c_str(), newName.c_str()); |
| 327 | + EXPECT_STREQ(insertion.biorbd::utils::Node::name().c_str(), newName.c_str()); |
| 328 | + } |
301 | 329 | } |
302 | 330 | } |
303 | 331 |
|
|
0 commit comments