measured-3d-force.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2025 CNRS INRIA LORIA
3 //
4 // This file is part of tsid
5 // tsid is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 // tsid is distributed in the hope that it will be
10 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Lesser Public License for more details. You should have
13 // received a copy of the GNU Lesser General Public License along with
14 // tsid If not, see
15 // <http://www.gnu.org/licenses/>.
16 //
17 
19 
21 
22 namespace tsid {
23 namespace contacts {
24 
25 using namespace std;
26 using namespace math;
27 using namespace pinocchio;
28 
30 
32  const std::string &frameName)
33  : MeasuredForceBase(name, robot), m_frame_name(frameName) {
34  assert(m_robot.model().existFrame(frameName));
36 
37  m_fext.setZero();
38  m_J.setZero(3, robot.nv());
39  m_J_rotated.setZero(3, robot.nv());
40  m_computedTorques.setZero(robot.nv());
41 
42  m_local_frame = true;
43 }
44 
46  Matrix6x J;
47  J.setZero(6, m_robot.nv());
48 
50  m_J = J.topRows(3);
51 
52  if (!m_local_frame) {
53  // Compute Jacobian in local world-oriented frame
54  SE3 oMi, oMi_rotation_only;
55  oMi_rotation_only.setIdentity();
57  oMi_rotation_only.rotation(oMi.rotation());
58 
59  // Use an explicit temporary `m_J_rotated` here to avoid allocations.
60  m_J_rotated.noalias() = (oMi_rotation_only.toActionMatrix() * J).topRows(3);
61  m_J = m_J_rotated;
62  }
63 
64  m_computedTorques = m_J.transpose() * m_fext;
65 
66  return m_computedTorques;
67 }
68 
70  m_fext = fext;
71 }
72 
74  return m_fext;
75 }
76 
77 void Measured3Dforce::useLocalFrame(bool local_frame) {
78  m_local_frame = local_frame;
79 }
80 
81 } // namespace contacts
82 } // namespace tsid
tsid::robots::RobotWrapper::framePosition
SE3 framePosition(const Data &data, const Model::FrameIndex index) const
Definition: src/robots/robot-wrapper.cpp:216
pinocchio::DataTpl
tsid::contacts::Measured3Dforce::Vector3
math::Vector3 Vector3
Definition: measured-3d-force.hpp:32
tsid::contacts::Measured3Dforce::useLocalFrame
void useLocalFrame(bool local_frame)
Specifies if the external force and jacobian is expressed in the local frame or the local world-orien...
Definition: measured-3d-force.cpp:77
tsid::contacts::Measured3Dforce::m_frame_id
Index m_frame_id
Definition: measured-3d-force.hpp:61
pinocchio::SE3
context::SE3 SE3
setup.data
data
Definition: setup.in.py:48
demo_quadruped.robot
robot
Definition: demo_quadruped.py:51
J
J
tsid::contacts::MeasuredForceBase
Definition: measured-force-base.hpp:28
ModelTpl< context::Scalar, context::Options >::existFrame
bool existFrame(const std::string &name, const FrameType &type=(FrameType)(JOINT|FIXED_JOINT|BODY|OP_FRAME|SENSOR)) const
measured-3d-force.hpp
tsid::contacts::Measured3Dforce::computeJointTorques
const Vector & computeJointTorques(Data &data) override
Definition: measured-3d-force.cpp:45
tsid::contacts::Measured3Dforce::getMeasuredContactForce
const Vector3 & getMeasuredContactForce() const
Definition: measured-3d-force.cpp:73
tsid::contacts::Measured3Dforce::m_computedTorques
Vector m_computedTorques
Definition: measured-3d-force.hpp:65
tsid::contacts::Measured3Dforce::m_fext
Vector3 m_fext
Definition: measured-3d-force.hpp:62
tsid::robots::RobotWrapper::nv
virtual int nv() const
Definition: src/robots/robot-wrapper.cpp:97
tsid::robots::RobotWrapper::model
const Model & model() const
Accessor to model.
Definition: src/robots/robot-wrapper.cpp:102
tsid::contacts::Measured3Dforce::m_J_rotated
Matrix3x m_J_rotated
Definition: measured-3d-force.hpp:64
tsid::contacts::Measured3Dforce::setMeasuredContactForce
void setMeasuredContactForce(const Vector3 &fext)
Definition: measured-3d-force.cpp:69
tsid::contacts::Matrix6x
pinocchio::Data::Matrix6x Matrix6x
Definition: measured-3d-force.cpp:29
robot-wrapper.hpp
ModelTpl< context::Scalar, context::Options >::getFrameId
FrameIndex getFrameId(const std::string &name, const FrameType &type=(FrameType)(JOINT|FIXED_JOINT|BODY|OP_FRAME|SENSOR)) const
tsid::contacts::Measured3Dforce::m_J
Matrix3x m_J
Definition: measured-3d-force.hpp:63
tsid::robots::RobotWrapper::frameJacobianLocal
void frameJacobianLocal(Data &data, const Model::FrameIndex index, Data::Matrix6x &J) const
Definition: src/robots/robot-wrapper.cpp:338
demo_quadruped.contacts
int contacts
Definition: demo_quadruped.py:98
setup.name
name
Definition: setup.in.py:179
tsid::math::Vector
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: math/fwd.hpp:35
tsid::contacts::Measured3Dforce::Measured3Dforce
Measured3Dforce(const std::string &name, RobotWrapper &robot, const std::string &frameName)
Definition: measured-3d-force.cpp:31
tsid
Definition: bindings/python/constraint/constraint-bound.cpp:21
std
tsid::robots::RobotWrapper
Wrapper for a robot based on pinocchio.
Definition: robots/robot-wrapper.hpp:37
pinocchio::DataTpl::Matrix6x
Eigen::Matrix< Scalar, 6, Eigen::Dynamic, Options > Matrix6x
tsid::contacts::MeasuredForceBase::m_robot
RobotWrapper & m_robot
Reference on the robot model.
Definition: measured-force-base.hpp:54
tsid::contacts::Measured3Dforce::m_local_frame
bool m_local_frame
Definition: measured-3d-force.hpp:66
test_Contact.frameName
string frameName
Definition: test_Contact.py:29
pinocchio


tsid
Author(s): Andrea Del Prete, Justin Carpentier
autogenerated on Sat May 3 2025 02:48:16