SuperDex Physics C++ API
Loading...
Searching...
No Matches
articulated_body_params.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19// PLEASE DO NOT ADD OTHER INCLUDES HERE. This header is included in the mochi_physics public API.
23
24namespace superdex {
25
26/**
27 * @brief Degree-of-freedom layout information for a single joint in an articulated body.
28 *
29 * @details Describes the offset and sizes of translation and rotation DoFs for a joint within
30 * the flattened DoF array of the articulated body.
31 */
33 /** @brief Offset of this joint's DoFs in the flattened DoF array. */
34 int offset = -1;
35 /** @brief Number of translational DoFs for this joint. */
36 int transSize = 0;
37 /** @brief Number of rotational DoFs for this joint. */
38 int rotSize = 0;
39
40 /**
41 * @brief Offset of this joint's translational DoFs in the flattened DoF array.
42 *
43 * @return The translational DoF offset (equal to @ref offset).
44 */
45 int GetTransOffset() const;
46
47 /**
48 * @brief Offset of this joint's rotational DoFs in the flattened DoF array.
49 *
50 * @return The rotational DoF offset (@ref offset + @ref transSize).
51 */
52 int GetRotOffset() const;
53
54 /**
55 * @brief Total number of DoFs for this joint.
56 *
57 * @return The total DoF count (@ref transSize + @ref rotSize).
58 */
59 int GetSize() const;
60
61#if MOCHI_LANGUAGE_CPP20
62 bool operator==(ArticulatedDofInfo const&) const = default;
63#endif
64
70};
71
72/**
73 * @brief Types of joints in an articulated body.
74 */
76 Free, ///< 6-DoF joint. Unconstrained relative motion between links.
77 Prismatic, ///< 1-DoF translational joint along a single axis.
78 Revolute, ///< 1-DoF rotational joint around a single axis.
79 Spherical, ///< 3-DoF rotational joint (ball-and-socket).
80 Hard, ///< 0-DoF rigid (weld) joint. No relative motion between links.
81 Cycle, ///< Cycle-closing joint in closed-loop topologies.
84};
85
86} // namespace superdex
87
90MOCHI_ENUM_ITEM(Prismatic)
91MOCHI_ENUM_ITEM(Revolute)
92MOCHI_ENUM_ITEM(Spherical)
94MOCHI_ENUM_ITEM(Cycle)
96MOCHI_ENUM_ITEM(Invalid)
98
99namespace superdex {
100
101/**
102 * @brief Defines a cycle-closing joint in an articulated body.
103 *
104 * @details Cycle joints create closed loops in the kinematic chain, allowing more complex
105 * topologies beyond simple tree structures.
106 */
108 /** @brief Child link index. */
109 int child = 0;
110
111 /** @brief Parent link index. */
112 int parent = 0;
113
114#if MOCHI_LANGUAGE_CPP20
115 bool operator==(ArticulatedCycleJoint const&) const = default;
116#endif
117
122};
123
124/**
125 * @brief Per-joint friction parameters for articulated bodies.
126 *
127 * @details Viscous and dry friction force/torque contributions are added together.
128 * - Viscous friction force/torque is proportional to velocity with coefficient @ref viscous.
129 * - The static-friction peak/breakaway force/torque is given by @ref coulomb + @ref stictionExtra.
130 * Static friction is regularized to allow slight slippage at speeds of up to @ref falloffVel.
131 * - Above the smoothing threshold |v| > @ref falloffVel, dynamic dry friction force/torque
132 * (excluding additional viscous friction) has magnitude
133 * @ref coulomb + @ref stictionExtra * exp(-pow((|v| - @ref falloffVel) / @ref stribeckVel, 2))
134 * when @ref stribeckVel > 0. If @ref stribeckVel = 0, the Stribeck term is omitted and the
135 * magnitude is @ref coulomb. Here |v| is the magnitude of the relative (linear or angular)
136 * velocity. This causes friction to decrease smoothly from the peak static value to @ref
137 * coulomb at high velocities.
138 */
140 /**
141 * @brief Viscous friction coefficient [N·s/m or N·m·s/rad].
142 *
143 * @note Default is zero (no viscous friction).
144 */
146
147 /**
148 * @brief Coulomb friction coefficient [N or N·m].
149 *
150 * @note Default is zero (no Coulomb friction).
151 */
153
154 /**
155 * @brief Velocity threshold for dry friction smoothing [m/s or rad/s].
156 *
157 * @details The dry friction force/torque smoothly transitions from 0 to the peak value as
158 * (linear or angular) velocity increases from 0 to @ref falloffVel.
159 *
160 * @note Smaller velocity thresholds improve physical accuracy but may degrade stability.
161 */
162 real falloffVel = 1e-3_r;
163
164 /**
165 * @brief [Experimental] Extra stiction force/torque [N or N·m] representing the difference
166 * between static and dynamic friction.
167 *
168 * @warning This is an experimental feature. It may be changed or removed in the future. Use at
169 * your own risk.
170 * @warning Nonzero values may harm convergence.
171 * @warning Nonzero extra stiction with zero Stribeck velocity results in a nonsmooth force.
172 *
173 * @note Must not be negative. The @ref coulomb represents dynamic friction in the high-velocity
174 * limit, and peak static friction is @ref coulomb + @ref stictionExtra.
175 * @note Defaults to zero (no difference between static and dynamic friction).
176 */
178
179 /**
180 * @brief [Experimental] Stribeck velocity [m/s or rad/s] governing how sharply friction
181 * transitions from static to dynamic coefficients as velocity increases.
182 *
183 * @warning This is an experimental feature. It may be changed or removed in the future. Use at
184 * your own risk.
185 * @warning Nonzero values may harm convergence.
186 * @warning Nonzero extra stiction with zero Stribeck velocity results in a nonsmooth force.
187 *
188 * @note Must not be negative. A smaller value means a sharper transition.
189 * @note Defaults to zero.
190 * @note This has no effect if @ref stictionExtra is zero.
191 */
193
194#if MOCHI_LANGUAGE_CPP20
195 bool operator==(ArticulatedJointFrictionParams const&) const = default;
196#endif
197
205};
206
207/**
208 * @brief Selects how a @ref RoutingElement contributes to a spatial tendon's routing.
209 */
211 /// A point fixed in a link's local frame (the same frame in which the link's mesh and
212 /// geometry are authored, i.e. the link's root-transform frame). Adjacent waypoints are joined
213 /// by a straight segment whose length contributes to the tendon length.
215 /// A constant moment arm contributing `coefficient * jointCoordinate`, as in a linear
216 /// transmission. Carries no geometry and breaks the polyline between waypoints.
218};
219
220} // namespace superdex
221
223MOCHI_ENUM_ITEM(Waypoint)
224MOCHI_ENUM_ITEM(LinearJoint)
226
227namespace superdex {
228
229/**
230 * @brief One ordered element in a spatial tendon's heterogeneous routing list.
231 *
232 * @details A @ref RoutingElementType::Waypoint uses @ref index (a link index) and @ref
233 * localPosition; a @ref RoutingElementType::LinearJoint uses @ref index (a joint index) and @ref
234 * coefficient. Order matters: a segment forms only between adjacent waypoints, so a linear-joint
235 * element between two waypoints leaves a gap.
236 */
238 /// Selects the interpretation of the remaining fields.
240
241 /// Waypoint: the link index the waypoint is attached to. LinearJoint: the joint index.
242 int index = 0;
243
244 /// Waypoint only: the waypoint position in the link's local frame (the same frame in which
245 /// the link's mesh and geometry are authored, i.e. the link's root-transform frame) [m].
247
248 /// LinearJoint only: the signed constant moment arm d(displacement)/d(joint DoF)
249 /// [m / joint DoF]; its sign sets whether the tendon lengthens or shortens with the joint DoF.
251
252#if MOCHI_LANGUAGE_CPP20
253 bool operator==(RoutingElement const&) const = default;
254#endif
255
262};
263
264} // namespace superdex
265
ArticulatedJointType
Types of joints in an articulated body.
@ Spherical
3-DoF rotational joint (ball-and-socket).
@ Revolute
1-DoF rotational joint around a single axis.
@ Prismatic
1-DoF translational joint along a single axis.
@ Hard
0-DoF rigid (weld) joint. No relative motion between links.
@ Cycle
Cycle-closing joint in closed-loop topologies.
@ Free
6-DoF joint. Unconstrained relative motion between links.
@ Invalid
Invalid constraint type.
RoutingElementType
Selects how a RoutingElement contributes to a spatial tendon's routing.
@ Waypoint
A point fixed in a link's local frame (the same frame in which the link's mesh and geometry are autho...
@ LinearJoint
A constant moment arm contributing coefficient * jointCoordinate, as in a linear transmission.
NdArray< real, 3 > Real3
Definition nd_array.h:106
@ Count
Number of actor type enum values.
Definition mochi_enums.h:38
#define MOCHI_ENUM_COUNT(name)
Definition reflection.h:275
#define MOCHI_ENUM_END()
Definition reflection.h:276
#define MOCHI_STRUCT_END()
Definition reflection.h:279
#define MOCHI_ENUM_BEGIN(name)
Definition reflection.h:273
#define MOCHI_FIELD(name)
Definition reflection.h:293
#define MOCHI_STRUCT_BEGIN(name)
Definition reflection.h:278
#define MOCHI_ENUM_ITEM(name)
Definition reflection.h:274
Defines a cycle-closing joint in an articulated body.
bool operator==(ArticulatedCycleJoint const &) const =default
Degree-of-freedom layout information for a single joint in an articulated body.
int transSize
Number of translational DoFs for this joint.
int GetTransOffset() const
Offset of this joint's translational DoFs in the flattened DoF array.
int GetSize() const
Total number of DoFs for this joint.
int offset
Offset of this joint's DoFs in the flattened DoF array.
int rotSize
Number of rotational DoFs for this joint.
bool operator==(ArticulatedDofInfo const &) const =default
int GetRotOffset() const
Offset of this joint's rotational DoFs in the flattened DoF array.
Per-joint friction parameters for articulated bodies.
real stictionExtra
[Experimental] Extra stiction force/torque [N or N·m] representing the difference between static and ...
real viscous
Viscous friction coefficient [N·s/m or N·m·s/rad].
real falloffVel
Velocity threshold for dry friction smoothing [m/s or rad/s].
real coulomb
Coulomb friction coefficient [N or N·m].
bool operator==(ArticulatedJointFrictionParams const &) const =default
real stribeckVel
[Experimental] Stribeck velocity [m/s or rad/s] governing how sharply friction transitions from stati...
One ordered element in a spatial tendon's heterogeneous routing list.
bool operator==(RoutingElement const &) const =default
Real3 localPosition
Waypoint only: the waypoint position in the link's local frame (the same frame in which the link's me...
RoutingElementType type
Selects the interpretation of the remaining fields.
int index
Waypoint: the link index the waypoint is attached to. LinearJoint: the joint index.
real coefficient
LinearJoint only: the signed constant moment arm d(displacement)/d(joint DoF) [m / joint DoF]; its si...