Skip to content

Commit a8c433e

Browse files
committed
[#1379] update hingedJointArrayMotor unit test for tracking
1 parent 8c280db commit a8c433e

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/fswAlgorithms/effectorInterfaces/hingedJointArrayMotor/_UnitTest/test_hingedJointArrayMotor.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,21 @@
2424
from Basilisk.architecture import messaging
2525
from Basilisk.fswAlgorithms import hingedJointArrayMotor
2626

27-
def jointTorques(M, K, P, theta, thetaDot, desTheta, desThetaDot, bias, maxTorque=None):
27+
def jointTorques(M, K, P, theta, thetaDot, desTheta, desThetaDot, desThetaDDot, bias, maxTorque=None):
2828
M = np.asarray(M, dtype=float)
2929
K = np.asarray(K, dtype=float)
3030
P = np.asarray(P, dtype=float)
3131
theta = np.asarray(theta, dtype=float).reshape(-1)
3232
thetaDot = np.asarray(thetaDot, dtype=float).reshape(-1)
3333
desTheta = np.asarray(desTheta, dtype=float).reshape(-1)
3434
desThetaDot= np.asarray(desThetaDot, dtype=float).reshape(-1)
35+
desThetaDDot = np.asarray(desThetaDDot, dtype=float).reshape(-1)
3536
bias = np.asarray(bias, dtype=float).reshape(-1)
3637

3738
nj = theta.size
38-
e = theta - desTheta
39+
e = np.arctan2(np.sin(theta - desTheta), np.cos(theta - desTheta))
3940
edot = thetaDot - desThetaDot
40-
theta_ddot_des = -(K @ e) - (P @ edot)
41+
theta_ddot_des = desThetaDDot - (K @ e) - (P @ edot)
4142

4243
Mtt = M[0:3,0:3]
4344
Mtth = M[0:3,6:6+nj]
@@ -151,12 +152,15 @@ def test_hingedJointArrayMotor(nonActForces, maxTorque, numJoints, numSpacecraft
151152
desJointStateInMsgData = messaging.JointArrayStateMsgPayload()
152153
desTheta = [0.12] * (numJoints * numSpacecraft)
153154
desThetaDot = [0.05] * (numJoints * numSpacecraft)
155+
desThetaDDot = [0.002] * (numJoints * numSpacecraft)
154156
desJointStateInMsgData.states.clear()
155157
desJointStateInMsgData.stateDots.clear()
156158
for v in np.asarray(desTheta).flatten():
157159
desJointStateInMsgData.states.push_back(float(v))
158160
for v in np.asarray(desThetaDot).flatten():
159161
desJointStateInMsgData.stateDots.push_back(float(v))
162+
for v in np.asarray(desThetaDDot).flatten():
163+
desJointStateInMsgData.stateDDots.push_back(float(v))
160164

161165
# create the joint reactions input message
162166
JointReactionsInMsgData = messaging.MJJointReactionsMsgPayload()
@@ -252,6 +256,7 @@ def test_hingedJointArrayMotor(nonActForces, maxTorque, numJoints, numSpacecraft
252256
thetaDot_sc = thetaDot[0:numJoints]
253257
desTheta_sc = desTheta[sc*numJoints:(sc+1)*numJoints]
254258
desThetaDot_sc = desThetaDot[sc*numJoints:(sc+1)*numJoints]
259+
desThetaDDot_sc = desThetaDDot[sc*numJoints:(sc+1)*numJoints]
255260
bias_sc = -reactionForces[startIdx:startIdx+6+numJoints]
256261

257262
if maxTorque:
@@ -260,7 +265,8 @@ def test_hingedJointArrayMotor(nonActForces, maxTorque, numJoints, numSpacecraft
260265
uMax_sc = None
261266

262267
torques_sc = jointTorques(M_sc, K_sc, P_sc, theta_sc, thetaDot_sc,
263-
desTheta_sc, desThetaDot_sc, bias_sc, maxTorque=uMax_sc)
268+
desTheta_sc, desThetaDot_sc, desThetaDDot_sc,
269+
bias_sc, maxTorque=uMax_sc)
264270
expectedTorques[sc*numJoints:(sc+1)*numJoints] = torques_sc
265271

266272
# Assert the motor torques are correct

0 commit comments

Comments
 (0)