@@ -84,12 +84,14 @@ double JointFeatures::GetJointForce(
84
84
const auto *joint = this ->ReferenceInterface <JointInfo>(_id);
85
85
const auto *identifier = std::get_if<InternalJoint>(&joint->identifier );
86
86
87
- if (identifier) {
87
+ if (identifier)
88
+ {
88
89
const auto *model = this ->ReferenceInterface <ModelInfo>(joint->model );
89
90
auto feedback = model->body ->getLink (identifier->indexInBtModel ).m_jointFeedback ;
90
91
const auto &link = model->body ->getLink (identifier->indexInBtModel );
91
92
results = 0.0 ;
92
- if (link .m_jointType == btMultibodyLink::eRevolute) {
93
+ if (link .m_jointType == btMultibodyLink::eRevolute)
94
+ {
93
95
// According to the documentation in btMultibodyLink.h, m_axesTop[0] is the
94
96
// joint axis for revolute joints.
95
97
Eigen::Vector3d axis = convert (link .getAxisTop (0 ));
@@ -99,11 +101,16 @@ double JointFeatures::GetJointForce(
99
101
angular.getX (),
100
102
angular.getY (),
101
103
angular.getZ ());
102
- // BUG: The total force is 2 times the cmd one see:
103
- // https://github.com/bulletphysics/bullet3/discussions/3713
104
104
results += axis_converted.Dot (angularTorque);
105
- return results / 2.0 ;
106
- } else if (link .m_jointType == btMultibodyLink::ePrismatic) {
105
+ #if BT_BULLET_VERSION < 326
106
+ // not always true
107
+ return results / 2.0 ;
108
+ #else
109
+ return results;
110
+ #endif
111
+ }
112
+ else if (link .m_jointType == btMultibodyLink::ePrismatic)
113
+ {
107
114
auto axis = convert (link .getAxisBottom (0 ));
108
115
math::Vector3 axis_converted (axis[0 ], axis[1 ], axis[2 ]);
109
116
btVector3 linear = feedback->m_reactionForces .getLinear ();
@@ -112,7 +119,12 @@ double JointFeatures::GetJointForce(
112
119
linear.getY (),
113
120
linear.getZ ());
114
121
results += axis_converted.Dot (linearForce);
115
- return results / 2.0 ;
122
+ #if BT_BULLET_VERSION < 326
123
+ // not always true
124
+ return results / 2.0 ;
125
+ #else
126
+ return results;
127
+ #endif
116
128
}
117
129
}
118
130
return results;
0 commit comments