Ejemplo n.º 1
0
    def test_appr_actTypeB(self, value):

        torque_req = np.asarray(value[0])
        magfield_b = np.asarray(value[1])
        app_torque_exp = np.asarray(value[2])

        vel = np.array([5, 6, 7])
        pos = np.array([3, 4, 5])

        q_BI = np.array([0.5, -0.5, 0.5, -0.5])
        q_IB = quatInv(q_BI)
        q_BO = qBI2qBO(q_BI, pos, vel)

        magfield_i = quatRotate(q_IB, magfield_b)

        w_BO_b = np.array([8, 6, 7])
        state = np.hstack((q_BO, w_BO_b))
        t0 = 0
        s = sat.Satellite(state, t0)
        s.setVel(vel)
        s.setPos(pos)
        s.setMag_i(magfield_i)
        s.setControl_b(torque_req)

        app_torque = act.actuatorTypeB(s)

        self.assertTrue(np.allclose(app_torque, app_torque_exp))
Ejemplo n.º 2
0
def load_satellites(satellites_data_dicts):
    """ 
	Loads the real satellites objects given a list of dictionnaries containing the parameters needed to
	instanciate the satellites which has to be simulated

	Input : a list of dictionnaries containing the parameters needed to instanciate the satellites which has to be simulated

	"""

    open("verif.txt", 'a').write("\n\n-------\n Satellites dict received : " +
                                 str(satellites_data_dicts))

    satellites_list = []

    for satellite_dict in satellites_data_dicts:

        for key, val in satellite_dict.items():
            if (str(type(val)) == "<class 'list'>"):
                satellite_dict[key] = np.array(val)

        satellite_dict["corps_ref"] = [
            body for body in c_b.CelestialBody.celestial_bodies
            if body.name == satellite_dict["corps_ref"]
        ][0]
        new_satellite = sat.Satellite(**satellite_dict)
        sat.Satellite.satellites.append(new_satellite)
Ejemplo n.º 3
0
	def test_gyroscope(self):
		qBO = np.array([.0,0.,0.,1.])
		v_w_BI_b = np.array([-3.9999, 4.8575, 0])
		v_w_BO_b = v_w_BI_b + qnv.quatRotate(qBO,v_w_IO_o)
		state = np.hstack((qBO,v_w_BO_b))
		sat = satellite.Satellite(state,12.05)
		sat.setGyroVarBias(np.array((-0.1, 0.1, 0.1)))
		self.assertTrue(np.allclose(sensor.gyroscope(sat),np.array((-4.0999,4.9575,0.1))))
Ejemplo n.º 4
0
	def test_J2_propagator(self):
		qBO = np.array([.0,0.,0.,1.])
		state = np.hstack((qBO,np.array([-0.1,0.39159385,-0.7])))
		sat = satellite.Satellite(state,12.05)
		sat.setPos(np.array([7070e3,0.,0.])) 
		sat.setVel(np.array([5.60,-5.0,0.0]))
		v_expected = np.array([7070e3,0.,0.,5.60,-5.0,0.0,12.05])
		self.assertTrue(np.allclose(defblock.J2_propagator(sat),v_expected))
Ejemplo n.º 5
0
 def test_zero_torque_ideal_q(self):
     mySat = satellite.Satellite(
         np.array([1.0, 0., 0., 0., -0.1, 0.39, -0.7]), 12.05)
     mySat.setPos(np.array([1e6, 53e5, 0.]))
     mySat.setVel(np.array([5.60, -5.0, 0.0]))
     mySat.setDisturbance_b(np.array([0., 0., 0.]))
     mySat.setControl_b(np.array([0., 0., 0.]))
     result = x_dot_BI(mySat, 12.06, mySat.getState())
     self.assertTrue(np.allclose(2. * result[0:4], [0., -0.1, 0.39, -0.7]))
