Skip to content

Commit 025bf19

Browse files
authored
Implemented the QA suggestions
1 parent 0f5372e commit 025bf19

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

constants_1U.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,37 @@
9696
v_S5 = np.array([0,0,1])
9797
v_S6 = np.array([0,0,-1])
9898

99+
m_normalVectors = np.zeros([6,3]) #matrix of normal vectors of sensors
100+
#S1 and S2 are opposite, S3 and S4 are opposite, S5 and S6 are opposite
101+
m_normalVectors[0,:] = v_S1
102+
m_normalVectors[1,:] = v_S2
103+
m_normalVectors[2,:] = v_S3
104+
m_normalVectors[3,:] = v_S4
105+
m_normalVectors[4,:] = v_S5
106+
m_normalVectors[5,:] = v_S6
107+
99108
SS_GAIN = 1
100109
SS_QUANTIZER = 3
101110
SS_THRESHOLD = 0.5
111+
u=1/(SS_QUANTIZER-1) #quantizier means no. of discrete values between 0 and 1 and u represents the resolution of ADC
102112

103113
ADC_BIAS = np.array([0,0,0,0,0,0])
104-
ADC_COV = 0.01*np.identity(6)
114+
ADC_COV = 0.01*np.identity(6)
105115

106116
#GPS (random values)
107117
GPS_POS_BIAS = np.array([0,0,0])
108118
GPS_VEL_BIAS = np.array([0,0,0])
109119
GPS_TIME_BIAS = np.array([0])
110-
GPS_POS_COV = np.identity(3)
111-
GPS_VEL_COV = np.identity(3)
120+
GPS_POS_COV = np.identity(3)
121+
GPS_VEL_COV = np.identity(3)
112122
GPS_TIME_COV = np.array([[0]])
113123

114124
#Magnetometer (random values)
115125
MAG_BIAS = np.array([0,0,0])
116-
MAG_COV = 1e-9*np.identity(3)
126+
MAG_COV = 1e-9*np.identity(3)
117127

118128
#Gyroscope (random values)
119129
GYRO_F_BIAS = np.array([0,0,0])
120-
GYRO_F_COV = 1e-9*np.identity(3)
130+
GYRO_F_COV = 1e-9*np.identity(3)
121131

122132
k_detumbling = 4*np.pi*(1+sin(radians(Inclination-11)))*Jmin/TimePeriod #gain constant in B_dot controller (from book by F. Landis Markley)

qnv.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def quatMultiplyUnnorm(v_q1,v_q2): #returns quaternion product (product is not a
3636
v_q = np.hstack((v_b,a))
3737
return v_q
3838

39-
def quatRotate(v_q,v_x): #rotates vector x by quaternion q
40-
39+
def quatRotate(v_q,v_x):
40+
#Transforms components of vector x in frame A to components in frame B if the input quaternion is q_BA
4141
if np.count_nonzero(v_x) == 0:
4242
return v_x
4343
v_qi = quatInv(v_q)

sensor.py

+2-14
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,6 @@ def ADC(sun_vector):
99
#input: sun vector in body frame, normal vectors of each sunsensor, sunsensor gain, quantizer
1010
#sunsensor gain : multiplying factor that converts dot product of sunvector with normal to voltage
1111
#output : 6 voltages, 1 per sunsensor
12-
13-
u=1/(SS_QUANTIZER-1) #quantizier means no. of discrete values between 0 and 1 and u represents the resolution of ADC
14-
15-
m_normalVectors = np.zeros([6,3]) #matrix of normal vectors of sensors
16-
#S1 and S2 are opposite, S3 and S4 are opposite, S5 and S6 are opposite
17-
m_normalVectors[0,:] = v_S1
18-
m_normalVectors[1,:] = v_S2
19-
m_normalVectors[2,:] = v_S3
20-
m_normalVectors[3,:] = v_S4
21-
m_normalVectors[4,:] = v_S5
22-
m_normalVectors[5,:] = v_S6
2312

2413
v_output = np.zeros([6]) #vector of output of each sensor
2514

@@ -73,8 +62,7 @@ def calc_SV(ss):
7362
if ss[m]>=ss[m+1]:
7463
v_sun_m[n]=1.0*ss[m]
7564
else:
76-
v_sun_m[n]=-1.0*ss[m+1]
77-
65+
v_sun_m[n]=-1.0*ss[m+1]
7866
return v_sun_m/np.linalg.norm(v_sun_m) #gives the unit sun vector to be used in quest.
7967

8068

@@ -103,7 +91,7 @@ def GPS(sat):
10391
v_pos_m = v_pos + np.random.multivariate_normal(GPS_POS_BIAS,GPS_POS_COV)
10492
v_vel_m = v_vel + np.random.multivariate_normal(GPS_VEL_BIAS,GPS_VEL_COV)
10593
time_m = time + np.random.multivariate_normal(GPS_TIME_BIAS,GPS_TIME_COV)
106-
94+
10795
return np.hstack([v_pos_m,v_vel_m,time_m])
10896

10997
def magnetometer(sat):

test_sensor.py

+5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
import sensor
1010
import frames as fs
1111

12+
13+
1214
#Before running these test cases multiply covariance with 0 in constants_1U.py
15+
16+
17+
1318
@ddt
1419
class TestSensor(unittest.TestCase):
1520

0 commit comments

Comments
 (0)