@@ -149,85 +149,41 @@ function body_constraint_jacobian_joint_data(mechanism::Mechanism{T}, body::Body
149
149
return [∇u ∇spring ∇damper]
150
150
end
151
151
152
- # function body_constraint_jacobian_contact_data(mechanism::Mechanism, body::Body{T},
153
- # contact::ContactConstraint{T,N,Nc,Cs,N½}) where {T,N,Nc,Cs<:NonlinearContact{T,N},N½}
154
- # Nd = data_dim(contact)
155
- # model = contact.model
156
- # contact_radius = model.collision.contact_radius
157
- # offset = model.collision.contact_normal' * contact_radius
158
- # xp3, qp3 = next_configuration(get_body(mechanism, contact.parent_id).state, mechanism.timestep)
159
- # xc3, qc3 = next_configuration(get_body(mechanism, contact.child_id).state, mechanism.timestep)
160
-
161
- # γ = contact.impulses[2]
162
-
163
- # ∇friction_coefficient = szeros(T,3,1)
164
-
165
- # X = force_mapping(:parent, model, xp3, qp3, xc3, qc3)
166
- # ∇p = - ∂skew∂p(VRmat(qp3) * LᵀVᵀmat(qp3) * X * γ)
167
- # ∇contact_radius = - ∂skew∂p(VRmat(qp3) * LᵀVᵀmat(qp3) * X * γ) * -rotation_matrix(inv(qp3)) * model.collision.contact_normal'
168
-
169
- # ∇X = szeros(T,3,Nd)
170
- # ∇Q = -[∇friction_coefficient ∇contact_radius ∇p]
171
- # return [∇X; ∇Q]
172
- # end
173
-
174
- function body_constraint_jacobian_contact_data (mechanism:: Mechanism , body:: Body{T} , contact:: ContactConstraint{T,N,Nc,Cs,N½} ) where {T,N,Nc,Cs<: NonlinearContact{T,N} ,N½}
175
- Nd = Dojo. data_dim (contact)
152
+ function body_constraint_jacobian_contact_data (mechanism:: Mechanism , body:: Body{T} ,
153
+ contact:: ContactConstraint{T,N,Nc,Cs,N½} ) where {T,N,Nc,Cs<: NonlinearContact{T,N} ,N½}
154
+ Nd = data_dim (contact)
176
155
model = contact. model
177
- xp3, qp3 = Dojo . next_configuration (get_body (mechanism, contact. parent_id). state, mechanism. timestep)
178
- xc3, qc3 = Dojo . next_configuration (get_body (mechanism, contact. child_id). state, mechanism. timestep)
156
+ xp3, qp3 = next_configuration (get_body (mechanism, contact. parent_id). state, mechanism. timestep)
157
+ xc3, qc3 = next_configuration (get_body (mechanism, contact. child_id). state, mechanism. timestep)
179
158
180
159
γ = contact. impulses[2 ]
181
160
182
161
∇friction_coefficient = szeros (T,3 ,1 )
183
162
184
- X = Dojo. force_mapping (:parent , model, xp3, qp3, xc3, qc3)
185
- ∇p = - Dojo.∂skew∂p (Dojo. VRmat (qp3) * Dojo. LᵀVᵀmat (qp3) * X * γ)
186
-
163
+ X = force_mapping (:parent , model, xp3, qp3, xc3, qc3)
164
+ ∇p = - ∂skew∂p (VRmat (qp3) * LᵀVᵀmat (qp3) * X * γ)
187
165
cn = contact_normal (model. collision, xp3, qp3, xc3, qc3)
188
- ∇contact_radius = - Dojo. ∂skew∂p (Dojo . VRmat (qp3) * Dojo . LᵀVᵀmat (qp3) * X * γ) * - Dojo . rotation_matrix (inv (qp3)) * cn'
166
+ ∇contact_radius = - ∂skew∂p (VRmat (qp3) * LᵀVᵀmat (qp3) * X * γ) * - rotation_matrix (inv (qp3)) * cn'
189
167
190
168
∇X = szeros (T,3 ,Nd)
191
169
∇Q = - [∇friction_coefficient ∇contact_radius ∇p]
192
170
return [∇X; ∇Q]
193
171
end
194
172
195
- # function contact_constraint_jacobian_contact_data(mechanism::Mechanism, contact::ContactConstraint{T,N,Nc,Cs,N½}, body::Body{T}) where {T,N,Nc,Cs<:NonlinearContact{T,N},N½}
196
- # Nd = data_dim(contact)
197
- # model = contact.model
198
-
199
- # xp3, vp25, qp3, ωp25 = next_configuration_velocity(get_body(mechanism, contact.parent_id).state, mechanism.timestep)
200
- # xc3, vc25, qc3, ωc25 = next_configuration_velocity(get_body(mechanism, contact.child_id).state, mechanism.timestep)
201
-
202
- # s = contact.impulses_dual[2]
203
- # γ = contact.impulses[2]
204
-
205
- # ∇friction_coefficient = SA[0,γ[1],0,0]
206
- # ∇contact_radius = [-model.collision.contact_normal; szeros(T,1,3); -model.collision.contact_tangent * skew(vector_rotate(ωp25, qp3))] * model.collision.contact_normal'
207
- # ∇p = [model.collision.contact_normal * rotation_matrix(qp3); szeros(T,1,3); model.collision.contact_tangent * skew(vector_rotate(ωp25, qp3)) * rotation_matrix(qp3)]
208
-
209
- # ∇compμ = szeros(T,N½,Nd)
210
- # ∇g = -[∇friction_coefficient ∇contact_radius ∇p]
211
-
212
- # return [∇compμ; ∇g]
213
- # end
214
-
215
173
function contact_constraint_jacobian_contact_data (mechanism:: Mechanism , contact:: ContactConstraint{T,N,Nc,Cs,N½} , body:: Body{T} ) where {T,N,Nc,Cs<: NonlinearContact{T,N} ,N½}
216
- Nd = Dojo . data_dim (contact)
174
+ Nd = data_dim (contact)
217
175
model = contact. model
176
+ xp3, vp25, qp3, ωp25 = next_configuration_velocity (get_body (mechanism, contact. parent_id). state, mechanism. timestep)
177
+ xc3, vc25, qc3, ωc25 = next_configuration_velocity (get_body (mechanism, contact. child_id). state, mechanism. timestep)
218
178
219
- xp3, vp25, qp3, ωp25 = Dojo. next_configuration_velocity (get_body (mechanism, contact. parent_id). state, mechanism. timestep)
220
- xc3, vc25, qc3, ωc25 = Dojo. next_configuration_velocity (get_body (mechanism, contact. child_id). state, mechanism. timestep)
221
-
222
- cn = contact_normal (model. collision, xp3, qp3, xc3, qc3)
223
- ct = contact_tangent (model. collision, xp3, qp3, xc3, qc3)
224
-
225
- s = contact. impulses_dual[2 ]
226
179
γ = contact. impulses[2 ]
227
180
228
181
∇friction_coefficient = SA[0 ,γ[1 ],0 ,0 ]
229
- ∇contact_radius = [- cn; szeros (T,1 ,3 ); - ct * Dojo. skew (Dojo. vector_rotate (ωp25, qp3))] * cn'
230
- ∇p = [cn * Dojo. rotation_matrix (qp3); szeros (T,1 ,3 ); ct * Dojo. skew (Dojo. vector_rotate (ωp25, qp3)) * Dojo. rotation_matrix (qp3)]
182
+
183
+ cn = contact_normal (model. collision, xp3, qp3, xc3, qc3)
184
+ ct = contact_tangent (model. collision, xp3, qp3, xc3, qc3)
185
+ ∇contact_radius = [- cn; szeros (T,1 ,3 ); - ct * skew (vector_rotate (ωp25, qp3))] * cn'
186
+ ∇p = [cn * rotation_matrix (qp3); szeros (T,1 ,3 ); ct * skew (vector_rotate (ωp25, qp3)) * rotation_matrix (qp3)]
231
187
232
188
∇compμ = szeros (T,N½,Nd)
233
189
∇g = - [∇friction_coefficient ∇contact_radius ∇p]
0 commit comments