Ejemplo n.º 6
0
def createTrspFile(path):
    # First of all load the trsp
    print("Loading trsp")
    trsps = json.load(
        open(DATA["scripts_update_cache_dir"] +
             DATA["scripts_update_trsp_file"]))

    print("Getting category numbers")
    trspcat = set()
    for trsp in trsps:
        trspcat.add(trsp['norad_cat_id'])

    print("Filling satellite data")
    satellites = []
    numSats = 0
    for file in DATA["scripts_update_files"]:
        print("Extracting satellites from %s" % file)
        f = open(DATA["scripts_update_cache_dir"] + file, 'r')

        if int(DATA["scripts_update_linesneeded"]) == 3:
            numSats = 0
            i = 0
            for line in f:
                if i == 0:  # Name of the sat
                    name = line.rstrip()
                elif i == 1:
                    tle1 = line.rstrip()
                elif i == 2:
                    tle2 = line.rstrip()
                i += 1
                if i == 3:
                    sat = satellite.Satellite(
                        name, file[:-4], tle1, tle2,
                        DATA["scripts_update_baseurl"] + file)
                    if sat.cat in trspcat:
                        for trsp in trsps:
                            if sat.cat == trsp['norad_cat_id']:
                                sat.addTrsp(trsp)
                    satellites.append(sat)
                    i = 0
                    numSats += 1

        print("Extraction successful, imported %d satellites" % numSats)
        f.close()

    print("Collecting data, total %d satellites" % len(satellites))

    def obj_dict(obj):
        return obj.__dict__

    print("Writing content to %s" %
          (path + DATA["scripts_update_result_file"]))
    with open(path + DATA["scripts_update_result_file"], 'w') as outfile:
        json.dump(satellites, outfile, default=obj_dict)

    print("Data was written successfully")
Ejemplo n.º 7
0
	def test_kinematics_explicitly(self):
		qBO = np.array([0.254,-0.508,np.sqrt(1-0.4**2-0.254**2-0.508**2),0.4])
		vel = np.array([5.60,-5.0,0.0])
		state = np.hstack((qBO,np.array([0.10050588,-0.05026119,-0.3014887])))
		mySat = satellite.Satellite(state,128.05)
		mySat.setVel(vel)
		mySat.setDisturbance_b(np.array([10e-10,-4e-6,-3e-5]))
		mySat.setControl_b(np.array([1e-5,1e-5,-8e-4]))
		result = x_dot_BO(mySat)
		self.assertTrue(np.allclose(result,[0.11475622,  0.06438473, -0.04115242, 0.08290271, 0.00632537, 0.00313621, -0.56264705]))
 def test_currentToTorque(self,value):        #converts control torque to voltage wiht help of earth's field
     v_magnetic_field_i= np.asarray(value[1])
     v_state=np.asarray(value[0])
     v_current=np.asarray(value[4]) #first element should be time then next three are currents
     mySat = satellite.Satellite(v_state,1.0)
     
     mySat.setMag_i(v_magnetic_field_i)
     torque = currentToTorque(v_current, mySat)
     result= torque
     self.assertTrue(np.allclose(result,np.asarray(value[5])))
Ejemplo n.º 9
0
 def test_zero_torque_rates_ideal_q(
         self):  #zero torque, zero initial angular velocity, aligned frames
     mySat = satellite.Satellite(np.array([1.0, 0., 0., 0., 0., 0., 0.]),
                                 12.0)
     mySat.setPos(np.array([1e6, 0., 0.]))
     mySat.setVel(np.array([5.0, 5.0, 0.0]))
     mySat.setDisturbance_b(np.array([0., 0., 0.]))
     mySat.setControl_b(np.array([0., 0., 0.]))
     result = x_dot_BI(mySat, 12.0, mySat.getState())
     self.assertTrue(np.allclose(result, [0., 0., 0., 0., 0., 0., 0.]))
Ejemplo n.º 10
0
    def test_inertia_eigenvec(self, value):
        q = np.array([1., 0., 0., 0.])
        mySat = satellite.Satellite(np.hstack((q, value)), 128.05)
        mySat.setPos(np.array([1e6, 53e5, 0.]))
        mySat.setVel(np.array([5.60, -5.0, 0.0]))
        mySat.setDisturbance_b(np.array([0., 0., 0.]))
        mySat.setControl_b(np.array([0., 0., 0.]))
        result = x_dot_BI(mySat, 128.08, mySat.getState())

        self.assertTrue(np.allclose(result[4:7], [0., 0., 0.]))
