1 #define BIORBD_API_EXPORTS
2 #include "RigidBody/IMUs.h"
4 #include <rbdl/Model.h>
5 #include <rbdl/Kinematics.h>
6 #include "Utils/String.h"
7 #include "Utils/Matrix.h"
8 #include "Utils/Rotation.h"
9 #include "RigidBody/GeneralizedCoordinates.h"
10 #include "RigidBody/Joints.h"
11 #include "RigidBody/Segment.h"
12 #include "RigidBody/IMU.h"
15 m_IMUs(std::make_shared<std::vector<biorbd::rigidbody::
IMU>>())
39 m_IMUs->resize(other.
m_IMUs->size());
40 for (
unsigned int i=0; i<other.
m_IMUs->size(); ++i)
41 (*m_IMUs)[i] = (*other.
m_IMUs)[i].DeepCopy();
62 return static_cast<unsigned int>(m_IMUs->size());
74 std::vector<biorbd::rigidbody::IMU> pos;
75 for (
unsigned int i=0; i<nbIMUs(); ++i)
76 if (!
IMU(i).
parent().compare(segmentName))
77 pos.push_back(
IMU(i));
83 return (*m_IMUs)[idx];
97 std::vector<biorbd::rigidbody::IMU> pos;
98 for (
unsigned int i=0; i<nbIMUs(); ++i)
99 pos.push_back(
IMU(Q, i,
false));
133 std::vector<biorbd::rigidbody::IMU> pos;
134 for (
unsigned int i=0; i<nbIMUs(); ++i)
136 pos.push_back(
IMU(Q, i, updateKin));
143 std::vector<biorbd::rigidbody::IMU> pos;
144 for (
unsigned int i=0; i<nbIMUs(); ++i)
146 pos.push_back(
IMU(i));
161 std::vector<biorbd::rigidbody::IMU> pos;
162 for (
unsigned int i=0; i<nbIMUs(); ++i)
164 pos.push_back(
IMU(Q, i, updateKin));
171 std::vector<biorbd::rigidbody::IMU> pos;
172 for (
unsigned int i=0; i<nbIMUs(); ++i)
174 pos.push_back(
IMU(i));
192 std::vector<biorbd::rigidbody::IMU> pos;
193 for (
unsigned int i=0; i<nbIMUs(); ++i)
194 if (!((*m_IMUs)[i]).parent().compare(name))
195 pos.push_back(
IMU(Q,i,
false));
205 return IMUJacobian(Q, updateKin,
false);
213 return IMUJacobian(Q, updateKin,
true);
221 bool lookForTechnical)
229 std::vector<biorbd::utils::Matrix> G;
231 for (
unsigned int idx=0; idx<nbIMUs(); ++idx){
237 unsigned int id = model.GetBodyId(node.
parent().c_str());
251 unsigned int nbTech = 0;
254 if (imu.isTechnical())
262 unsigned int nbAnat = 0;
265 if (imu.isAnatomical())
274 std::vector<biorbd::utils::String> names;
275 for (
unsigned int i=0; i<nbIMUs(); ++i)
276 names.push_back(
IMU(i).biorbd::utils::Node::name());
283 std::vector<biorbd::utils::String> names;
284 for (
unsigned int i=0; i<nbIMUs(); ++i)
286 names.push_back(
IMU(i).biorbd::utils::Node::name());
294 std::vector<biorbd::utils::String> names;
295 for (
unsigned int i=0; i<nbIMUs(); ++i)
297 names.push_back(
IMU(i).biorbd::utils::Node::name());
bool isAnatomical() const
Return if the IMU is anatomical.
unsigned int nbTechIMUs()
Return the number of technical inertial measurement units (IMU)
Class GeneralizedCoordinates.
const std::vector< biorbd::rigidbody::IMU > & IMU() const
Return all the IMU in the local reference of the segment.
A RotoTrans which is attached to a segment.
const biorbd::utils::String & name() const
Return the name of the node.
biorbd::utils::RotoTrans globalJCS(const biorbd::rigidbody::GeneralizedCoordinates &Q, const biorbd::utils::String &name)
Return the joint coordinate system (JCS) for the segment in global reference frame at a given Q.
int GetBodyBiorbdId(const biorbd::utils::String &segmentName) const
Return the biorbd body identification.
std::vector< biorbd::rigidbody::IMU > segmentIMU(const biorbd::rigidbody::GeneralizedCoordinates &Q, unsigned int idx, bool updateKin=true)
Return all the inertial measurement units (IMU) on a specified segment.
unsigned int nbIMUs() const
Return the number of inertial measurement units (IMU) in the set.
This is the core of the musculoskeletal model in biorbd.
std::vector< biorbd::utils::String > IMUsNames()
Return the names of the inertial measurement units (IMU)
const biorbd::rigidbody::Segment & segment(unsigned int idx) const
Get a segment of index idx.
A wrapper for the Eigen::MatrixXd.
void CalcMatRotJacobian(const biorbd::rigidbody::GeneralizedCoordinates &Q, unsigned int segmentIdx, const RigidBodyDynamics::Math::Matrix3d &rotation, RigidBodyDynamics::Math::MatrixNd &G, bool updateKin)
Calculate the jacobian matrix of a rotation matrix.
std::shared_ptr< std::vector< biorbd::rigidbody::IMU > > m_IMUs
All the inertial Measurement Units.
virtual ~IMUs()
Destroy the class properly.
Wrapper around the std::string class with augmented functionality.
std::vector< biorbd::utils::Matrix > TechnicalIMUJacobian(const biorbd::rigidbody::GeneralizedCoordinates &Q, bool updateKin=true)
Return the jacobian of the technical inertial measurement units (IMU)
void addIMU(bool technical=true, bool anatomical=true)
Add a new inertial measurement unit to the set.
std::vector< biorbd::rigidbody::IMU > anatomicalIMU()
Return all the anatomical inertial measurement units (IMU) in their respective segment local referenc...
std::vector< biorbd::utils::Matrix > IMUJacobian(const biorbd::rigidbody::GeneralizedCoordinates &Q, bool updateKin=true)
Return the jacobian of the inertial measurement units (IMU)
std::vector< biorbd::rigidbody::IMU > technicalIMU()
Return all the technical inertial measurement units (IMU) in their respective segment local reference...
biorbd::rigidbody::IMUs DeepCopy() const
Deep copy of the inertial measurement units data.
void UpdateKinematicsCustom(const biorbd::rigidbody::GeneralizedCoordinates *Q=nullptr, const biorbd::rigidbody::GeneralizedVelocity *Qdot=nullptr, const biorbd::rigidbody::GeneralizedAcceleration *Qddot=nullptr)
Update the kinematic variables such as body velocities and accelerations in the model to reflect the ...
const biorbd::utils::String & parent() const
Return the parent name of the node.
std::vector< biorbd::utils::String > technicalIMUsNames()
Return the names of the technical inertial measurement units (IMU)
bool isTechnical() const
Return if the IMU is technical.
unsigned int nbAnatIMUs()
Return the number of anatomical inertial measurement units (IMU)
biorbd::utils::Rotation rot() const
Return the rotation matrix.
IMUs()
Construct inertial measurement units set.
std::vector< biorbd::utils::String > anatomicalIMUsNames()
Return the names of the anatomical inertial measurement units (IMU)