Ejemplo n.º 11
0
	def test_zero_torque_ideal_q(self):		#zero torque, random initial angular velocity, aligned frames
		qBO = np.array([.0,0.,0.,1.])
		vel = np.array([5.60,-5.0,0.0])
		state = np.hstack((qBO,np.array([-0.1,0.39159385,-0.7])))
		mySat = satellite.Satellite(state,12.05)
		mySat.setVel(vel)
		mySat.setDisturbance_b(np.array([0.,0.,0.]))
		mySat.setControl_b(np.array([0.,0.,0.]))
		result = x_dot_BO(mySat)
		self.assertTrue(np.allclose(result,[-0.05,0.1957969257,-0.35, 0., 0.00453874, -0.00185081, -0.00168015]))
 def test_ctrlTorqueToVoltage(self,value):        #converts control torque to voltage wiht help of earth's field
     v_magnetic_field_i= np.asarray(value[1])
     v_state=np.asarray(value[0])
     v_ctrlTorque=np.asarray(value[2])
     mySat = satellite.Satellite(v_state,1.0)
     
     mySat.setMag_i(v_magnetic_field_i)
     mySat.setControl_b(v_ctrlTorque)
     voltage = ctrlTorqueToVoltage(mySat)
     result= voltage
     self.assertTrue(np.allclose(result, np.asarray(value[3])))
Ejemplo n.º 13
0
	def test_constant(self):
		t0 = 0.0
		mySat = satellite.Satellite(np.array([1.0,0.,0.,0.,0.,0.,0.]),t0)
		t = 10
		mySat.setPos(np.array([1e6,0.,0.]))
		mySat.setVel(np.array([5.0,5.0,0.0]))
		h = 0.1
		for i in range(0,int(t/h)):
			updateStateTimeRK4(mySat,f_constant,h)
			mySat.setTime(t0+(i+1)*h)
		self.assertTrue(np.allclose([10.0,10.0,10.0],mySat.getW_BO_b()))
Ejemplo n.º 14
0
	def test_GPS(self):
		qBO = np.array([.0,0.,0.,1.])
		v_w_BI_b = np.array([-3.9999, 4.8575, 0]) 
		v_w_BO_b = v_w_BI_b + qnv.quatRotate(qBO,v_w_IO_o)
		state = np.hstack((qBO,v_w_BO_b))
		sat = satellite.Satellite(state,3.132)
		v_pos_i = np.array([5000,5000,6000])
		v_vel_i = np.array([7e3,0,0])
		sat.setPos(v_pos_i)
		sat.setVel(v_vel_i)
		result=sensor.GPS(sat)
		self.assertTrue(np.allclose(result,np.array((5000,5000,6000,7e3,0,0,3.132))))
Ejemplo n.º 15
0
	def test_dynamics(self,value):
		t0 = 0.
		h = value
		
		v_q_BO = np.array([0.4,0.254,-0.508,0.71931912])
		
		v_w_BO_b = frames.wBIb2wBOb(np.array([0.1,-0.05,-0.3]),v_q_BO,v_w_IO_o)
		
		mySat1 = satellite.Satellite(np.hstack((v_q_BO, v_w_BO_b)),t0)
		
		mySat1.setPos(np.array([1e6,53e5,0.]))
		mySat1.setVel(np.array([5.60,-5.0,0.0]))
		mySat1.setDisturbance_b(np.array([10e-10,-4e-6,-3e-5]))
		mySat1.setControl_b(np.array([1e-5,1e-5,-8e-4]))
		
		updateStateTimeRK4(mySat1,x_dot_BO,h)
		x1 = mySat1.getState()

		mySat2 = satellite.Satellite(np.hstack((v_q_BO, v_w_BO_b)),t0)
		
		mySat2.setPos(np.array([1e6,53e5,0.]))
		mySat2.setVel(np.array([5.60,-5.0,0.0]))
		mySat2.setDisturbance_b(np.array([10e-10,-4e-6,-3e-5]))
		mySat2.setControl_b(np.array([1e-5,1e-5,-8e-4]))
		
		mySat2.setState(np.hstack((v_q_BO,v_w_BO_b)))		
		k1 = h*x_dot_BO(mySat2)
		mySat2.setState(np.hstack((v_q_BO,v_w_BO_b))+0.5*k1)
		k2 = h*x_dot_BO(mySat2)
		mySat2.setState(np.hstack((v_q_BO,v_w_BO_b))+0.5*(k2))
		k3 = h*x_dot_BO(mySat2)
		mySat2.setState(np.hstack((v_q_BO,v_w_BO_b))+k3)
		k4 = h*x_dot_BO(mySat2)
		
		error_state = np.hstack((v_q_BO,v_w_BO_b)) + (1./6.)*(k1 + 2.*k2 + 2.*k3 + k4)
		if (error_state[3]<0):
			error_state[0:4]=-1*error_state[0:4]
		error_state[0:4]=error_state[0:4]/np.linalg.norm(error_state[0:4])
		self.assertTrue(np.allclose(error_state,x1))
Ejemplo n.º 16
0
 def test_kinematics_explicitly(self):
     state = np.array([
         0.4, 0.254, -0.508,
         np.sqrt(1 - 0.4**2 - 0.254**2 - 0.508**2), 0.1, -0.05, -0.3
     ])
     mySat = satellite.Satellite(state, 128.05)
     mySat.setPos(np.array([1e6, 53e5, 0.]))
     mySat.setVel(np.array([5.60, -5.0, 0.0]))
     mySat.setDisturbance_b(np.array([10e-10, 0., 0.]))
     mySat.setControl_b(np.array([1e-5, 0., 0.]))
     result = x_dot_BI(mySat, 128.08, mySat.getState())
     self.assertTrue(
         np.allclose(result[0:4], [0.082498, 0.114183, 0.064066, -0.04095]))
    def test_magmeter(self, value):
        qBI = np.asarray(value[0])
        v_sv_i = np.asarray(value[1])

        v_pos_i = np.array([1e6, -2.03, -3.0])
        v_vel_i = np.array([2.0e3, 2.8, -73.2])
        qBO = frames.qBI2qBO(qBI, v_pos_i, v_vel_i)
        state = np.hstack((qBO, np.zeros(3)))
        mySat = satellite.Satellite(state, 12.0)
        mySat.setQ_BI(qBI)
        result = defblock.magmeter(mySat, v_sv_i)
        v_expected = value[2], value[3]
        self.assertTrue(np.allclose(result, v_expected))
Ejemplo n.º 18
0
	def test_magnetometer(self):
		qBO = np.array([.0,0.,0.,1.])
		v_w_BI_b = np.array([-3.9999, 4.8575, 0]) 
		v_w_BO_b = v_w_BI_b + qnv.quatRotate(qBO,v_w_IO_o)
		state = np.hstack((qBO,v_w_BO_b))
		sat = satellite.Satellite(state,12.05)
		v_pos_i = np.array([1e6,-2.03,-3.0])
		v_vel_i = np.array([2.0e3,2.8,-73.2])
		sat.setPos(v_pos_i)
		sat.setVel(v_vel_i)
		qOI = np.array([-0.70697614, -0.01353643,  0.70697824,  0.01353791])
		Magi = qnv.quatRotate(qnv.quatInv(qOI),np.array((2.3e-6,3.4e-6,3.1e-6)))
		sat.setMag_i(Magi) 
		self.assertTrue(np.allclose(sensor.magnetometer(sat),np.array((2.3e-6,3.4e-6,3.1e-6))))
Ejemplo n.º 19
0
    def test_ramp1(self):
        t0 = 0.
        mySat = satellite.Satellite(np.array([1.0, 0., 0., 0., 0., 0., 0.]),
                                    t0)
        t = 10
        h = 0.1
        for i in range(0, int(t / h)):
            x1 = rk4(mySat, f_ramp, h)
            mySat.setState(x1.copy())
            mySat.setTime(t0 + (i + 1) * h)

        self.assertTrue(
            np.allclose([51.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0],
                        mySat.getState()))
    def test_Bdot(self, value):

        mag1 = np.asarray(value[0])
        mag2 = np.asarray(value[1])
        mag_exp = np.asarray(value[2])

        iniState = np.array([1., 0., 0., 0., 0., 0., 0.])
        s = sat.Satellite(iniState, 0)
        s.setMag_b_m_p(mag1)
        s.setMag_b_m_c(mag2)
        detcon.cons.k = 0.004252756437794863
        magMoment = detcon.magMoment(s)
        #print magMoment
        self.assertTrue(np.allclose(magMoment, mag_exp))
	def test_dynamics(self):
		t0 = 0.
		h = 0.001
		
		v_q_BO = np.array([0.4,0.254,-0.508,0.71931912])		
		v_w_BO_b = frames.wBIb2wBOb(np.array([0.1,-0.05,-0.3]),v_q_BO,v_w_IO_o)
		
		mySat1 = satellite.Satellite(np.hstack((v_q_BO, v_w_BO_b)),t0)
		
		mySat1.setPos(np.array([1e6,53e5,0.]))
		mySat1.setVel(np.array([5.60,-5.0,0.0]))
		mySat1.setDisturbance_b(np.array([10e-10,-4e-6,-3e-5]))
		mySat1.setControl_b(np.array([1e-5,1e-5,-8e-4]))
		
		rk4Quaternion(mySat1,x_dot_BO,h)
		x1 = mySat1.getState()

		mySat2 = satellite.Satellite(np.hstack((v_q_BO, v_w_BO_b)),t0)
		
		mySat2.setPos(np.array([1e6,53e5,0.]))
		mySat2.setVel(np.array([5.60,-5.0,0.0]))
		mySat2.setDisturbance_b(np.array([10e-10,-4e-6,-3e-5]))
		mySat2.setControl_b(np.array([1e-5,1e-5,-8e-4]))
		
		mySat2.setState(np.hstack((v_q_BO,v_w_BO_b)))		
		k1 = h*x_dot_BO(mySat2)
		mySat2.setState(np.hstack((v_q_BO,v_w_BO_b))+0.5*k1)
		k2 = h*x_dot_BO(mySat2)
		mySat2.setState(np.hstack((v_q_BO,v_w_BO_b))+0.5*(k2+k1))
		k3 = h*x_dot_BO(mySat2)
		mySat2.setState(np.hstack((v_q_BO,v_w_BO_b))+k3+0.5*(k2+k1))
		k4 = h*x_dot_BO(mySat2)
		
		error_state = np.hstack((v_q_BO,v_w_BO_b)) + (1./6.)*(k1 + 2.*k2 + 2.*k3 + k4)
		print(error_state)
		self.assertTrue(np.allclose(error_state,x1))
Ejemplo n.º 22
0
	def test_magmeter(self,value): 
		qBI = np.asarray(value[0])
		v_B_i=np.asarray(value[1])
		v_pos_i = np.array([1e6,-2.03,-3.0])
		v_vel_i = np.array([2.0e3,2.8,-73.2])
		qBO = frames.qBI2qBO(qBI,v_pos_i,v_vel_i)
		state = np.hstack((qBO,np.zeros(3)))
		mySat = satellite.Satellite(state,12.0)
		mySat.setMag_i(v_B_i)
		mySat.setPos(v_pos_i)
		mySat.setVel(v_vel_i)
		qOI = qnv.quatMultiplyNorm(qnv.quatInv(qBO),qBI)
		result = defblock.magnetometer(mySat)
		v_expected = value[2];
		self.assertTrue(np.allclose(result,v_expected))
Ejemplo n.º 23
0
    def test_ramp2(self):
        t0 = 0.
        mySat = satellite.Satellite(
            np.array([0.5, 0.5, -0.5, -0.5, 1.6, -2.5, 0.3]), t0)
        t = 10.
        h = 0.1

        for i in range(0, int(t / h)):
            x1 = rk4(mySat, f_ramp, h)
            mySat.setState(x1.copy())
            mySat.setTime(t0 + (i + 1) * h)

        self.assertTrue(
            np.allclose([50.5, 50.5, 49.5, 49.5, 51.6, 47.5, 50.3],
                        mySat.getState()))
Ejemplo n.º 24
0
    def test_tx(self):
        t0 = 0.
        mySat = satellite.Satellite(
            np.array([0.5, 0.5, -0.5, -0.5, 1.6, -2.5, 0.3]), t0)
        t = 3.
        h = 0.001

        for i in range(0, int(t / h)):
            x1 = rk4(mySat, f_tx, h)
            mySat.setState(x1.copy())
            mySat.setTime(t0 + (i + 1) * h)

        expected = np.exp(-t**2 / 2.) * np.array(
            [0.5, 0.5, -0.5, -0.5, 1.6, -2.5, 0.3])

        self.assertTrue(np.allclose(expected, mySat.getState()))
Ejemplo n.º 25
0
	def test_sunsensor(self):
		qBO = np.array([.0,0.,0.,1.])
		v_w_BI_b = np.array([-3.9999, 4.8575, 0]) 
		v_w_BO_b = v_w_BI_b + qnv.quatRotate(qBO,v_w_IO_o)
		state = np.hstack((qBO,v_w_BO_b))
		sat = satellite.Satellite(state,12.05)
		v_pos_i = np.array([1e6,-2.03,-3.0])
		v_vel_i = np.array([2.0e3,2.8,-73.2])
		sat.setPos(v_pos_i)
		sat.setVel(v_vel_i)
		qOI = np.array([-0.70697614, -0.01353643,  0.70697824,  0.01353791])
		Suni = qnv.quatRotate(qnv.quatInv(qOI),np.array((3,4,5)))
		sat.setSun_i(Suni) 
		result = sensor.sunsensor(sat)
		expected = np.array((3/(50**(0.5)),4/(50**(0.5)),5/(50**(0.5))))
		self.assertTrue(np.allclose(result,expected))
Ejemplo n.º 26
0
 def test_zero_torque_ideal_q(
         self
 ):  #zero torque, random initial angular velocity, aligned frames
     qBO = np.array([1.0, 0., 0., 0.])
     pos = np.array([1e6, 53e5, 0.])
     vel = np.array([5.60, -5.0, 0.0])
     state = np.hstack((qBO, np.array([-0.1, 0.39159385, -0.7])))
     mySat = satellite.Satellite(state, 12.05)
     mySat.setPos(pos)
     mySat.setVel(vel)
     mySat.setDisturbance_b(np.array([0., 0., 0.]))
     mySat.setControl_b(np.array([0., 0., 0.]))
     result = x_dot_BO(mySat, 12.06, mySat.getState())
     self.assertTrue(
         np.allclose(result, [
             0., -0.05, 0.1957969257, -0.35, 0.00490396, -0.00185206,
             -0.00173161
         ]))
Ejemplo n.º 27
0
    def test_dynamics(self):
        t0 = 0.
        h = 0.001

        v_q_BO = np.array([0.4, 0.254, -0.508, 0.71931912])
        v_q_BI = frames.qBO2qBI(v_q_BO, np.array([1e6, 53e5, 0.]),
                                np.array([5.60, -5.0, 0.0]))
        mySat = satellite.Satellite(
            np.hstack((v_q_BI, np.array([0.1, -0.05, -0.3]))), t0)

        mySat.setPos(np.array([1e6, 53e5, 0.]))
        mySat.setVel(np.array([5.60, -5.0, 0.0]))
        mySat.setDisturbance_b(np.array([10e-10, -4e-6, -3e-5]))
        mySat.setControl_b(np.array([1e-5, 1e-5, -8e-4]))

        r = np.linalg.norm(mySat.getPos())
        v_w_IO_o = np.array([
            0., np.sqrt(G * M_EARTH / (r)**3), 0.
        ])  #angular velocity of orbit frame wrt inertial frame in orbit frame

        v_w_BO_b = frames.wBIb2wBOb(np.array([0.1, -0.05, -0.3]), v_q_BO,
                                    v_w_IO_o)

        x1 = rk4Quaternion(mySat, x_dot_BO, h)
        mySat.setState(x1.copy())
        mySat.setTime(t0 + h)

        k1 = h * x_dot_BO(mySat, t0 + 0.5 * h, np.hstack((v_q_BO, v_w_BO_b)))
        k2 = h * x_dot_BO(mySat, t0 + 0.5 * h,
                          np.hstack((v_q_BO, v_w_BO_b)) + 0.5 * k1)
        k3 = h * x_dot_BO(mySat, t0 + 0.5 * h,
                          np.hstack((v_q_BO, v_w_BO_b)) + 0.5 * k2)
        k4 = h * x_dot_BO(mySat, t0 + h, np.hstack((v_q_BO, v_w_BO_b)) + k3)

        error_state = np.hstack(
            (v_q_BO, v_w_BO_b)) + (1. / 6.) * (k1 + 2. * k2 + 2. * k3 + k4)
        expected = np.hstack((frames.qBO2qBI(error_state[0:4],
                                             np.array([1e6, 53e5, 0.]),
                                             np.array([5.60, -5.0, 0.0])),
                              frames.wBOb2wBIb(error_state[4:7],
                                               error_state[0:4], v_w_IO_o)))
        self.assertTrue(np.allclose(expected, mySat.getState()))
Ejemplo n.º 28
0
 def test_kinematics_explicitly(self):
     qBO = np.array(
         [0.4, 0.254, -0.508,
          np.sqrt(1 - 0.4**2 - 0.254**2 - 0.508**2)])
     pos = np.array([1e6, 53e5, 0.])
     vel = np.array([5.60, -5.0, 0.0])
     state = np.hstack((qBO, np.array([0.10050588, -0.05026119,
                                       -0.3014887])))
     mySat = satellite.Satellite(state, 128.05)
     mySat.setPos(pos)
     mySat.setVel(vel)
     mySat.setDisturbance_b(np.array([10e-10, -4e-6, -3e-5]))
     mySat.setControl_b(np.array([1e-5, 1e-5, -8e-4]))
     result = x_dot_BO(mySat, 128.08, mySat.getState())
     print(result)
     self.assertTrue(
         np.allclose(result, [
             0.08290271, 0.11475622, 0.06438473, -0.04115242, 0.00627683,
             0.00299226, -0.56264081
         ]))
Ejemplo n.º 29
0
	def test_zero_torque_rates_ideal_q(self):	#zero torque, zero initial wBIB, aligned frames
		'''
		For this test case set (from sixth model of Advitiy) and ALTITUDE = 700 km
		Ixx = 0.00152529
		Iyy = 0.00145111
		Izz = 0.001476
		Ixy = 0.00000437
		Iyz = - 0.00000408
		Ixz = 0.00000118
		'''
		qBO = np.array([0.0,0.,0.0,1.])
		vel = np.array([5.0,5.0,0.0])
		v_w_BI_b = np.array([0.,0.,0.])
		v_w_BO_b = frames.wBIb2wBOb(v_w_BI_b,qBO,v_w_IO_o)
		state = np.hstack((qBO,v_w_BO_b))
		mySat = satellite.Satellite(state,12.0)
		mySat.setVel(vel)
		mySat.setDisturbance_b(np.array([0.,0.,0.]))
		mySat.setControl_b(np.array([0.,0.,0.]))
		result = x_dot_BO(mySat)
		self.assertTrue(np.allclose(result,[0.,0.00053089,0.,0.,0.,0.,0.]))
Ejemplo n.º 30
0
    def save(self):

        # capture every entry made by the user
        name = self.nameBox.get()
        upFreq = self.upFreqBox.get()
        downFreq = self.downFreqBox.get()
        owner = self.boxOwner.get()
        modulation = self.boxModulation.get()

        #verify if all the information is here
        if name == "" or upFreq == 0 or downFreq == 0 or owner == "" or modulation == "":

            self.errortext.set("all fields must be filled!")

        else:

            try:
                if float(upFreq) > 500 or float(upFreq) < 100 or float(
                        downFreq) > 500 or float(downFreq) < 100:
                    self.errortext.set("Frequencies not in range")
                else:
                    #saves the satellite in the database
                    sat = satellite.Satellite(name=name,
                                              upFreq=upFreq,
                                              downFreq=downFreq,
                                              upBand="UHF",
                                              downBand="VHF",
                                              owner=owner,
                                              modulation=modulation)
                    sat.saveInDB()
                    #save the TLE in predict TLE
                    TLEDB = open("/home/simon/.predict/predict.tle", 'a')
                    newTLE = '\n' + name + "\n" + self.boxTLE.get(
                    ) + "\n" + self.boxTLE2.get()
                    TLEDB.write(newTLE)
                    # quit the window without closing the program
                    self.master.destroy()
            except ValueError:
                self.errortext.set("frequencies should be numbers")