Design of Attitude Control System of a Double CubeSat Gaute Bråthen Master of Science in Engineering Cybernetics Submission date: Januar 2013 Supervisor: Jan Tommy Gravdahl, ITK Norwegian University of Science and Technology Department of Engineering Cybernetics Design of Attitude Control System of a Double CubeSat Master thesis by Gaute Bråthen Supervisor: Prof. J.T. Gravdahl Co-supervisor: Roger Birkeland, NTNU IET Norwegian University of Science and Technology, Institute of Engineering Cybernetics Trondheim, January 25, 2013 NTNU Norges teknisk-naturvitenskapelige universitet Fakultet for informasjonsteknologi, matematikk og elektroteknikk Institutt for teknisk kybernetikk MSc thesis assignment 0B Name of the candidate: Subject: Gaute Bråthen Engineering Cybernetics Title: Attitude control for the Norwegian student satellite NUTS Background 1B The NUTS (NTNU Test Satellite) project was started in September 2010. The project is part of the Norwegian student satellite program run by NAROM (Norwegian Centre for Space-related Education). The projects goal is to design, manufacture and launch a double CubeSat by 2014. Assignment: 1) Evaluate different methods for numerical differentiation in order to find the time derivative of the measured magnetic field, ̇ . Implement the chosen method on the microcontroller. 2) Simulate detumbling of the spacecraft using feedback from ̇ . Add noise to the measurements. The noise should be consistent with what you measure using the real magnetometer. Use the IGRF-model in the simulations. Compare the results with the detumbling done in the thesis by Z.Tudor (2011) 3) Investigate if ̇ -detumbling is able to bring the angular velocity of the spacecraft to such low levels that LQ-control can be employed for attitude control. 4) Conclude on what detumble and attitude control algorithms to use on the real spacecraft 5) Design and specify the torque coils to be used on the spacecraft with respect to number of windings, resistance and physical size. To be handed in by: Trondheim, Jan Tommy Gravdahl Professor, supervisor Abstract The NTNU Test Satellite, NUTS, is a satellite being build in a student CubeSat project at the Norwegian University of Science and Technology. The project was started in September 2010 as a part of the Norwegian student satellite program run by NAROM (Norwegian Centre for Space-related Education). The NUTS project goals are to design, manufacture and launch a double CubeSat by 2014. As payload an IR-camera observing waves in the air-glow layer is planned, as well as a short-range RF experiment. The satellite will fly two transceivers in the amateur radio bands. Final year master students from several departments are the main contributors in the project and most of the system components are designed and built by students. As the main payload is an IR-camera and one of the main goals once in orbit is to take pictures of the gravity waves in the atmosphere, a reliable Attitude Determination and Control System (ADCS) is important. In order to take reliable pictures, an absolute requirement is that the camera does not miss the Earth, and more accurately be able to point towards the Earth in such a matter that unwanted disturbances, such as stars and other light sources in space, is not in the camera’s field of view. In this thesis, a realistic simulation environment have been created in order to assess and design an Attitude Control System (ACS) to be implemented on the satellite. Magnetorquers as the satellite’s actuators have been designed. Further, a detumbling control algorithm using an estimated derivative of the geomagnetic field measured with a magnetometer, is shown to be working satisfactory, even when being subjected to heavy environmental disturbances. Linear and nonlinear reference control algorithms subjected to realistic disturbances in the space environment have been tested and compared as well. Comparisons between a proportional derivative (PD) controller and a linear quadratic regulator (LQR) are presented, and the nonlinear controller proved to give best results and pointing control good to take pictures of the Earth atmposphere is achieved. v Sammendrag Norges teknisk- naturvitenskapelige universitet (NTNU) startet høsten 2010 studentsatellittprosjektet NTNU Test Satellite, NUTS. Prosjektet er en del av det nasjonale ANSAT-programmet styrt av NAROM (Nasjonalt senter for romrelatert opplæring) og Norsk romsenter, som andre norske høyskoler og universiteter også er en del av. Målene til NUTS-prosjektet er å designe, bygge og sende opp en dobbel CubeSat i 2014. Hoved payload’en er et infrarødt kamer som skal ta bilde av jordas amtosfære, og en annen payload er et trådløs databus-eksperiment. Satellitten vil ha to radiobånd for kontakt med bakken. Masterstudenter fra mange forskjellige disipliner er med på prosjektet. Siden hovedpayload’en er et IR-kamer, å få satellitten til å peke mot jorda er viktig, og et robust attitude kontrollsystem er å foretrekke. Det er vist i denne rapporten at man kan detumble stelliten ved bruk av estimering av derivatet av en måling av det lokale geomagnetiske felt, også når store forstyrrelse er tilstede. Sammenligninger mellom en ulineær og en lineær kontroller har blitt gjort, der den ullineære ser ut til å gi best resultater. Peking av satellitten mot jorda for å ta bilder av dens atmosfære ser ut til å være oppnådd. vii Contents Abstract v Sammendrag vii List of Figures xii List of Tables xiv 1 2 Introduction 1 1.1 The NUTS - NTNU Test Satellite project . . . . . . . . . . . . . 1 1.2 Small satellites . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 Small satellite magnetic attitude control systems overview . . . . 2 1.4 Previous work . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.5 Thesis outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Theory 6 2.1 Coordinate frames . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.1.1 Earth centered inertial frame . . . . . . . . . . . . . . . . 7 2.1.2 Earth centered Earth fixed frame . . . . . . . . . . . . . . 7 2.1.3 Orbit fixed frame . . . . . . . . . . . . . . . . . . . . . . 7 2.1.4 Body fixed frame . . . . . . . . . . . . . . . . . . . . . . 7 ix 3 2.2 The Rotation Matrix . . . . . . . . . . . . . . . . . . . . . . . . 8 2.3 Attitude representation . . . . . . . . . . . . . . . . . . . . . . . 10 2.3.1 Euler angles and roll-pitch-yaw . . . . . . . . . . . . . . 10 2.3.2 Euler parameters and Quaternions . . . . . . . . . . . . . 11 2.4 Frame transformations . . . . . . . . . . . . . . . . . . . . . . . 12 2.5 The inertia matrix . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.6 Magnetometer measurements . . . . . . . . . . . . . . . . . . . . 13 2.6.1 Magnetometer filter . . . . . . . . . . . . . . . . . . . . . 14 2.6.2 Numerical differentiation . . . . . . . . . . . . . . . . . . 15 2.6.3 Digital estimator . . . . . . . . . . . . . . . . . . . . . . 15 2.7 Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.8 Controllability . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.9 Stabilizability . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Spacecraft Dynamics and Environment 19 3.1 Basic orbit dynamics . . . . . . . . . . . . . . . . . . . . . . . . 19 3.2 Satellite dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.3 Satellite kinematics . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.4 The geomagnetic field model . . . . . . . . . . . . . . . . . . . . 22 3.5 Actuator model . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.6 Environmental disturbances . . . . . . . . . . . . . . . . . . . . . 24 3.6.1 Gravitation . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.6.2 Aerodynamic torque . . . . . . . . . . . . . . . . . . . . 25 3.6.3 Solar radiation torque . . . . . . . . . . . . . . . . . . . . 26 3.6.4 Internal magnetic dipole . . . . . . . . . . . . . . . . . . 27 Linearized satellite model . . . . . . . . . . . . . . . . . . . . . . 27 3.7 x 3.7.1 4 5 6 7 Linearized equations of motion . . . . . . . . . . . . . . 31 Magnetorquer design 33 4.1 Design specification . . . . . . . . . . . . . . . . . . . . . . . . . 33 4.2 Coil design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Control 36 5.1 Control strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 5.2 Stability requirements . . . . . . . . . . . . . . . . . . . . . . . . 37 5.3 Detumbling Controller . . . . . . . . . . . . . . . . . . . . . . . 39 5.4 Nonlinear controller . . . . . . . . . . . . . . . . . . . . . . . . . 40 5.5 Linear-Quadratic Regulator . . . . . . . . . . . . . . . . . . . . . 41 Simulations and Results 43 6.1 Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 6.2 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 6.2.1 Magnetometer measurement filters . . . . . . . . . . . . . 44 6.2.2 Detumbling . . . . . . . . . . . . . . . . . . . . . . . . . 45 6.2.3 Nonlinear control . . . . . . . . . . . . . . . . . . . . . . 47 6.2.4 Optimal control . . . . . . . . . . . . . . . . . . . . . . . 62 Discussion and Conclusion 67 7.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 7.2 Conlusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Bibliography 69 A Matlab Code 74 B Mechanical Drawings and Data 96 xi List of Figures 6.1 Plot of low-pass filter for geomagnetic measurements. . . . . . . . 45 6.2 Zoomed plot of low-pass filter for geomagnetic measurements. . . 46 6.3 Plot of the numerical differentiation by central difference method for geomagnetic measurements . . . . . . . . . . . . . . . . . . . 47 Zoomed plot of the numerical differentiation by central difference method for geomagnetic measurements . . . . . . . . . . . . . . 48 6.5 Plot of the digital estimator used for geomagnetic measurements . 49 6.6 Zoomed plot of the digital estimator used for geomagnetic measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 6.7 Plot of angular velocity ω bob after detumbling. . . . . . . . . . . . 51 6.8 Plot of energy and power consumption after detumbling. . . . . . 52 6.9 Plot of total disturbance torques while detumbling. . . . . . . . . 53 6.10 Plot of the Euler angles after nonlinear control, gravity as only disturbance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 6.11 Plot of energy and power consumption after nonlinear control, gravity as only disturbance. . . . . . . . . . . . . . . . . . . . . . . . 55 6.12 Plot of gravity-gradient torques while simulating nonlinear reference controller. . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 6.13 Plot of the Euler angles after nonlinear control, with gravity and aerodynamic disturbance torques. . . . . . . . . . . . . . . . . . 57 6.14 Plot of energy and power consumption after nonlinear control, with gravity and aerodynamic disturbance torques. . . . . . . . . . . . 58 6.4 xii 6.15 Plot of the aerodynamic disturbance torques while simulating nonlinear control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 6.16 Plot of the Euler angles after nonlinear control, with gravity, aerodynamic and solar disturbance torques. . . . . . . . . . . . . . . . 60 6.17 Plot of the solar disturbance torques while simulating nonlinear control, with gravity, aerodynamic and solar disturbance torques. . 61 6.18 Plot of the Euler angles after nonlinear control with integral action, i = 1 · 10−12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 6.19 Plot of the Euler angles after nonlinear control with integral action, i = 5 · 10−11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 6.20 Plot of the Euler angles after optimal control, gravity as only disturbance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 6.21 Plot of energy and power consumption after optimal control, gravity as only disturbance. . . . . . . . . . . . . . . . . . . . . . . . 65 6.22 Plot of the Euler angles after optimal control, with gravity and aerodynamic disturbance torques. . . . . . . . . . . . . . . . . . 66 B.1 Mechanical drawing of magnetorquer to be used and the x- and y-sides. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 B.2 Mechanical drawing of magnetorquer to be used on the z-side. . . 97 xiii List of Tables 4.1 Table of magnetorquer parameters. . . . . . . . . . . . . . . . . . 34 4.2 AWG parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . 35 5.1 ACS requirements. . . . . . . . . . . . . . . . . . . . . . . . . . 36 6.1 Table of simulation parameters. . . . . . . . . . . . . . . . . . . . 44 6.2 Initial values for the detumbling simulations. . . . . . . . . . . . 46 6.3 Initial values for the nonlinear reference controller simulations with only gravity-gradient disturbance. . . . . . . . . . . . . . . . . . 49 Initial values for the nonlinear reference controller simulations with gravity-gradient and aerodynamic disturbances. . . . . . . . . . . 50 Initial values for the nonlinear reference controller simulations with gravity-gradient, aerodynamic and solar disturbances. . . . . . . . 51 Initial values for the nonlinear reference controller simulations with integral action. . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Initial values for the optimal LQR reference controller simulations with gravity-gradient as only disturbance. . . . . . . . . . . . . . 63 Initial values for the optimal LQR reference controller simulations with gravity-gradient and aerodynamic disturbances. . . . . . . . 64 6.4 6.5 6.6 6.7 6.8 xiv Chapter 1 Introduction 1.1 The NUTS - NTNU Test Satellite project The NUTS project is a student satellite project at the Norwegian university of science and technology (NTNU), which aims to design, build and launch a satellite of the CubeSat standard by the year of 2014. The project is part of a national satellite program, ANSAT, where also the Narvik University College and University of Oslo are bulding a satellite each, called HinCube [1] and CubeSTAR [2] respectively. Apart from building three student satellites, the ANSAT program also "has the intention to stimulate cooperation between educational institutions in Norway and with industry, and also to give the students experience in team work and hands-on training. The program also aims to increase the interest for science and technology in lower educational levels to secure future recruitment to higher education" [3]. The program was initiated in 2006 and started up in 2007 as a succession of the NCUBE-1 and NCUBE-2 projects. The NUTS project were initiated in the fall of 2010, while students started working on it in the spring of 2011. The project spans over a wide area of different discipilines, and since the start-up there’s been more than 30 students involved, and with even more to come. The satellite will be built following the CubeSat standard developed by the California Polytechnic State University and Stanford University [4], as a way for schools and universities to be able to build and launch affordable satellites consisting of mostly commercial off-the-shelf components. Our satellite will be a double CubeSat measuring 10 × 10 × 20 cm3 and have a maximum weight of 2.66 kg. The main payload will be an infrared (IR) camera which will take pictures of gravity waves in the Earth’s atmosphere, and as a secondary payload there’s an internal wireless databus to be tested in space. As for the attitude control, magnetic torquer is the chosen actuator. A project statement can be found at [5], and for updated information see the project’s webpage [6]. 1 CHAPTER 1. INTRODUCTION 1.2 2 Small satellites After the World War II, when both USSR and USA acquired advanced missile technology from Germany, the very first signs of the coming space age took place. On October 4th 1957 the space age begun with the launch of Sputnik 1 by the USSR. This ignited the space-race between the USSR and the United States of America, and over the years with ever more decreasing size of electrical components into micro- and nanoelectronics have made it possible to make smaller and smaller satellites at a low cost. 1.3 Small satellite magnetic attitude control systems overview With the increasing possibilities of having advanced payloads in small satellites, also nano satellites, comes the need of an accurate attitude control system. There are numbers of different approaches one can use for ACS, both passive and active ones. Passive control schemes includes gravity gradient boom and/or permanent magnet; the former mainly supporting pointing stability for active controlled satellites which already are nadir pointing, and the latter consists of a ferromagnet in order to make the sattelite’s dipole vector follow the geomagnetic field lines. With the permanent magnetic solution our nadir pointing requirement would be compromised, and since the gravity gradient boom only supports other active controllers, none of them were chosen to be used in our satellite. Active schemes are for example liquid or gas thrusters, moment wheels and/or electromagnetic torquers. As the CubeSat standard doesn’t allow for liquid thrusters, only gas thrusters are an alternative. However, with the strict space and weight restrictions of our satellite and maybe more important, for practical mechanical reasons thrusters were not considered an option for our solution. Moment wheels also take up some space and weight in a satellite, and one would also need electromagnetic torquers (magnetorquers) for moment dumping of the wheels. For satellites at altitudes defined as a low Earth orbit (LEO), i.e. the locus from the Earth’s surface up to an altitude of 2,000 km, and with a near polar orbit the geomagnetic field is strong enough and is varying enough to be able to use magnetorquers as control actuators. Magnetorquers are also relatively cheap and easy to manufacture. Hence for the NUTS, which will be in a LEO, an active scheme of magnetic actuators is suitable and an overview of this field will now be presented. Since the beginning of the space age the use of magnetorquers for attitude control have been studied White et al. [7]. However, only since the early 90’s the use of magnetic control for small satellites gained attention; in Wen & Kreutz-Delgado [8] a general framwork for the attitude tracking control problem for a rigid body was developed, and in Pittelkau [9] it was shown that roll/yaw dynamics with mag- CHAPTER 1. INTRODUCTION 3 netic control are/can be seen as periodically time varying and an optimal periodic control law was developed. Nonlinear sliding mode control for satellites is the topic of the paper by Chen & Lo [10]. In Steyn [11], a rule-based fuzzy controller is presented in a low-earth-orbit small satellite attitude control system. Three-axis satellite control based only on magnetic control for a low earth orbit satellite with optional moments of inertia is shown in Wisniewski & Blanke [12] and is further revised in Wisniewski & Blanke [13]. In Wisniewski [14] a nonlinear sliding mode controller is developed for a small near polar LEO satellite without appendages. In Wang et al. [15], detumbling and attitude acquisition is made possible without e.g. gravity boom or reaction wheels, only magnetorquers. A control system with the satellite dynamics represented with an inner and outer loop is used, where the outer loop is regarded as a regulation system controlled by a virtual input produced by the inner. Magnetic attitude control using periodic linear systems theory were investigated in Wisniewski [16], based on the steady state and transient solutions of the Riccati equation, and it was shown that a LEO near polar with magnetic actuators can be described with a set of periodic differential equations. The periodicy being exploited is that of the geomagnetic field surrounding the Earth, which over 24 hours can be said to be periodic. Psiaki [17] also finds periodic linear controllers using asymptotic linear quadratic regulator (LQR) techniques, which also includes integral action and saturation logic. In Lovera and Astolfi [18] an optimal periodic controller for asymptotic stabilization is described and in addition, techniques for disturbance attenuation for periodic systems subject to periodic disturbances is described. For a good overview and survey of the small satellite magnetic attitude control field, the paper by Silani and lovera [19] is worth the read. 1.4 Previous work The work done on attitude control in the NCUBE-1 and NCUBE-2 projects, with contributions from Kristiansen [20], Fauske [21] Busterud [22], Øverby [23] and Narverud et al. [24], and the thesis by Soglo [25], the makes up the basis of most of the work on attitude determination and control systems (ADCS) in the NUTS projects. Other Master theses worth mentioning are Makovec [26] of the HokieSat project, Andresen et al. [27] from the AAUSAT-II project, Giesselmann [28] of the Compass-1 project, and the two from the CubeSTAR project by Stray [29] and Rensel [30]. Since this project is very interdisciplenary, the work of the all members of the group is crucial to make the system as a whole to work altogether. The different subsystems of the satellite project are: • On-board computer (OBC) • Backplane CHAPTER 1. INTRODUCTION 4 • Electrical power system (EPS) • Tracking, telemetry & command (TT&C) • Payload (IR Camera and wireless bus) • Mechanical • Attitude determination and control system (ADCS) • Ground station (not part of the space segment/satellite) Work on the OBC have been done by Volstad [31] with a focus on hardware design, and Holmstrøm [32] with software design focus. de Bruyn [33] developed the a system for the backplane amd EPS with further work done by Jacobsen [34]. An antenna system design were developed by Marholm [35], and uplink security and access control were the topics in Visockas [36]. Systems for taking, handling and sending infrared pictures with the IR camera have been done by Bakken and Rønning [37], while work on the wireless bus experiment is shown in Meland [38]. Rokstad [39] started analysis of the possibilities of making the frame structure of the satellite in composite material. Ground station work have been done by Stenhaug [40]. Earlier work on the ADCS part of the project have been done by Jenssen and Yabar [41], Rinnan [42] and Holberg [43], which all investigates and suggests solutions of the attitude determination problem. In [41] the Extended Kalman Filter (EKF) for nonlinear estimation of the satellite’s attitude is investigated, and also a new method called the Extended QUaternion EStimation, abbreviated EQUEST, for nonlinear attitude estimation were found. This method utilizes vectorized and non-vectorized measurements for the attitude estimation. For satellites with magnetic actuation as ours, the EQUEST method have some advantages over the EKFmethod. In [42] the EQUEST method were further developed, and it now makes use of quaternion products as opposed to earlier, which used subtractions between estimated and measured quaternions. This latter method does not result in a new quaternion, but the former with quaternion products does. As a result, it has a higher accuracy, but with the cost of more complexity and it’s computationally more demanding. Work done in the ADCS part of the project with a focuse on attitude control, are Tudor [44], and also Holberg [45] and Bråthen [46]. In [44] work on detumbling the satellite and reference control using a PD-like nonlinear controller were shown to give good results. using these control algorithms, three perpendicular magnetic coils (also called magnetic torquers/magnetorquers) were found to give sufficient actuation for reference control of a spacecraft. Also, a 8-bit, 16 MHz microcontroller were found to have the sufficient processing power to compute the geomagnetic field using the International Geomagnetic Reference Field (IGRF) model and simultaneously maintaining correct coil actuation. In [45] an optimal linear CHAPTER 1. INTRODUCTION 5 quadratic regulator (LQR) for reference control were developed, while in [46] different nonlinear controllers were investigated, and a sliding mode and a PD controller similar to the one developed by Tudor [44] proved to work satisfactory. On-going work: There are on-going work on all the subsystems except the 1.5 Thesis outline Chapter 2 introduces some mathematical principles used throughout the thesis. Filters for magnetometer measurements are explained. It also includes Lyapunov stability theorems, and the concepts of observability, controllability and stabilizability is introduced. Chapter 3 presents and explains the models used for simulating the dynamics of a rigid body in orbit around the Earth, including models for the space environment; the geomagnetic IGRF model, and gravitational, aerodynamic, solar radiation and internal dipole disturbance torques. Introduces the magnetic actuator model and derives the linearized satellite model. Chapter 4 presents the magnetorquer design for the satellite. Chapter 5 presents the control strategy and the controllers to be investigated: the so-called B-dot detumbling controller, the nonlinear PD-like reference controller and the optimal LQR controller. Some coments on the stability of the three control algorithms are provided. Chapter 6 shows the results of the filters for the magnetometer measurements, and of the three control algorithms investigated. Some comparisons between the different filters and the different control algorithms subjected to dofferent conditions are made. Chapter 7 presents the final conclusions and remarks on further work to be done. Appendix A contains the Matlab code and scripts used to simulate the controllers and filters. Appendix B presents some mechanical drawings of the frame used for the magnetorquers, provided by Christian E. Nomme and Kim Sandvik. Chapter 2 Theory Working with navigation from an engineering point of view, is in many ways the study and effort to try to determine and control the change of dynamics of an object/body, such as marine vessels, airplanes and spacecrafts or satellites. Different coordinate frames are used to model the dynamics of the different objects, and in order to work with and analyse these, one need mathematical tools to describe how these objects relate to each other. Space navigation with respect to a small satellite is often restricted to change its attitude, which is one of this thesis’ objectives, and is described in chapter 3. In this chapter, the different reference frames are defined and established, as well as the most commonly used parametrizations for attitude representation. For a more in-depth study of these topics, see (Gravdahl and Egeland, 2002) in general and (Hughes, 1986) for space attitude specifically. 2.1 Coordinate frames First step in order to analyse and design an ACS control system for a satellite is to define the different coordinate frames to work with. A satellite’s attitude is maybe most conveniently described as a deviation relative to a chosen reference coordinate frame. For this reason, and because the topic of attitude, reference frames and rotations can be a bit mind-boggling, it is important to have clear definitions of the different frames. 6 CHAPTER 2. THEORY 2.1.1 7 Earth centered inertial frame The Earth centered inertial (ECI) frame, denoted Fi , has its origin in the center of the Earth and is an inertial, non-rotational frame in which Newtons’s laws of motion apply. It is defined by the the unit vectors ~xi , ~yi and z~i . The ~zi axis points at a 90◦ angle relative to the Earth’s equatorial plane where it coincides with the Earths rotational axis and continues through the celestial North Pole. The ~xi axis points in the vernal equinox vector direction, which is the vector pointing from the centre of the Sun to the centre of the Earth at the vernal equinox. The vernal equinox is a time of the year when the Earths orbital plane as it rotates around the Sun coincides with the equatorial plane, i.e. the center of the Sun lies in the same plane as the Earths equator. Finally, the ~yi axis completes the three axis orthonormal frame according to the right-hand rule. 2.1.2 Earth centered Earth fixed frame The Earth centered Earth fixed frame (ECEF) frame, denoted Fe , has as the ECI frame its origin at the Earth’s centre, but it’s different in the way that it rotates with the Earth. The frame is spanned out by the unit vectors ~xe , ~ye and z~e . Again, the ~ze points along the Earth’s rotational axis, while ~xe points in the direction of 0◦ latitude and 0◦ longitude. This means the coordinate frame rotates around the ~ze axis with the angular rate of ωe = 7.2921 · 10−5 rad/s. The ~ye completes the right-handed orthonormal frame. 2.1.3 Orbit fixed frame The orbit fixed frame, denoted Fo , follows the orbit trajectory and has its origin at the satellite’s center of mass. It is defined by the unit vectors ~xo , ~yo and ~zo . The ~zo axis points towards the center of the Earth, and the ~xo axis points in the orbit normal direction, which is parallel to the orbital angular momentum vector. Again, the ~yo axis completes the right-handed orthonormal frame. 2.1.4 Body fixed frame The body fixed frame, denoted Fb , is a moving coordinate system which also has it’s origin at the satellite’s center of mass. However, unlike the orbit frame it is fixed to the satellite, and so it rotates and moves with the satellite. It’s defined CHAPTER 2. THEORY 8 by the unit vectors ~xb ,~b and ~zb , and for simplifying further attitude comptutations it’s commmon to let these vectors coincide with the satellite’s axes of moments of inertia. We will define it by letting the ~yb axis be that of the maximum inertia, the ~zb axis be the minimum inertia, and the ~xb axis completes the right-hand orthonormal system. This choice follows from the result of the stability analysis done in section 5.2. Further, the ~xb axis is called the roll axis, ~yb is the pitch axis and ~zb is the yaw axis. 2.2 The Rotation Matrix Our main mission in orbit is to take pictures of the Earth’s gravity field waves in the upper atmosphere with an IR camera, and hence we want to orient the satellite’s camera in the nadir direction towards the Earth. In order to compare and manipulate the satellite’s attitude relative to a reference frame, one need to or express the attitude vector in several different frames. One transforms the attitude vector from one frame to another, and the tool used for doing this is the rotation matrix R. Another interpretation is that it can also describe the attitude of a rigid body. The definitions and notation below follows mostly that of Gravdahl and Egeland [47]. Let Fa and Fc denote two coordinate frames, both ∈ R3 . The frames are defined by the orthogonal unit vectors ~a1 , ~a2 , ~a3 and ~c1 , ~c2 , ~c3 respectively. Further, a vector ~v may be described in both systems Fa and Fc : ~v = 3 X via~ai and ~v = i=1 3 X vic~ci . (2.1) i=1 where via = ~v · ~ai and vic = ~v · ~ci are the coordinates of the vector ~v in the frames Fa and Fc , respectively. The column vectors in the two frames are then given by (for likt Tudor?) a c v1 v1 va = v2a and vc = v2c . (2.2) a c v3 v3 The relation between the coordinate vector represented in the two different coordinate frames can be found by combining the equations (2.1) and (2.2): via = ~v · ~ai = (v1c~c1 + v2c~c2 + v3c~c3 ) · ~ai = 3 X j=1 vj (~ai · ~cj ) . (2.3) CHAPTER 2. THEORY 9 Further, one can now transform the coordinate vector from frame Fc to frame Fa via the rotation matrix Rac given by: va = Rac vc where Rac = {~ai · ~cj } . (2.4) So Rac is the rotation matrix which takes a vector in the Fc frame and transforms it to a vector in the Fa frame. A simple way of explaining this is to describe the transformation as f rom vto = Rto . f rom v The elements of a rotation matrix Rto f rom are called the direction cosines, and so the rotation matrix is also called the direction cosine matrix. The two main properties of the rotation matrix are that its determinant equals unity and that it is orthogonal: 1. Rac = (Rca )−1 = (Rca )T . 2. det R = 1. From this a special orthogonal group for the rotation matrix, the SO(3) - special group of order 3 is defined. See Egeland and Gravdahl [47] for proofs. SO(3) = R|R ∈ R3×3 , RT R = I3×3 and det R = 1 (2.5) where I3×3 is the 3 by 3 identity matrix. One important property of the rotation matrix is called composite rotations. This means that a rotation from frame Fd to frame Fa can be done by, for instance first rotating from frame Fd via intermediate frame Fc , and then finally from Fc to Fa . Say one want to express a vector in the Fd frame, vd , in the Fa frame, and to do so one need to go via frame Fc . To illustrate consider the following equation to obtain the rotation matrix Rad from Fd to Fa : va = Rac Rcd vd ⇒ Rad = Rac Rcd . (2.6) Finally, the rotation matrix has two interpetations: 1. One uses the rotation matrix to transform a vector from one coordinate frame to another. 2. One uses the rotation matrix to rotate a vector within the coordinate frame it is represented in. CHAPTER 2. THEORY 2.3 10 Attitude representation Attitude simply means how an object is rotated or oriented relative to a reference frame, and it is evident that the concept of attitude representation and rotation matrices are highly interconnected. With which parameters one wish to describe an object’s attitude is what we mean by attitude representation. (Euler angles and Euler parameters will be presented below.) 2.3.1 Euler angles and roll-pitch-yaw Euler angles are a classical and intuitive way of expressing the attitude. It consists of the roll angle φ, pitch angle θ and yaw angle ψ contained in the Euler angle vector Θ: φ Θ = θ . (2.7) ψ In a three-axis orthonormal coordinate system, with ~x, ~y and ~x spanning out the principal axes, roll describes rotation about the ~x axis, pitch is rotation about the ~y axis and yaw is rotation about the ~z axis. From this we get that e.g. the matrix Ry (θ) denotes a single rotation of θ radians around the ~y axis. The elements of the matrices for all the three axes becomes: 1 0 0 Rx (φ) = 0 cos φ − sin φ 0 sin φ cos φ (2.8) cos θ 0 sin θ 0 1 0 Ry (θ) = − sin θ 0 cos θ (2.9) cos ψ − sin ψ 0 Rz (ψ) = sin ψ cos ψ 0 0 0 1 (2.10) Say that a transformation of a vector from one frame to another consists of first a rotation φ around the x axis, followed by a rotation θ around the current y axis, and finally a rotation ψ around the current z axis. Then the resulting rotation matrix can be written as Rac = Rx (φ)Ry (θ)Rz (ψ). (2.11) CHAPTER 2. THEORY 11 This formulation is useful and an easier way to interpret a rotation of e.g. a satellite as a sequence of single rotations rather than a rotation matrix. Now, the concept of the rotation matrix when relating it to Euler angles can be taken one step further. In [47], it is shown that the rotation matrix Rac can be described as a rotation θ about an unit vector ~k, and Rac is given by Rac = cos(I3×3 ) + sin θ S(k) + (1 − cos θ)k(k)T (2.12) where the S(k) is the skew-symmetric form of the coordinate vector k defined by 0 −k3 k2 k1 0 −k1 , k = k2 (2.13) S(k) = −ST (k) = k3 −k2 k1 0 k3 which gives that the cross product can be written on the form a × b = S(a)b. (2.14) In litterature the notation k× instead of S(k) is used as well. The parametrization in equation (2.12) is called the angle-axis parametrization of the rotation matrix. How intuitive Euler angles and the roll-pitch-yaw concept may be, one problem when using this representation is that one risk to get singularities for some angles, e.g. cos π2 , when calculating the resulting rotation matrix. For this reason Euler parameters, also called quaternions, is used in the numerical computations in this project. However, for the ease of interpetation the Euler angles are used when presenting some of the results in this thesis. 2.3.2 Euler parameters and Quaternions As mentioned above, since we can risk to get singularities when using Euler angles we are interested in another way to represent the satellite’s attitude. This is where Euler parameters comes in handy. The Euler parameters is a four-parameter singularity free attitude representation. The Euler parameters and unit quaternions are basically the same, and, to not confuse more than necessary, the expression quaternion will be used from now on. The quaternion q is defined as a complex number with one real part η and three imaginary parts given in the vector ε defined by: ε θ θ 1 η = cos , ε = k sin = ε2 (2.15) 2 2 ε3 CHAPTER 2. THEORY 12 which, as in (2.12), corresponds to a rotation θ about an unit vector k. The quaternion becomes q= η ε 1 ε2 ε3 T . (2.16) The quaternion also satisfies the constraint qT q = 1 ⇒ η 2 + εT ε = η 2 + ε21 + ε22 + ε23 = 1. (2.17) When using the quaternion in practical implementations, equation (2.17) gives that an object is aligned with the reference frame of interest when q = [1 0 0 0]T . One can say that the quaternion parameters express a rotation η about an unit vector ε in a similar manner as in (2.12), and we get the rotation matrix given by the quaternion parameters η and ε: Rk,θ = Re (η, ε) = I3×3 + 2η S(ε) + 2S2 (ε) (2.18) Further, once we have the quaternions for the satellite in the body frame and using (2.18), we can obtain the rotation matrix between the body frame of the satellite and the orbit frame: Rob = I3×3 + 2η S(ε) + 2S2 (ε) (2.19) And finally we get Rbo = (Rob )T (2.20) which will be made use of later. While the main advantage when using quaternions, namely that it is singularity free, is a big one; a disadvantage is that its physical meaning isn’t as intuitive as Euler angles. 2.4 Frame transformations Now that the concept of the rotation matrix is established, the practice of transforming vectors between frames will be shown. Two assumptions are made; the satellite’s orbit eccentricity is zero and the altitude is 600 km. ECI to ECEF ECEF to Orbit frame Orbit to Body frame CHAPTER 2. THEORY 2.5 13 The inertia matrix In order to have a good model of the satellite, it is important to know as exactly as possible what the satellite’s inertia matrix is. Mathematically, the inertia matrix Io <3×3 about an arbitrary origin O is defined according to Ix −Ix y −Ix z Iy −Iy z , Io = Io T > 0. Io := −Iy x (2.21) −Iz x −Iz y Iz where Ix , Iy and Iz are the moments of inertia about the xb -, yb - and zb - axis respectively, and Ixy = Iyx , Ixz = Izx and Iyz = Izy are the products of inertia. If one choose to let the principal axes of inertia coincide with the axes of the body frame, the inertia matrix reduces to: Ix 0 0 (2.22) I = 0 Iy 0 . 0 0 Iz where Ix , Iy and Iz are given by: Z Ix = ZV Iy = ZV Iz = (y 2 + z 2 )ρm dV (x2 + z 2 )ρm dV (2.23) (x2 + y 2 )ρm dV V and ρm is the density of the satellite and V is the volume. Throughout this paper the inertia matrix will be referred to as I, while the identity matrix wil be referred to as In×n , as in equation (2.18) e.g. 2.6 Magnetometer measurements As we will see in chapter 5, we want to use magnetometer mesurements in the detumbling algorithm, the so-called B-dot algorithm. The measurements can be expected to be noisy, and from the name of the algorithm it’s apparent that the derivative of the local geomagnetic field, Ḃ, needs to be found. In signal processing, and in control theory for that matter, derivating a noisy signal is generally not considered to be a very good idea. The reason for this is that any CHAPTER 2. THEORY 14 noise in the original raw signal will be carried on and amplified in the process of finding its derivative. Different methods will be looked into in this chapter to find the smoothest Ḃ values. A suitable and sufficient sampling frequency of the magnetometer measurements have been found to be 1 Hz. With this frequency and with a measuring/actuating switching every 3 seconds, see section 5.1, we get efficiency and the estimated time ˆ is stable. derivative of the local geomagnetic field, Ḃ, For filter results see section 6.2.1. 2.6.1 Magnetometer filter For some of the differentiation methods investigated here, the raw and noisy measurement signal is not preferred to use. Before the signal is differentiated we want to filter it in order to remove most of the high frequency noise, hence a digital low-pass filter is found. The measured magnetic field might also be used in other control laws, and in attitude determination schemes, so to filter these measurements is necessary. We use a standard low-pass filter: H(s) = B̂ ωc = B s + ωc (2.24) which when written out in discrete form becomes: B̂k = a1 B̂k−1 + b1 Bk (2.25) where B̂k is the filtered value, at sample k, of the measured value Bk , and a1 and b1 are the filter coefficients: a1 = 0.8. and b1 = 1 − a1 . When simulating and testing this and other filters, the IGRF model discussed in section 3.4 is used, which calculates the local gemomagnetic field vector represented in the orbit frame, Bo . Noise corresponding to about 1.5 times the expected noise floor given in the chosen magnetometer datasheet, see [48], is added to the computed IGRF value. Since the magnetometer we want to emulate is fixed to the satellite, we further transform the calculated local geomagnetic field vector Bo to the body frame, and we get Bb . This vector is our emulated magnetometer measurement, i.e. the raw signal on which we want to test the filter found above, and also other filters presented below. CHAPTER 2. THEORY 2.6.2 15 Numerical differentiation We will here investigate a method of numerical differentiation of a digital signal, namely the central difference method. Central difference This method is a quite well-known and basic formula for numerical differentiation of a signal. The formula is a first-order finite difference method and takes basis in the definition of the time derivative of a function f (x), which is: d f (x + ∆t) − f (x) f (x) = . dt ∆t (2.26) where ∆t is the sample time, i.e. the time between each sample. When implemented on the on-board microcontroller this will be fixed to 1 second, and we get a sampling frequency of 1 Hz. The central difference method is the following: d f (x + ∆t) − f (x − ∆t) f (x) = dt 2∆t (2.27) When you have a sequence of samples of a signal, you take the difference between the next sample and the previous and divides by the change in the time. Now you get a smaller error then what you would’ve got using the standard derivative definition (called backward difference when used as a numerical differentiator). This can be directly implemented as a discrete numerical differentiator of the measured geomagnetic field vector B. We get the following ˆ = Bk+1 − Bk−1 Ḃ k 2∆t (2.28) where subscript k, k + 1 and k − 1 demotes the current, next and the previous sample, respectively. Since the measurements are noisy, the values Bk−1 , Bk and Bk−1 are filtered values from the filter in equation 2.25 in section 2.6.1. 2.6.3 Digital estimator Here, an estimation algorithm of Ḃ is presented, based on (Andersen, 2005). The estimator can be expressed as a Laplace domain filter: H(s) = ˆ Ḃ ωc s = B s + ωc (2.29) with ωc being the cut-off frequency. A cut-off frequency of ωc = 0.7 rad/s have been found to be valid. CHAPTER 2. THEORY 16 We will implement this on a computer and microcontroller, so the estmator needs to be discrete. In the z-domain it is the following H(z) = ωc z−1 b2 (1 − z −1 ) = z − e−ωc Ts 1 − a2 z −1 where Ts is the sample time. And thus ˆ − a z −1 ) = b (1 − z −1 )B. Ḃ(1 2 2 (2.30) (2.31) Written out in the discrete notation used when implemented in the Matlab simulation script and eventually on the on-board microcontroller, we get the recurrent filter: ˆ = a Ḃ ˆ Ḃ (2.32) 2 k−1 + b2 (Bk − Bk−1 ) k with k and k-1 subscript denoting the current and previous sample, respectively, ˆ and B being vectors. The filter coefficients is found to be and with Ḃ k k a2 = e−ωc Ts = 0.9324. and b2 = 0.2028. ˆ is calculated by using almost all the information One can see that the estimated Ḃ (about 93 %) of the previous estimated value, and adding a low average of the current and previously measured values of B. Some high-frequency noise will come through. See more in chapter 6. 2.7 Stability In order to evaluate the controller strategies presented in chapter 5, we here look at some stability tools for linear and nonlinear systems. First, we present Lyapunov stability theorems extracted from chapter Chapter 4.1 in Khalil [49]. Theorem 1: Let x = 0 be an equilibrium point for ẋ = f (x) and D ⊂ Rn be a domain containing x = 0. Let V : D → R be a continuously differentiable function such that V (0) = 0 and V (x) > 0 in D − {0} (2.33) V̇ (x) ≤ 0 in D. (2.34) CHAPTER 2. THEORY 17 Then, x = 0 is stable. Moreover, if V̇ (x) < 0 in D − {0} (2.35) then x = 0 is asymptotically stable. Theorem 2: Let x = 0 be an equilibrium point for ẋ = f (x). Let V : Rn → R be a continuously differentiable function such that V (0) = 0 and V (x) > 0, ∀x 6= 0 (2.36) ||x|| → ∞ ⇒ V (x) → ∞ (2.37) V̇ (x) < 0, ∀x 6= 0 (2.38) then x = 0 is globally asymptotically stable. 2.8 Controllability A linear system ẋ(t) = Ax(t) + Bu(t) is said to be controllable if for all initial conditions x(0) = x0 , final conditions xf and tf > 0, there exists an input u(t), 0 < t < tf , such that x(t) = xf . In other words, a linear system is controllable if at any given time t with an input u(t), it’s possible to make the system assume the state xf . Further, with the controllability matrix C we have a mathematical definition of controllability: Definition 1 For the linear system ẋ(t) = Ax(t) + Bu(t), and with n being the dimension of A , the controllability matrix C is defined as C = [B|AB|A1 B| . . . |An−1 B]. (2.39) The linear system is controllable if and only if C has full row rank, i.e. rank(C) = n. CHAPTER 2. THEORY 2.9 18 Stabilizability For a system which is uncontrollable in terms of the definition in 2.8, we have a tool for ensuring that a system with state-feedback control wil be stable, namely the concept of stabilizability: Definition 2 For the a linear system ẋ(t) = Ax(t) + Bu(t) with the state-feedback controller u = Kx(t), the closed loop system becomes x(t) = (A + BK)x(t) = Ac x(t). (2.40) The linear closed-loop system is said to be stabilizable if Ac is Hurwitz, i.e. all the eigenvalues of Ac has strictly negative real parts. Chapter 3 Spacecraft Dynamics and Environment In this section some basic space calculations will be presented, in addition to a mathematical model of the satellite, the actuators used to control it and the main surroundings influencing it’s behaviour. 3.1 Basic orbit dynamics Orbit dynamics are based on the laws of Newton and Kepler. Kepler’s laws describes unperturbed orbital motions of planets around the Sun, while Newton’s laws describes the physical laws governing the relationship between the forces acting on a body and its motion due to those forces. In other words, Newton gave us the mathematical explanation of why planets and satellites follow Kepler’s laws. Kepler’s laws of planetary motion 1. The orbit of every planet is an ellipse with the Sun at one of the two foci. 2. The line joining a planet and the Sun sweeps out equal areas during equal intervals of time. 3. The square of the planetary period of revolution is proportional to the cube of the planet’s mean distance to the Sun. Newton’s laws of motion 1. An object which experiences no net force will have constant velocity; it will 19 CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT 20 remain in a state of rest (zero velocity) or it will move in a straight line with constant velocity (non-zero velocity). 2. The acceleration a of a body is parallel and directly proportional to the net force F acting on the body, is in the direction of the net force and is inversely proportional to the mass m the body: F = ma. (3.1) 3. If a body exerts a force F1 on another body, the other body will exert an equal force with opposite direction F2 = −F2 , to the first body. So F1 and F2 are equal in magnitude and opposite in direction. 4. The gravitational force between any two objects with mass m1 and m2 and distance r, is given by1 : 3 Gm1 m2 m −11 F= , where G = 6.7638 × 10 . (3.2) 2 r kgs2 To find a satellite’s angular velocity while orbiting the Earth, we make use of Newton’s universal gravitation law and his famous second law, with a = ω02 r: Gm2 2 rr Gm2 ω0 = r3 ω02 r = (3.3) We have assumed an orbital altitude of R0 = 600 km. so the distance from the satellite to the centre of the Earth: r = Re + R0 = 6371 km + 600 km = 6971 km (3.4) where Re = 6371 km is the Earth’s mean radius. 3.2 Satellite dynamics We assume we can treat the satellite as a rigid body. Lets start with the rotational equivalent of Newtons second law of motion, the law of angular momentum h: h = Iω (3.5) 1 This last law is not one of Newton’s three laws of motion, but since it’s used in our reasoning to end up with the mathematical model which explains a body’s orbital dynamics, we choose to list it here. It’s name is Newton’s law of universal gravitation. CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT 21 where I is the body’s moment of inertia matrix (see chapter 2.5) and ω is the body’s rotational velocity. The torque τ = [τ1 , τ2 , τ3 ]T is the total torque acting on the body. The torque law is then given by d τ = (Iω) (3.6) dt When this is expressed in the body frame, relative to an inertial frame, such as the ECI for our case, we get the following: τb = d b b I ω ib + ω bib × Ib ω bib . dt (3.7) The moment of inertia matrix is constant in the body frame, for simplicity we denote it I, and the torque law then becomes τ b = Iω̇ bib + ω bib × (Iω bib ). (3.8) The last cross-product part of (3.8) comes from the fact that dynamics are described in the rotating body frame. After some regrouping and mathematical manipulation we get the following: Iω̇ bib = −S(ω bib )Iω bib + τ b ω̇ bib = I−1 −S(ω bib )Iω bib + τ b . (3.9) Here we have ended up with the satellite’s dynamics expressed by its angular velocity (w.r.t. the inertial frame) time differentiative. Indeed, how we want to manipulate the satellite is by changing its angular velocity with the means of a control torque, in order to make it point in a certain direction. From this perspective, the model in (3.8) is convenient for our purpose. In component form the model is 1 ((Iy − Iz )ω2 ω3 + τ1 ) Ix 1 ω̇2 = ((Iz − Ix )ω1 ω3 + τ2 ) Iy 1 ω̇3 = ((Ix − Iy )ω1 ω2 + τ3 ) Iz ω̇1 = (3.10) (3.11) (3.12) The total torque, τ b , in (3.9) consists of a sum of torques acting on the satellite. These are the magnetic control torque, τ bm , generated by the magnetorquers, and the total of the disturbance torques, τ bdist . All of these torques will be derived in later sections. CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT 3.3 22 Satellite kinematics The kinematic equations of motion of how the attitude quaternions change are given by 1 η̇ = − T ω bob 2 1 ˙ = (ηI3x3 + S()) ω bob 2 (3.13) (3.14) as given in [47]. Since the attitude we are interested in altering is that of the satellite (body) relative the orbit frame, the corresponding angular velocity to the quaternions representing that attitude is ω bob . In order to connect this to the angular velocity ω bib in the expression for the satellite dynamics in (3.9) we have the following relationship ω bob = ω bib − ω bio = ω bib − Rbo ω oio = ω bib + ω0 cb2 (3.15) where ω oio is the orbital angular velocity around the Earth w.r.t. the inertial frame, and it comes in the form of a rotation about the ~yo axis: ω oio = 0 −ω0 0 T . (3.16) The vector cb2 in (3.16) comes from the column vector representation of the rotation matrix Rbo : Rbo = cb1 cb2 cb3 , (3.17) where cb1 , cb2 and cb3 are the projection of the xo -, yo - and zo - axis in the body frame. For example, the deviation of the zb - axis and the zo - axis is given by cb3 , and if it satisfy cb3 = [0 0 1]T the two axes are aligned. For more on angular velocities between different frames in general, and its physical interpretations, see chapter 6.8 in [47]. 3.4 The geomagnetic field model The International Geomagnetic Reference Field (IGRF) is a global model of the geomagnetic field sourrounding the Earth, and it is estimated every five years by CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT 23 the International Association of Geomagnetism and Aeronomy (IAGA). It consists of a set of Gaussian coefficients that is used to create a spherical harmonical approximation of the field. The latest version is the 11th generation (IGRF 11, revised 2009) model. The model and its application to satellite attitude control have already been well studied by Kristiansen, Makovec and Davis in [20; 26; 50], and a good summary of the model can be seen in Tudor [44]. I therefore refer to these sources, and only present the main IGRF equation here, which is obtained from Davis [50]. The magnetic field, B, is defined as the negative gradient of the scalar potential function V: B = −∇V (3.18) 0 V (Rc , λ , θ) = Re k n X Re n+1 X Rc n=1 m 0 (gnm cos mθ + hm n sin mθ)Pn (λ ) (3.19) m=0 where Re is the mean radius of the Earth, Rc is the distance from centre of Earth to the point of which one want to find the magnetic field values, λ0 is the colatitude (λ0 = 90◦ − latitude) and θ is the longitude. Further, P (λ0 ) is the Schmidt normalized associated Legendre polynomials, and gnm and hm n are the Gaussian coefficiants provided by the IAGA for the IGRF. Thus, the final magnetic field vector components in ECEF spherical coordinates are: ∂V ∂Rc k X Re n+2 Br = − = n=1 Bλ0 = − =− Rc =− 3.5 n X Rc (gnm cos mθ + hm n sin mθ) m=0 ∂V 1 0 Rc sin λ ∂θ n k 1 X Re n+2 X sin λ0 m 0 (gnm cos mθ + hm n sin mθ)Pn (λ ) (3.20) m=0 1 ∂V Rc ∂λ0 k n X Re n+2 X n=1 Bθ = − (n + 1) n=1 Rc ∂Pnm (λ0 ) ∂λ0 m 0 (−gnm sin mθ + hm n sin mθ)Pn (λ ) (3.21) (3.22) m=0 Actuator model The satellite’s attitude will be controlled using magnetic coils as actuators, also called magnetorquers. When applying an electrical current through the windings CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT 24 of the coils, a magnetic dipole field will be created. The magnetic dipole can be described as a vector, and the vector will be perpendicilar to the coil, pointing in the direction of the extended thumb of one’s hand according to the right-hand rule. When this field reacts with the local geomagnetic field, a magnetic moment is generated. In a very intuitive way, the magnetic field generated by the magnetorquers will try to align itself with the local geomagnetic field surrounding the satellite at that particular place. Thus, the satellite will experience a torque acting on it; pushing it in order to align it with the geomagnetic field. The magnetic dipole moment generated by the coils is given by the number of windings N, the current i and the coil area A. In our satellite we will have coils on the x+ -, y + - and z − - panels, so the total moment will be Nx ix Ax mb = mbx + mby + mbz = Ny iy Ay . (3.23) Nz iz Az The cross product of the magnetic dipole moment, mb , and the local geomagnetic field, Bb , generates the magnetic control torque τ bm : τ bm = mb × Bb = S(mb )Bb . (3.24) This torque is what will be used to maneuver the satellite. One inherit problem with magnetic control is that the system at times is underactuated. This comes from the fact that the torque is generated by the cross product between the magnetic moment, mb , and the geomagnetic field, Bb . If, for instance, we want to turn the satellite about the x axis, and this is axis is parallel to the local geomagnetic field vector; then control is lost and the system is in fact underactuated. Further, since when any of the magnetorquers is parallel to the local geomagnetic field we loose one degree of freedom, from definition 2.8 our system is uncontrollable. Another problem is that the coils only can produce a moment perpendicular to the coil area. Since the desired moment rarely will coincide with one of the coil moments, one have to do some modifications to the control algorithms. More on this in chapter 5. 3.6 Environmental disturbances There are several different environmental disturbances which will act on the satellite while orbiting the Earth, most of them will be disturbance torques. To list some of them, one should mention • Gravitation CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT 25 • Aerodynamic torque. • Solar radiation torque. • Internal magnetic dipole moments and other electrical noise which could lead to measurement errors. The disturbances listed above will, without doubt, all act on the satellite. Some argue that since the size of a CubeSat is relatively small, some of the disturbances will be so small they can be neglected. In low Earth orbits the most influental disturbance torques are gravity, aerodynamic and possibly magnetic dipoles. In any case we choose to model and investigate them here. 3.6.1 Gravitation The gravitation disturbance comes in form of a gravity-gradient torque, which will affect any non symmetric body in the Earth’s gravity field. When a non-symmetric satellite is orbiting the Earth, different gravitation forces from the Earth will act on different places on the satellite, which will lead to a gravity-gradient disturbance torque acting on the satellite. According to (Hughes, 1986), it’s given by τ bg = 3ω02 S(cb3 )Icb3 (3.25) where I is the satellites moment of inertia, ω0 is the orbital angular velocity from (3.3) and cb3 is given in (3.17). The gravitational force will be slightly bigger on the part of the satellite being closer to the Earth, and because of this the gravity-gradient torque will actually have a small stabilizable effect on the satellite according to our desired attitude. It will in a way pull one of the z-facets towards the Earth, depending on the mass distribution of the satellite. From the stability analysis in section/chapter ??, it’s shown that the satellite will be gravity-gradient stable if the satellite’s moments of inertia are designed in a certain way: Iy > Iz > Iz . 3.6.2 (3.26) Aerodynamic torque Even though there aren’t many particles crashing into the satellite in LEO altitudes (the atmosphere by definition ended at 100 km altitude), there are in fact some areodynamic drag creating a torque on the satellite. In order to have an as accurate model as possible, the model obtained in (Hughes, 1986) takes the satellite’s CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT rotating movements into account: b b τ ba = ρa Vrb Vrb Ap S(cp )V̂r − I + S(V̂r )J ω bob 26 (3.27) where • ρa is the atmospheric density. • Ap is the total projected area the airflow "sees". • cp is the location of the atmospheric centre of pressure relative centre of gravity. • Vrb is the magnitude of the local atmospheric velocity vector, Vrb = Vbr . b • V̂r is the unit velocity vector of the local atmosphere relative to the satellite b surface, V̂r = Vbr /Vrb . • J is the moment of inertia matrix with origin in the centre of pressure. • ω bob is the angular velocity of the satellite relative the orbit frame. For practical purposes, the local velocity vector is calculated in the orbit frame, so we need to transform it to the body frame: Vbr = Rbo Vor (3.28) Lastly, the projected area in (3.27) is constant, while in reality it will vary depending on the satellite’s attitude. A worst-case area is used, i.e. the projected area seen when one of the corner sides between the x- and y-sides are pointing in the velocity direction: p Ap = z x 2 + y 2 . (3.29) 3.6.3 Solar radiation torque Electromagnetic radiation from the Sun may produce a pressure on the satellite surface and in this way and create a disturbance torque. The solar radiation torque expression is given by Fs b Ap (1 + q) cos i cps (3.30) τs = c where CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT 27 • Fs is the solar constant, Fs = 1367 W/m2 . • c is the speed of light, c = 3 × 108 m/s. • Ap is the total projected area. • q is the reflectance factor. • i is the angle of incidence of the Sun. • cps is the location of the solar centre of pressure relative centre of gravity. As for the aerodynamic torque, a constant worst-case projected area is used. See equation 3.29. 3.6.4 Internal magnetic dipole The way in which the dipole moments of the magnetorquers are created apply to any kind of conductor which have a current running through it. This leads to small internal dipole moments being created all the time when any electronics on board the satellite is being used. It is very difficult to have a model for this to include in simulation models, for the reason that different electronics have different characteristics and on the satellite thousands of different components are being used. To try to model all of this would be very time demanding and not very constructive. However, it is a matter that is worth being aware of, and one might want to include these effects as a bias in the control algorithms. This has not been done at this time, but some very rough estimations of the dipole effects is shown in chapter 6. The resulting internal magnetic dipole disturbance torque will be created in the same manner as the control torque from section 3.5: τ bm,d = mbd × Bb = S(mbd )Bb . 3.7 (3.31) Linearized satellite model A commonly used controller for attitude control of a small satellite using only magnetorquers is the Linear-Quadratic Regulator. The word linear makes it clear that it’s based on linear dynamics, which will be presented here, while the rest of the controller as a whole will be further investigated in section 5.5. Two assumptions are made here; that in the equlibrium point the disturbance torques of solar radiation and internal dipole will have a negliable impact on the satellite. the linearization is done according to Busterud [22] and Øverby [23]. CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT 28 With the definition of the orbit reference frame in 2.1, the satellite have the desired attitude when it’s aligned with the orbit frame, i.e. the linearization will be around the equilibrium points ηeq 1 qeq = = (3.32) εeq 0 Kinematics Looking at the kinematics equation in (3.14) and using the constraint property of (2.17), we have that since η is defined by the ε-vector elements, η can be omitted in the linearization: ε = εeq + δε = δε, where δε are small perturbations from the equlibrium. When linearizing the satellite kinematics in this equilibrium point we get: 1 δ ε̇ = ω bob (3.33) 2 Rotation matrix From (2.19) we get that the rotation matrix corresponding to the quaternion describing the satellite’s attitude relative the orbit frame is Rbo = (Rob )T = I3×3 − 2ηS(ε) − 2S2 (ε) (3.34) which for the equilibrium point can be written as Rbo = I3×3 − 2S(δε) 1 2δε3 −2δε2 1 2δε1 . Rbo = −2δε3 2δε2 −2δε1 1 (3.35) (3.36) Angular velocity Using the relationship in (3.15) we get the following expression for the angular velocity of the satellite relative the ECI frame: ω bib = Rbo ω oio + ω bob (3.37) And from (3.33) one can see that ω bob = 2ε̇. Inserting this and (3.36) into equation (3.37), we get the linearized model ofω bib to be 2δ ε̇1 − 2ω0 δε3 ω bib = 2δ ε̇2 − ω0 , (3.38) 2δ ε̇3 + 2ω0 δε1 CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT 29 with its time derivative being 2δ ε̈1 − 2ω0 δ ε̇3 . 2δ ε̈2 ω̇ bib = 2δ ε̈3 + 2ω0 δ ε̇1 (3.39) Magnetic control torque From (3.24) the magnetic control torque is τ bm = S(mb )Bb . (3.40) Since our model of the local geomagnetic field, the IGRF, is expressed in the orbit frame we have that τ bm = S(mb )Rbo Bo (3.41) which in the equilibrium point is the following o Bz my − Byo mz τ bm = S(mb )Bo = Bxo mz − Bzo mx . Byo mx − Bxo my (3.42) Gravity-gradient In Busterud [22] it is shown that the expression for the gravity-gradient in (3.25) written out with quaternion parameters is 2(Iz − Iy )(ε2 ε3 + ηε1 )(1 − 2(ε21 + ε22 )) τ bg = 3ω02 2(Ix − Iz )(ε1 ε3 + ηε2 )(1 − 2(ε21 + ε22 )) , (3.43) 4(Iy − Ix )(ε1 ε1 + ηε2 )(ε2 + ηε1 ) and inserting for the equlibrium point we find (Iz − Iy )δε1 τ bg = 3ω02 (Ix − Iz )δε2 . 0 (3.44) Areodynamic torque The aerodynamic torque expression from (3.27) with ω bobeq = 0 from (3.32) inserted is b τ ba = ρa (Vrb )2 Ap S(cp )V̂r . (3.45) Further, from (3.28) and the definition of V̂r we have that b V̂r = Vbr /Vrb = (Rbo Vor )/Vrb , (3.46) CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT 30 so that when inserting for Rbo from (3.34) and using the equilibrium quaternion parameters, we get b V̂r = Vor /Vro . (3.47) Here we have also used the fact that the magnitude of the velocity vectors represented in different frames are the same in the equilibrium, Vrb = Vro . And finally we arrive at the linearized aerodynamic torque: cp2 Vro3 − cp3 Vro2 (3.48) τ ba = ρa Vro Ap cp3 Vro1 − cp1 Vro3 . cp1 Vro2 − cp2 Vro1 Linearized satellite dynamics Putting together equations (3.9), (3.42), (3.44) and (3.48), the linearized satellite dynamics becomes i h (3.49) ω̇ bib = I−1 −S(ω bib )Iω bib + τ bm + τ bg + τ ba We introduce Iy −Iz Ix , Ix −Iy Iz . (3.50) σx ω bib,y ω bib,z − I−1 S(ω bib )Iω bib = σy ω bib,x ω bib,z , σz ω bib,x ω bib,y (3.51) σx = σy = Iz −Ix Iy , σy = Now we can write the cross-product in (3.49) above as which in the equilibrium can be approximated with σx (δωy − ω0 )δωz −σx ω0 δωz ≈ . σy δωx δωz 0 − I−1 S(ω bib )Iω bib = σz δωx (δωy − ω0 ) −σz ω0 δωx Equation (3.49) written out becomes (Bzo my − Byo mz )/Ix −σx ω0 δωz + (Bxo mz − Bzo mx )/Iy 0 ω̇ bib = −σz ω0 δωx (Byo mx − Bxo my )/Iz −σx δε1 (cp2 Vro3 − cp3 Vro2 )/Ix + 3ω02 −σy δε2 + ρa Vro Ap (cp3 Vro1 − cp1 Vro3 )/Iy . 0 (cp1 Vro2 − cp2 Vro1 )/Iz (3.52) (3.53) CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT 31 Finally, when inserting for ω̇ bib from equation (3.39) and after manipulating2 one get the linearized model on component form: δ ε̈1 = (1 − σx )ω0 δ ε̇3 − 4σx ω02 δε1 + 1 (B o my − Byo mz ) 2Ix z + ρa Vro Ap (cp2 Vro3 − cp3 Vro2 )/Ix 1 δ ε̈2 = −3σy ω0 δ ε̇2 + (B o mz − Bzo mx ) 2Iy x + ρa Vro Ap (cp3 Vro1 − cp1 Vro3 )/Iy δ ε̈3 = −(1 − σx )ω0 δ ε̇1 − σz ω02 δε3 + (3.54) 1 (B o mx − Bxo my ) 2Iz y + ρa Vro Ap (cp1 Vro2 − cp2 Vro1 )/Iz 3.7.1 Linearized equations of motion For this LQR controller the ε-vector of the quaternion and its time derivative is chosen as the states, and we have the follwing state vector: x(t) = δε1 δ ε˙1 δε2 δ ε˙2 δε3 δ ε˙3 T , (3.55) with the gain vector u(t) = mx my mz T , (3.56) v(t) = Vro Vro Vro T . (3.57) and disturbance vector The linearized system represented in the state-space model form becomes ẋ(t) = Fx(t) + G(t)u(t) + D(t)v(t), y(t) = Cx(t), 2 See Appendix A.2 in [23] for complete deduction of the linearized model CHAPTER 3. SPACECRAFT DYNAMICS AND ENVIRONMENT 32 where F= 0 1 0 −4σx ω02 0 0 0 0 0 0 0 −3σy ω02 0 0 0 0 −(1 − σz )ω0 0 0 0 0 0 0 (1 − σx )ω0 1 0 0 0 0 0 0 0 1 0 −σz ω02 0 , (3.58) 0 G(t) = 0 0 0 0 Bzo (t) 2Ix −Byo (t) 2Ix Bxo (t) 2Iy 0 0 0 0 Byo (t) 2Iz −Bxo (t) 2Iz 0 −Bzo (t) 2Iy 0 0 , (cp2 Vro3 − cp3 Vro2 )/Ix D(t) = ρa Ap (cp3 Vro1 − cp1 Vro3 )/Iy . (cp1 Vro2 − cp2 Vro1 )/Iz (3.59) (3.60) Chapter 4 Magnetorquer design In the work of Tudor [44] an early prototype of the magnetorquer was designed. Since then, a whole lot of different subsystems have been designed and developed for the NUTS satellite. Most important for the magnetorquer design have been the progress in the mechanical design of the satellite’s frame. With the good help of my fellow students Christian E. Nomme and Kim Sandvik, who are currently working on the mechanical design of the frame, I’ve been able to design a more realistic magnetorquers which fit with the overall and mehanical satellite design. There’s two different designs of the magnetorquers; one for the magnetorquer placed on the z-facet and one for the two magnetorquers placed on the x- and y-facets. When working with this, the main restriction proved to be that of space available on the satellite, with other being power and energy available from the EPS and to some degree weight of the magnetorquers. Further, when designing the magnetorquers there are a few tradeoffs. Using the expression for the magnetic moment generated by the magnetorquers in (3.23), essentially m = niA, we have that we want to maximize the number of turns N , current i and area A. Thinner copper wire increases number of turns, but also the thinner the wire, the higher its resistance per meter is, and thus the current decreases. In addition, with higher amount of turns the longer the wire, and the resistance increases as well. Theres also a limit of current available from the EPS system, so it will not help very much with a very low resistance since the current will meet a roof limit. 4.1 Design specification In the EPS design done by Lars Erik Jacobsen in Jacobsen [34] each subsystem will have 300 mA accessible, which means 100 mA on each magnetorquer. How33 CHAPTER 4. MAGNETORQUER DESIGN Parameters AWG number Conductor diameter [mm] Mass [g] Mean height [mm] Mean width [mm] Mean ara [mm2 ] Cross-section height [mm] Cross-section width [mm] Number of windings Resistance [Ω] Max current in conductor [mA] Inductance [mH] Time constant [ms] Magnetic moment [Am2 ] Magnetorquer 1 AWG 31 0.226 36 165 63 10395 4 3 221 43.03 113 5.6 0.13 0.2596 34 Magnetorquer 2 AWG 31 0.226 25 77 77 5929 4 3 221 23.78 113 4.3 0.18 0.1481 Table 4.1: Table of magnetorquer parameters. ever, this is merely a current regulator on the EPS module which may be changed. Further, the EPS provides a 5V power supply and there’s 29 Wh of available energy from the battery package. The size specification are based on the mechanical drawings of the magnetorquer frames done by Christian E. Nomme, see appendix B. From this a mean area is calculated for the two different magnetorquers. The cross-sectional area specification is also found in the drawings in appendix B. In table 4.1 the magnetorquer constraints and resulting parameters are found. 4.2 Coil design The magnetorquer is basically a simple coil of winded wire around a frame. For the conductor in the coil, copper is the chosen material since it’s the most available and most of its specifics are quite known, making the design process easier. The wire evaluation were done based on the American Wire Gauge (AWG) standard, see [51]. A few different wire diameters were evaluated, and the results can be found in table 4.2. The calculations resulting in table 4.2 are based on the size of the biggest magnetorquer (for x- and y-sides), and the chosen wire is AWG 31 with diameter 0.226 mm. To find the coil’s inductance we first need to know it’s magnetic flux: √ √ 2 2nI 2 2nI Φ = BA = µ0 · A, · A = µ0 √ πd π hw (4.1) CHAPTER 4. MAGNETORQUER DESIGN Diameter [mm] Resistance [Ω/m] Max amps [mA] Turns Mass [g] Total Resistance [Ω] Magnetic moment [Am2 ] AWG 30 0.305 0.339 142 165 27 25.51 0.2436 AWG 31 0.226 0.427 113 221 36 43.03 0.2596 35 AWG 32 0.252 0.538 91 266 43 65.26 0.2119 AWG 33 0.230 0679 72 352 57 109 0.1679 Table 4.2: AWG parameters. √ where the coil length d is approximated with hw, and h and w is the coil’s height and width respectively. Now, the inductance of the biggest coil is found by the formula for a rectangular coil: √ √ nΦ 2 2n2 µ0 A 2 2 2 √ √ L= = = n µ0 hw I π π hw L ≈ 5.6 mH. (4.2) From this the coil’s time constant is found to be τ= L 5.6 = ≈ 0.13ms. R 43.03 (4.3) This is a very small inductance and thus a small time constant, and one may have reason to believe the coil’s inductance to be a bit higher. Even if one were to find the inductance to be tenfold higher than in (4.2), the time constant would be small enough that doing switching with a few seconds, or even less, is achievable. Because a magnetorquer frame hasn’t been made yet, a coil prototype haven’t been made so unfortunately measurements haven’t been done in order to verify the calculated values. A prototype coil without any frame were however made by Tudor in [44], and it worked nicely. Chapter 5 Control The main payload of the satellite, the IR camera, needs to point in the nadir direction towards the Earth in order to take pictures of the gravity waves. With our definition of the reference frames in section 2.1, the satellite will be nadir-pointing when the body and reference frames are aligned. From the work done by Snorre S. Rønning in [37], a requirement for getting any pictures at all is that the satellite attitude doesn’t deviate more 50 degrees. However, a higher accuracy is desirable. Further, the satellite while taking pictures should not drift much. Thus, even if the satellite were to deviate from the desired attitude, we would want it to be stable. This leads to the requirement that the satellite’s desired angular velocity w.r.t. the orbit frame is close to zero. The ACS requirements are summed up in table 5.1. In this chapter the control strategy and control algorithms are presented. In order to find a way of meeting the ACS requirements, different control algorithms are presented, evaluated and stability properties are found. 5.1 Control strategy After being released from the P-POD on the launch vehicle, the satellite will spin arbitrarily around its three axes. In order to be able to point the satellite at the desired attitude, its spin needs to be slown down first, i.e. detumbling is necessary. After detumbling, the satellite’s angular velocity will hopefully be close to zero Pointing accuracy [◦ deg] Angular velocity [rad/s] Roll ±25 ±1 · 10−3 Pitch ±25 ±1 · 10−3 Table 5.1: ACS requirements. 36 Yaw ±1 · 10−3 CHAPTER 5. CONTROL 37 and one can employ pointing control. The detumble algorithm presented here makes use of a measurement of the Earth’s geomagnetic field. Since the actuators are magnetic coils (magnetorquers), there’s a conflict between measuring the magnetic field surrounding the satellite and using the actuators, which will influence the magnetometer measurements. Because of this a switching strategy is suggested. What we want to do is store a sequence of the measured magnetic field, and use the estimator in 2.6.3 to estimate the time derivaˆ is the stored and used in the tive of the local geomagnetic field. This estimated Ḃ detumbling algorithm, while the magnetometer is turned off since a measurement at this stage might be disturbed and thus maybe useless. (Since the magnetometer may be a measurement being used in an attitude determination algorithm, the switching strategy is used while using all the control algorithms.) A method of emulating the switching has been implemented in the Matlab script used for simulation. One can note that one could use a strategy of feed forward from the known actuator gain in order get a measurement while using the magnetorquers, but this is outside the scope of this thesis. After detumbling the satellite, one can, as mentioned above, start pointing control. Dependent on how large the deviations away from the desired attitude are, different controller are used. Typically, with more than 20◦ deviation we want to use the nonlinear PD-like controller based on Soglo [25] and Tudor [44], and for smaller deviations the linear LQR controller based on Busterud [22], Øverby [23] and Wisniewski [14]) is preferred. 5.2 Stability requirements By using Lyaounov theory with the concepts of stability presented in section 2.7, together with energy considerations of the satellite we can find some requirements for stability. The stability analysis shown here is heavily based on the Lyapunov analysis by Soglo [25] and Tudor [44], but also adding the energy contribution from the aerodynamic torque. The energy of the system consists of kinetic and potential energy. Kinetic energy is the satellite’s translational and rotatioinal energy, while the potential energy is mainly because of gravity-gradient effects. Let’s start with the kinetic energy: 1 1 T = mb ωo2 Rc2 + (ω bib )T Iω bib 2 2 (5.1) CHAPTER 5. CONTROL 38 and when inserting for ω bib we get 1 1 1 T = mb ωo2 Rc2 + ωo2 cT2 Ic2 − ωo cT2 Iω bob + (ω bob )T Iω bob 2 2 2 (5.2) And by grouping 5.2 into T = T0 + T1 + T2 (5.3) we arrive at 1 1 T0 = mb ωo2 Rc2 + ωo2 cT2 Ic2 2 2 T b T1 = −ωo c2 Iω ob 1 T2 = (ω bob )T Iω bob 2 (5.4) (5.5) (5.6) The potential energy is dominated by the gravitational force working on the satellite caused by the Earth. We make use of Newton’s law of gravity and the following assumptions • The Earth is the only object exerting a gravitational force on the satellite. • The Earth is close to spherical and has a symmetric mass distribution. • The satellite is small compared to distance to the centre of the Earth. The potential energy exerted by the Earth on the satellite is then given by U =− µMb 1 2 3 − ωo (Ix + Iy + Iz ) + ωo2 cT3 Ic3 . Rc 2 2 (5.7) with Mb being the mass of the satellite. From [25] the Lyapunov function candidate is given by 1 3 1 1 V = (ω bob )T Iω bob + ωo2 cT3 Ic3 − ωo2 cT2 Ic2 + ωo2 (Iy − 3Iz ), 2 2 2 2 (5.8) which when evaluated in the equilibrium states ω bob = 0 and Rob = 0, and manipulated and written out on scalar form becomes 1 3 V = (ω bob )T Iω bob + ωo2 [(Ix − Iz )c213 + (Iy − Iz )c223 ] 2 2 1 2 (5.9) + ωo [(Iy − Ix )c212 + (Iy − Ix )c232 ]. 2 T If we now define a state vector x = (ω bob )T c13 c23 c12 c32 , we can find the requirements which needs to be fulfilled in order to have Lyapunov stability. From CHAPTER 5. CONTROL 39 the Lyapunov function candidate in 5.9, we see that the following requirements have to be met: Iy > Ix > Iz . When this is fulfilled, the candidate function in 5.9 is zero in the equlibrium points when the state vector equals zero. This means the satellite needs to be designed and built accordingly. To have Lyapunov stability we need to investigate the time derivative of the Lyapunov function candidate. Using the result in chapter 7 in Soglo [25], we have that the time derivative of V in 5.9 is V̇ = (ω bob )T τ bm . (5.10) This result will be further used to evaluate stabilit of the different control algorithms. 5.3 Detumbling Controller As already mentioned, one need to detumble the satellite in order to start pointing control. The detumbling controller proposed here is the B-dot controller. This is a very common detumbling controller in the small satellite litterature, and as the name implies, it makes use of the derivative of the magnetic field. This is only possible in LEO, since for higher altitudes the geomagnetic field is practically unmeasurable. The controller was first proposed by Stickler and Alfriend [52], and later improved by Wisniewski [14]: b mb = −k Ḃ , k > 0, (5.11) where mb is the magnetic control output moment, k is the positive control gain and Ḃ is the time derivative of the measured local magnetic field. The thought is, that when the satellite is spinning after launch from the P-POD, the surrounding geomagnetic field will change accordingly to the satellite’s angular velocity. Therefore, by measuring the B-field, and caluclating its time derivative and using it in the negative feedback control-law, the satellite’s energy will decrease, and thus it’s spin or angular velocity will decrease as well. Based only on measurements of the magnetic field, it doesn’t need any attitude information and is therefore quite straight forward and easy to use, hence it’s popularity. With the expression for the estimated Ḃ found in 2.32, the detumbling control law becomes ˆ b , k > 0, mb = −k Ḃ (5.12) CHAPTER 5. CONTROL 40 ˆ b is the last calculated estimation of Ḃb based on a sequence of measurewhere Ḃ ments of the magnetic field B, according to the switching strategy explained above. When decreasing the angular velocity by means of decreasing the rate of change of the magnetic field, the satellite basically behaves like a compass with three degrees of freedom, and will therefore try to align itself and follow the local geomagnetic field. It follows that the slowest angular velocity one can expect from the B-dot controller is the change of the geomagnetic field. This is indeed not very fast. When inserting this controller into the expression for the magnetic control torque τ bm , and further into the expression for the derivative of the Lyapunov finction we get h i ˆ b × Bb , k > 0 V̇ = −k(ω bob )T Ḃ (5.13) This detumbling controller clearly takes energy out of the system, and one can argue that since this controller will always try to slow the system down, it is asymptotically stable in terms of angular velocity for our case. It is, however difficult to ˆ b or Bb to be positive show analytically because we cannot guarantee that ω bob , Ḃ semi-definite. Simulations show that it is stable and will slow the satellite down and keep it close to the equilibrium of ω bob = 0. 5.4 Nonlinear controller With our main goal of the mission being to take pictures of the Earth’s atmosphere, we need to point the satellite’s camera towards the Earth. To do this a reference controller is proposed, and in this section a nonlinear reference controller will be presented. First of all, with our definition of the satellites axes in section 2.1.4, the control goal is to align the body frame with the orbit frame. This, when expressed with quaternions, means that the quaternion describing the rotation of the satellite (body) relative the orbit frame is desired to be q = [1 0 0 0]T . From the constraint property of quaternions in equation 2.17, one can see that it will be enough to make sure the ε-vector part of the quaternion is equal to zero, and we will get the desired alignment. This controller presented here is based on the works of Soglo [25] and Tudor [44]. The PD-like controller is given by τ bd = −pε − kω bob , p, k > 0 (5.14) which is found by extending the Lyapunov function candidate in equation (5.9) by using the ε-vector of the quaternions as the error measurement. After some manipulation one arrives at the controller in 5.14. This is the desired control law, hence the subscript d. For more see Soglo [25]. CHAPTER 5. CONTROL 41 This control law will always calculate a gain assuming the magnetorquers are perpendicular to the local geomagnetic field, but this willl seldom be the case. Because of this we project it down to a plane always being perpendicular to the local geomagnetic field. This way we make sure the calculated control gain is the best we can get, and we don’t use more gain effort than necessary. Further, it’s for the magnetorquers we want to calculate the gain, and the control law becomes 1 b b b mb = −p(B × ε) − k(B × ω ) (5.15) ob ||Bb || Inserting the controller in equation (5.14) into the equation for the magnetic control torque we get 1 b b b τ bm = −p(B × ε) − k(B × ω ) × Bb . (5.16) ob ||Bb || This controller is shown in [25] to be uniformly asymptotically stable. [25] also gives a gain requirement k > 8ω02 (Iy − Iz ). (5.17) 5.5 Linear-Quadratic Regulator The other reference controller to be investigated is a Linear-Quadratic Regulator (LQR). This controller makes use of the linearized satellite model found in section 3.7.1. A LQR controller is an optimal linear controller which seeks to meet some control goal while minimizing the effort it takes to achieve this. This type of controller is a popular and well documented controller to use on spacecrafts with magnetic actuation. See for example the work of Wisniewski and Blanke [13], Psiaki [17], Giesselmann [28] and Stray [29]. From its name, it is based on linearized system dynamics while defining a cost function which is to be minimized. Further, this method calculates a gain matrix based on state feedback in order to minimize the cost function. The cost function is often defined as a sum of some key states one want to minimize the deviation of. In our case this is the attitude of the spacecraft, represented by the quaternions describing the deviation between the satellite’s body frame and the orbit frame, which we want to be aligned. The quadratic cost function for the infinite-horizon LQR controller is given by Z 1 ∞ T J= [x (t)Qx(t) + uT (t)Ru(t)]dt (5.18) 2 0 where Q and R are positive semi-definite and diagonal weighting matrices. As mentioned above, in our case x is the ε-vector of the attitude quaternion, and u is the magnetic control gain. CHAPTER 5. CONTROL 42 Using the linearized system dynamics found in section 3.7.1, the solution to the cost function J is u(t) = −Kx(t), (5.19) where optimal gain matrix K is the solution of the optimal control problem, given by K = R−1 B(t). (5.20) Here, B(t) is the local geomagnetic field mesurement. Further, the soultion to equation (5.20) is found by solving the Riccati equation. The Riccati differential is used to minimalization problems with quadratic cost function, and is given by Ṗ(t) = −P(t)F − FT P(t) − Q + P(t)G(t)R−1 (t)G(t)P, (5.21) where F and G(t) is from the linearized model in section 3.7.1. P(t) converges to a stationary solution if the system is controllable or stabilizable, and we arrive at 0 = FT P + PF − PGR−1 GT P + Q. (5.22) Now we get the closed-loop system to be: ẋ = (F − GK)x(t) = Fc x(t). (5.23) We also need to mention a few words about the weighting matrices Q and R. With weighting matrices one can choose if one wishes to weigh the states x more with the matrix Q, or if one wishes to weigh the control inputs u more with the matrix R. By choosing a larger Q, one will get the poles of the closed-loop system matrix Fc will have poles further left in the s-plane, and so one will have a quicker response, but with a higher control effort (more gain/power). With a larger R on the other hand, one will experience a cheaper controller in terms of control effort, but one will get a slower response. When simulating the system with the LQR controller, the Matlab function lqr() will be used to find K; K = lqr(). This takes the linearized system matrices F and G, and the weighting matrices Q and R as inputs. It will only return a solution if the closed loop matrix Fc is Hurwitz. We have shown in section 3.5 that our system is uncontrollable. From definition 2.9 we have a stable controller if the closed-loop system matrix Fc is Hurwitz. Our closed-loop system with the optimal gain matrix K is indeed Hurwitz, so the controller is stable. Chapter 6 Simulations and Results 6.1 Simulation This chapter presents results of the numerical simulations done in Matlab. The MSS toolbox, which is a toolbox developed for marine control, have been used for all simulations because of it’s functions for calculating rotation matrices and quaternions. The parameters used in the simulations can be seen in tables 6.1 and 4.1. Further, the matlab function ode45 have been used to numerically integrate the system using the state matrix x= (ω bib )T η εT λ p T . (6.1) where λ is the satellite’s latitude, and p is the satellite’s power consumption. This R last state p si not a state wwith any impact on the system, but since p = W attdt it is practical to include it as a state in order to monitor the different control algorithms power consumptions. From this, the wattage use relates to p with p W h = 3600s . Different initial states are chosen for the different control algorithms. As Tudor’s and Soglo’s approach, it’s more intuitive to state the initial conditions with the satellites angular velocity relative the orbit frame and with the Euler angles, [ω bib φ θ ψ]. These parameters are then rotated and transformed, respectively to become ω bib , η and ε, using the functions euler2q and Rquat from the MSS toolbox. All the Matlab simulation files can be found in appendix A. The maximum internal dipole moment found is a very rough estimate based loosely on how much current each module can use at any time, from [34]. 43 CHAPTER 6. SIMULATIONS AND RESULTS Parameters Mass [kg] Size [mm] Moments of inertia [kgm2 ] Voltage [V] Maximum current [mA] Maximum magnetic moment [Am2 ] Maximum aerodynamic torque [Nm] Maximum solar radiation torque [Nm] Maximum internal dipole moment [Am2 ] Desired Euler angles [deg] Desired angular velocity [rad/s] 44 Value 2.6 100 × 100 × 200 Ix = 0.33, Iy = 0.33002, Iz = 0.11 5 113 0.2596 1.977 · 10−8 4.124 · 10−9 7.2 · 10−4 φ = 0, θ = 0, ψ = 0 ω bob = 0 Table 6.1: Table of simulation parameters. 6.2 6.2.1 Results Magnetometer measurement filters The results after simulating the different magnetometer measurement filters from section 2.6 are presented here. All the testing of the filters have been done in the detumbling phase, since the change in measured geomagnetic fiekd is expected to be greatest here. Low-pass filter Here are results of the low-pass filter from section 2.6.1, used for the measured local geomagnetic field. B̂k = a1 B̂k−1 + b1 Bk . (6.2) The plots of the results can be seen in figures 6.1 and 6.2. Numerical differentiator Here are results of the numerical differentiator from section 2.6.2 used for the measured local geomagnetic field. ˆ = Bk+1 − Bk−1 . Ḃ k 2∆t The plots of the results can be seen in figures 6.3 and 6.4. (6.3) CHAPTER 6. SIMULATIONS AND RESULTS 45 Figure 6.1: Plot of low-pass filter for geomagnetic measurements. Estimator Here are results of the estimator from section 2.6.3 used to estimate the derivative of the measured local geomagnetic field. ˆ = a Ḃ ˆ Ḃ 2 k−1 + b2 (Bk − Bk−1 ) k (6.4) The plots of the results can be seen in figures 6.5 and 6.6. 6.2.2 Detumbling Simulation of the detumbling controller, with all disturbance torques included. The detumble control law was found in section 5.3 and is given by: ˆ b, k > 0 mb = −k Ḃ (6.5) and is using the estimated value of the derivative of the measured local geomagnetic field. The control law results in the control torque k ˆ b τ bm = − b Ḃ × Bb . (6.6) ||B || CHAPTER 6. SIMULATIONS AND RESULTS 46 Figure 6.2: Zoomed plot of low-pass filter for geomagnetic measurements. The control gain used in 6.6 is d = 4 · 10−5 . The initial values for detumbling can be seen in table 6.2. The results of the simulations of the detumbling controller can be seen in figures 6.7 and 6.8, depicting the angular velocity of the satellite w.r.t. to the orbit frame and the power consumption of the controller, respectively. The total disturbance torques from section 3.6 are: τ bd = τ bg + τ ba + τ bs + τ bm,d , and can be seen in figure 6.9. ω bob φ θ ψ λ p = = = = = = [0.1 − 0.2 0.1]T 180◦ 30◦ −75◦ 0◦ 0J Table 6.2: Initial values for the detumbling simulations. (6.7) CHAPTER 6. SIMULATIONS AND RESULTS 47 Figure 6.3: Plot of the numerical differentiation by central difference method for geomagnetic measurements 6.2.3 Nonlinear control Here the simulations using the nonlinear reference controller from section 5.4 is presented. The control law is: 1 b b b −p(B × ε) − k(B × ω ) × Bb . (6.8) τ bm = ob ||Bb || In the following subsections the results of using the controller when subjected to different disturbance torques is presented. Gravity gradient as only disturbance The nonlinear reference controller simulated with gravity-gradient torques as only disturbance torque is presented here. In figures 6.10 and 6.11 one can see plots of the satellite’s roll, pitch and yaw angles, and the controller’s power consumption, respectively. The gravity-gradient torque can be seen in figure 6.12. The control gains used in here is p = 3 · 10−9 and k = 6 · 10−6 . CHAPTER 6. SIMULATIONS AND RESULTS 48 Figure 6.4: Zoomed plot of the numerical differentiation by central difference method for geomagnetic measurements The initial values for the nonlinear reference controller simulations with only gravitygradient disturbance can be seen in table 6.3. The angular velocity initial values are the final values from the detumble controller. Gravity-gradient and aerodynamic disturbance torques The nonlinear reference controller simulated with gravity-gradient and aerodynamic torques is presented here. In figures 6.13 and 6.14 one can see plots of the satellite’s roll, pitch and yaw angles, and the controller’s power consumption, respectively. The aerodynamic torque can be seen in figure 6.15. The control gains used in here is p = 1.5 · 10−9 and k = 6 · 10−6 . The initial values for the nonlinear reference controller simulations with gravitygradient and aerodynamic disturbances can be seen in table 6.4. The angular velocity initial values are the final values from the detumble controller. CHAPTER 6. SIMULATIONS AND RESULTS 49 Figure 6.5: Plot of the digital estimator used for geomagnetic measurements Gravity-gradient, aerodynamic and solar disturbance torques The nonlinear reference controller simulated with gravity-gradient, aerodynamic and solar disturbance torques is presented here. In figures 6.16 and 6.17 one can see plots of the satellite’s roll, pitch and yaw angles, and the solar radiation disturbance torque, respectively. The control gains used in here is p = 1.5 · 10−9 and k = 6 · 10−6 . The initial values for the nonlinear reference controller simulations with gravitygradient, aerodynamic and disturbances can be seen in table 6.5. The angular veω bob φ θ ψ λ p = = = = = = [0.001056 0.000722 − 0.000339]T 180◦ 30◦ −75◦ 0◦ 0J Table 6.3: Initial values for the nonlinear reference controller simulations with only gravity-gradient disturbance. CHAPTER 6. SIMULATIONS AND RESULTS 50 Figure 6.6: Zoomed plot of the digital estimator used for geomagnetic measurements locity initial values are the final values from the detumble controller. Nonlinear control with integral action The simulation of the nonlinear reference controller with integral action is presented here. When adding more disturbance torques than the gravity-gradient it’s apparent that we get a constant deviation. The reason for this is that when adding e.g. aerodynamic torque, after the satellite’s spin is decreased we get a more or less ω bob φ θ ψ λ p = = = = = = [0.001056 0.000722 − 0.000339]T 180◦ 30◦ −75◦ 0◦ 0J Table 6.4: Initial values for the nonlinear reference controller simulations with gravity-gradient and aerodynamic disturbances. CHAPTER 6. SIMULATIONS AND RESULTS 51 Figure 6.7: Plot of angular velocity ω bob after detumbling. constant disturbance effect, see figure 6.15. Hence the equlibrium of the satellite is now shifted and we get a steady-state offset as a result. Because of this the nonlinear controller in 5.14 were augmented with integral action in an attempt to get rid of the offset. (6.9) τ bd = −pε − kω bob − iεe , p, k, i > 0 where εe is the accumulated error of the ε-vector of the quaternion describing the satellites position w.r.t. to the orbit frame. Because of the quaternion properties from equation (2.17), and since the desired attitude quaternion is q = [1 0 0 0]T , ω bob φ θ ψ λ p = = = = = = [0.001056 0.000722 − 0.000339]T 20◦ 20◦ 20◦ 0◦ 0J Table 6.5: Initial values for the nonlinear reference controller simulations with gravity-gradient, aerodynamic and solar disturbances. CHAPTER 6. SIMULATIONS AND RESULTS 52 Figure 6.8: Plot of energy and power consumption after detumbling. we get that the quaternion error (or rather the "epsilon"-error) is given by Z εe = εdt. (6.10) The system is simulated with the nonlinear reference controller augmented with integral action, and with gravity-gradient and aerodynamic disturbance torues, in order to have an offset to remove. In figures 6.18 one can see plots of the satellite’s roll, pitch and yaw angles when the integral gain equals i = 1 · 10−12 . In figure 6.19 one can see the same, but now with an integral gain of i = 5 · 10−11 . The other two gains are p = 1.5 · 10−9 and k = 6 · 10−6 . The initial values for the nonlinear reference controller augmented with integral action, and with gravity-gradient and aerodynamic disturbances can be seen in table 6.6. The angular velocity initial values are the final values from the detumble controller. CHAPTER 6. SIMULATIONS AND RESULTS 53 Figure 6.9: Plot of total disturbance torques while detumbling. ω bob φ θ ψ λ p = = = = = = [0.001056 0.000722 − 0.000339]T 180◦ 30◦ −75◦ 0◦ 0J Table 6.6: Initial values for the nonlinear reference controller simulations with integral action. CHAPTER 6. SIMULATIONS AND RESULTS 54 Figure 6.10: Plot of the Euler angles after nonlinear control, gravity as only disturbance. CHAPTER 6. SIMULATIONS AND RESULTS 55 Figure 6.11: Plot of energy and power consumption after nonlinear control, gravity as only disturbance. CHAPTER 6. SIMULATIONS AND RESULTS 56 Figure 6.12: Plot of gravity-gradient torques while simulating nonlinear reference controller. CHAPTER 6. SIMULATIONS AND RESULTS 57 Figure 6.13: Plot of the Euler angles after nonlinear control, with gravity and aerodynamic disturbance torques. CHAPTER 6. SIMULATIONS AND RESULTS 58 Figure 6.14: Plot of energy and power consumption after nonlinear control, with gravity and aerodynamic disturbance torques. CHAPTER 6. SIMULATIONS AND RESULTS 59 Figure 6.15: Plot of the aerodynamic disturbance torques while simulating nonlinear control. CHAPTER 6. SIMULATIONS AND RESULTS 60 Figure 6.16: Plot of the Euler angles after nonlinear control, with gravity, aerodynamic and solar disturbance torques. CHAPTER 6. SIMULATIONS AND RESULTS 61 Figure 6.17: Plot of the solar disturbance torques while simulating nonlinear control, with gravity, aerodynamic and solar disturbance torques. CHAPTER 6. SIMULATIONS AND RESULTS 62 Figure 6.18: Plot of the Euler angles after nonlinear control with integral action, i = 1 · 10−12 . 6.2.4 Optimal control Here the simulations using the optimal LQR reference controller from section 5.5 is presented. In the following subsections the results of using the controller when subjected to different disturbance torques is presented. Gravity-gradient as only disturbance The LQR reference controller simulated with gravity-gradient torques as only disturbance torque is presented here. The initial values for the optimal LQR controller with gravity-gradient as only disturbance can be seen in table 6.7. The angular velocity initial values are the final values from the detumble controller. The roll, pitch and yaw initial values are the final values after using the nonlinear controller with gravity-gradient and aerodynamic disturbance torques from figure 6.13 in section 6.2.3. In figures 6.20 and 6.21 one can see plots of the satellite’s roll, pitch and yaw angles, and the controller’s power consumption, respectively. CHAPTER 6. SIMULATIONS AND RESULTS 63 Figure 6.19: Plot of the Euler angles after nonlinear control with integral action, i = 5 · 10−11 . Gravity-gradient and aerodynamic disturbance torques The LQR reference controller simulated with gravity-gradient and aerodynamic torques is presented here. The initial values for the optimal LQR controller with gravity-gradient and aerodynamic disturbances can be seen in table 6.8. The angular velocity initial values are the final values from the detumble controller. The roll, pitch and yaw initial values are picked to be close to the equilibrium, this being a linear controller. ω bob φ θ ψ λ p = = = = = = [0.001056 0.000722 − 0.000339]T −20◦ 20◦ 130◦ 0◦ 0J Table 6.7: Initial values for the optimal LQR reference controller simulations with gravity-gradient as only disturbance. CHAPTER 6. SIMULATIONS AND RESULTS 64 Figure 6.20: Plot of the Euler angles after optimal control, gravity as only disturbance. In figures 6.22 one can see plot of the satellite’s roll, pitch and yaw angles. ω bob φ θ ψ λ p = = = = = = [0.001056 0.000722 − 0.000339]T 5◦ −9◦ 6◦ 0◦ 0J Table 6.8: Initial values for the optimal LQR reference controller simulations with gravity-gradient and aerodynamic disturbances. CHAPTER 6. SIMULATIONS AND RESULTS 65 Figure 6.21: Plot of energy and power consumption after optimal control, gravity as only disturbance. CHAPTER 6. SIMULATIONS AND RESULTS 66 Figure 6.22: Plot of the Euler angles after optimal control, with gravity and aerodynamic disturbance torques. Chapter 7 Discussion and Conclusion 7.1 Discussion All the filters; the low-pass filter, the central difference method for numerical differentiation and the estimator worked nicely, and since they were being tested with a higher noise than can be expected from the magnetometer to be used, i think it is safe to say they all gave satisfactory results. The detumbling controller worked satisfactory as well, and so did the nonlinear reference controller to a certain degree. When subjected to more than only the gravity-gradient torques, the nonlinear controller didn’t meet the desired angles. However, with aerodynaic torques added it were able to settle the satellite with an offset for the roll, pitch and yaw angles of about -20, 20 and 130 degrees, respectively. Since the last angle, the yaw, is the angle about the z-axis, this doesn’t have an impact on wether or not we’re able to take a picture of the Earth, as long as it’s stable at that angle - which it is. From [37] it is argued that with an offset of less than 50 degrees, one is still able to take good pictures of the Earth’s atmosphere with the infrared camera. When adding more disturbances, the solar radiation torque, the controller didn’t work and weren’t able to stabilize the satellite at any angle. The attempt with integral action augmentation of the nonlinear controller proved to be unsatisfactory as well. The optimal LQR regulator worked nicely when only being subjected to gravitygradient torques, and also gave good results with rather high initial roll, pitch and yaw values. When adding aerodynamic torques, it failed. 67 CHAPTER 7. DISCUSSION AND CONCLUSION 7.2 68 Conlusion A low pass filter for magnetometer measurements were found to be working satisfactory. As for finding the derivative of the local geomagnetic field, the estimator is suggested. This is because if one were to use the numerical differentiator, its necessary to filter the measurement first, and this will take too much time. The detumbling controller worked still when being subjected to all the disturbance torques, and managed to settle the satellite at an angular velocity very close to zero. The detumbling controller utilizing the estimated value of the derivative of the local geomagnetic field can be said to work as fine as the one found by Tudor [44]. The nonlinear controller worked well with gravity-gradient as the only disturbance, but with aerodynamic disturbance torques there were a ste, and even more when solar radiation torques were included. However, it can be used since one can still take pictures of the Earth’s atmosphere with a 20 degrees deiation in roll and pitch, and yaw does not have an impact of the picture to be taken as long as it doesn’t drift. Integral action were tried out in an attempt to remove the deviatioins, but it was unsuccessfull. The optimal LQR controller worked well with gravity-gradient as the only disturbance as well, but with aerodynamic disturbance torques the results were unsatisfactory. To use the proposed detumbling algorithm first and then the nonlinear controller for big deviations in order to be able to use the optimal LQR controller, can not be said to guarantee good results. The suggestion is to use the detumbling controller with the estimated B-dot as proposed, with the nonlinear PD-like controller, and maybe see if there can be done some mmore investigations on methods to remove the steady-state offset when subjected to disturbance torques. If anything, it have been pointed out that no matter how small any disturbance torque is, since every force and torque acting on a satellite in space is very small, it has an impact and consequences. Bibliography [1] http://hincube.hin.no. The HiNCube project webpage. [2] http://www.cubestar.no/. The CubeSTAR webpage. [3] http://www.rocketrange.no/?page_id=254. The ANSAT program webpage. [4] “Cubesat design specification rev. http://www.cubesat.org/images/developers/cds_rev12.pdf, 2011. 12.” [5] R. Brikeland, “NUTS-1 Mission Statement,” 2011. [6] http://nuts.cubesat.no/. The NUTS project webpage. [7] J. White, F. Shigemoto, and K. Bourquin, “Satellite attitude control utilizing the earth’s magnetic field,” tech. rep., DTIC Document, 1961. [8] J. Wen and K. Kreutz-Delgado, “The attitude control problem,” Automatic Control, IEEE Transactions on, vol. 36, no. 10, pp. 1148–1162, 1991. [9] M. Pittelkau, “Optimal periodic control for spacecraft pointing and attitude determination,” Journal of Guidance Control Dynamics, vol. 16, pp. 1078– 1084, 1993. [10] Y. Chen and S. Lo, “Sliding-mode controller design for spacecraft attitude tracking maneuvers,” Aerospace and Electronic Systems, IEEE Transactions on, vol. 29, no. 4, pp. 1328–1333, 1993. [11] W. Steyn, “Fuzzy control for a non-linear mimo plant subject to control constraints,” Systems, Man and Cybernetics, IEEE Transactions on, vol. 24, no. 10, pp. 1565–1571, 1994. [12] R. Wisniewski and M. Blanke, “Three-axis satellite attitude control based on magnetic torquing,” in 13th IFAC World Congress, pp. 1–36, Citeseer, 1996. [13] R. Wisniewski and M. Blanke, “Fully magnetic attitude control for spacecraft subject to gravity gradient,” Automatica, vol. 35, no. 7, pp. 1201–1214, 1999. 69 BIBLIOGRAPHY 70 [14] R. Wisniewski, “Satellite attitude control using only electromagnetic actuation,” Department of Control Engineering, Aalborg University, 1996. [15] P. Wang, Y. Shtessel, and Y. Wang, “Satellite attitude control using only magnetic torquers,” in AIAA Guidance, Navigation, and Control Conference and Exhibit, Boston, USA, 1998. [16] R. Wisniewski, “Linear time-varying approach to satellite attitude control using only electromagnetic actuation,” Journal of Guidance Control and Dynamics, vol. 23, no. 4, pp. 640–647, 2000. [17] M. Psiaki, “Magnetic torquer attitude control via asymptotic periodic linear quadratic regulation,” Journal of Guidance, Control, and Dynamics, vol. 24, no. 2, pp. 386–394, 2001. [18] M. Lovera and A. Astolfi, “Spacecraft attitude control using magnetic actuators,” Automatica, vol. 40, no. 8, pp. 1405–1414, 2004. [19] E. Silani and M. Lovera, “Magnetic spacecraft attitude control: a survey and some new results,” Control Engineering Practice, vol. 13, no. 3, pp. 357–371, 2005. [20] R. Kristiansen, “Attitude control of a microsatellite,” Master’s thesis, Department of Engineering Cybernetics (ITK), Norwegian University of Science and Technology (NTNU), Trondheim, Norway, 2000. [21] K. Fauske, “Attitude stabilization of an underactuated rigid spacecraft,” Master’s thesis, Department of Engineering Cybernetics (ITK), Norwegian University of Science and Technology (NTNU), Trondheim, Norway, 2003. [22] B. Busterud, “Orienteringsregulering av mikrosatellitter,” Master’s thesis, Norwegian University of Science and Technology, 2003. [23] E. Øverby, “Attitude control for the norwegian student satellite ncube,” Norwegian University of Science and Technology. Department of Engineering Cybernetics, 2004. [24] E. Narverud, R. Birkeland, and E. K. Holm, “Design of small student satellite,” Project work. [25] P. Soglo, “3-aksestyring av gravitasjonsstabilisert satellitt ved bruk av magnetspoler,” Master’s thesis, Department of Engineering Cybernetics (ITK), Norwegian University of Science and Technology (NTNU), Trondheim, Norway, 1994. [26] K. L. Makovec, “A nonlinear magnetic controller for three-axis stability of nanosatellites,” Master’s thesis, Faculty of the Virginia Polytechnic Institute and State University, 2001. BIBLIOGRAPHY 71 [27] B. Ø. Andresen, C. Grøn, R. H. Knudsen, C. Nielsen, K. K. Sørensen, and D. Taagaard, “Attitude Control System for AAUSAT-II,” Master’s thesis, Aalborg University, 2005. [28] J. Giesselmann, “Development of an active magnetic attitude determination and control system for picosatellites on highly inclined circular low earth orbits,” Master of Engineering RMIT University, 2006. [29] F. Stray, “Attitude control of a nano satellite,” Master’s thesis, University of Oslo, 2010. [30] K. Rensel, “An attitude detumbling system for the cubestar nano satellite,” Master’s thesis, University of Oslo, 2011. [31] M. L. Volstad, “Internal data bus of a small student satellite,” Master’s thesis, Norwegian University of Science and Technology (NTNU), Trondheim, Norway, 2011. [32] D. E. Holmstrøm, “Software and software architecture for a student satellite,” 2011. Project report at the Norwegian University of Science and Technology (NTNU), Trondheim, Norway. [33] D. de Bruyn, “Power distribution and conditioning for a small student satellite design of the nuts backplane & eps module,” Master’s thesis, Norwegian University of Science and Technology (NTNU), Trondheim, Norway, 2011. [34] L. E. Jacobsen, “Electrical power system of the ntnu test satellite.,” Master’s thesis, Norwegian University of Science and Technology, Department of Electronics and Telecommunications, 2012. [35] S. Marholm, “Antenna systems for nuts,” Master’s thesis, Norwegian University of Science and Technology (NTNU), Trondheim, Norway, 2012. [36] V. Visockas, “Access control and securing of the nuts uplink,” 2011. Project report at the Norwegian University of Science and Technology (NTNU), Trondheim, Norway. [37] S. S. Rønning, “Optimizing an infrared camera for observing of atmospheric gravity waves from a cubesat platform,” Master’s thesis, Norwegian University of Science and Technology, 2012. [38] E. Meland, “Internal wireless bus in student satellite experiment,” 2011. Project report at the Norwegian University of Science and Technology (NTNU), Trondheim, Norway. [39] K. I. M. Rokstad, “Investigation of using composite materials for the cubesat primary structure,” in European Cubesat Symposium, Brussels, February 2012, 2012. BIBLIOGRAPHY 72 [40] B. H. Stenhaug, “Antenna system for a ground station communicating with the ntnu test satellite (nuts),” Master’s thesis, Norwegian University of Science and Technology (NTNU), Trondheim, Norway, 2011. [41] K. L. Jenssen and K. H. Yabar, “Development, implementation and testing of two attitude estimation methods for cube satellites,” Master’s thesis, Department of Engineering Cybernetics (ITK), Norwegian University of Science and Technology (NTNU), Trondheim, Norway, 2011. [42] T. B. Rinnan, “Development and comparison of estimation methods for attitude determination,” Master’s thesis, Department of Engineering Cybernetics (ITK), Norwegian University of Science and Technology (NTNU), Trondheim, Norway, 2012. [43] F. S. Holberg, “Design of attitude estimation and control system for a cube satellite,” Master’s thesis, Department of Engineering Cybernetics (ITK), Norwegian University of Science and Technology (NTNU), Trondheim, Norway, 2012. [44] Z. Tudor, “Design and implementation of attitude control for 3-axes magnetic coil stabilization of a spacecraft,” Master’s thesis, Department of Engineering Cybernetics (ITK), Norwegian University of Science and Technology (NTNU), Trondheim, Norway, 2011. [45] F. S. Holberg, “Optimal attitude control of a double cubesat using magnetorquers,” Project report at the Norwegian University of Science and Technology (NTNU), Trondheim, Norway. [46] G. Bråthen, “Nonlinear attitude control of a double cubesat using magnetorquers,” 2011. Project report at the Norwegian University of Science and Technology (NTNU), Trondheim, Norway. [47] O. Egeland and J. Gravdahl, Modeling and simulation for automatic control. Marine Cybernetics, 2002. [48] “3-Axis Digital Compass IC HMC5983.” http://www51.honeywell.com/aero/ common/documents/myaerospacecatalog-documents/Defense_Brochuresdocuments/HMC5983_3_Axis_Compass_IC.pdf. HMC5983 Magnetometer Datasheet. [49] H. Khalil, Nonlinear systems. Prentice hall New Jersey, 3rd ed., 2002. [50] J. Davis, “Mathematical modeling of earth’s magnetic field,” Technical Note, Virginia Tech, Blacksburg, 2004. [51] “American Wire Gauge.” http://www.powerstream.com/Wire_Size.htm. BIBLIOGRAPHY 73 [52] A. Stickler and K. Alfriend, “An elementary magnetic attitude control system,” in American Institute of Aeronautics and Astronautics, Mechanics and Control of Flight Conference, Anaheim, Calif, Research supported by ITHACO, Inc. and NASA, vol. 5, 1974. [53] M. Bakken, “Signal processing for communicating gravity wave images from the ntnu test satellite,” Master’s thesis, Norwegian University of Science and Technology (NTNU), Trondheim, Norway, 2012. [54] K. Fauske, “Ncube attitude control,” 2002. Project report at the Norwegian University of Science and Technology (NTNU), Trondheim, Norway. [55] B. Gregory, “Attitude control system design for ion, the illinois observing nanosatellite,” Master’s thesis, University of Illinois, 2004. [56] P. Hughes and P. Carlisle, Spacecraft attitude dynamics. J. Wiley, 1986. [57] T. Kane, P. Likins, and D. Levinson, Spacecraft dynamics, vol. 1. New York, McGraw-Hill Book Co, 1983. [58] S. Marshall and G. Skitek, Electromagnetic concepts and applications, vol. 10. Prentice-Hall, 1990. [59] K. Musser and W. Ebert, “Autonomous spacecraft attitude control using magnetic torquing only,” in NASA, Goddard Space Flight Center, Flight Mechanics/Estimation Theory Symposium, 1989 p 23-38(SEE N 90-13413 05-13), 1989. [60] B. Vik, “Integrated satellite and inertial navigation systems,” Department of Engineering Cybernetics, NTNU, 2009. [61] J. Wertz and W. Larson, Space mission analysis and design. Microcosm, 1999. Appendix A Matlab Code %************************************************************************ % F i l e main . m % Main s c r i p t . C o n t a i n s t h e f o l l o w i n g s e c t i o n s : % % − Simulate ( i n t e g r a t e ) system % − Estimate the d e r i v a t i v e of the geomagnetic f i e l d ( the B f i e l d ) % % W r i t t e n by Zdenko Tudor , 2 0 1 1 . E d i t e d by Gaute B r å t h e n , 2 0 1 2 . %************************************************************************ clear all ; close all ; clc ; a d d p a t h ( ’myIGRF ’ ) ; % I n i t i a l i z e s t o r a g e v a r i a b l e s ( For t e s t i n g and p l o t t i n g p u r p o s e s o n l y ) g l o b a l VAR Btime B c n t B f i l t Bdot p a r t _ s u m t a u _ a t a u _ s t a u _ d R_B_O ; % p a r t _ % Bdot = [ ] ; % C o u n t e r s and g l o b a l v a r i a b l e s u s e d t o s a v e t h e " m e a s u r e d " B f i e l d and B d % t o be u s e d a s i n p u t t o c o n t r o l law cnt = 0; Bcnt = [0 1 ] ; B f i l t = zeros ( 3 , 1 ) ; Bdot = z e r o s ( 3 , 1 ) ; part_sum = zeros ( 1 , 3 ) ; % part_sum2 = part_sum ; tau_a = zeros ( 3 , 1 ) ; tau_s = zeros ( 3 , 1 ) ; tau_d = zeros ( 3 , 1 ) ; 74 APPENDIX A. MATLAB CODE 75 % Create parameters s t r u c t P = parameters ( ) ; % Load n e c c e s s a r y p a r a m e t e r s orbitPeriod = P. orbitPeriod ; scalePlot = P. scalePlot ; % I n i t i a l and s i m u l a t i o n p a r a m e t e r s numOfOrbits = 3 . 5 ; tSpan = [ 0 , o r b i t P e r i o d * numOfOrbits ] ; % tSpan = [0 ,20]; Btime = 0 ; % For d e f i n i n g s i m u l a t i o n l e n g t h % For x−a x e s s c a l i n g when p l o t t i n g % S i m u l a t i o n t i m e i n number o f o r % Time s p a n f o r ODE45 % For t e s t i n g h i g h e r s a m p l i n g r a t e % w_B_OB = [ 0 . 1 ; − 0 . 2 ; 0 . 1 ] ; % Initial rotational veloci w_B_OB = [ 0 . 0 0 1 0 5 6 ; 0 . 0 0 0 7 2 2 ; − 0 . 0 0 0 3 3 9 ] ; % 0.0019;0.0006; −0.0007 % 0.000 0.001056;0.000722; −0.000339 eulAng = [ 2 0 ; 2 0 ; 2 0 ] ; %[ 1 8 0 ; 3 0 ; − 7 5 ] ; % [ 2 0 ; 2 0 ; 2 0 ] ; [ − 2 0 ; 2 0 ; 1 3 0 ] ; % Initial orientation % eulAng = [5; −9;6]; % [ w_B_IB_tudor , ~ ] = e u l 2 q u a ( P , w_B_OB ’ , eulAng ’ ) % Transform i n i t i a l pa qua = e u l e r 2 q ( eulAng ( 1 ) * p i / 1 8 0 , eulAng ( 2 ) * p i / 1 8 0 , eulAng ( 3 ) * p i / 1 8 0 ) ; R = R q u a t ( qua ) ; w_B_IB = R*w_B_OB ; i n i t L a t = 0; % Initial latitude i n i t J o u l e = 0; % A l w a y s t o be s e t t o z e r o i n i t _ e = [0 0 0] ’; % I n i t i a l error % S t a t e v e c t o r x = [ wx wy wz e t a e p s 1 e p s 2 e p s 3 l a t i t u d e t o t a l J o u l e ] ; x I n i t = [ w_B_IB ; qua ; i n i t L a t ; i n i t J o u l e ; i n i t _ e ] ; % ODE45 s i m u l a t o n s e t t i n g s o p t i o n s = o d e s e t ( ’ MaxStep ’ , 1 , ’ O u t p u t F c n ’ , @outFcn , ’ R e f i n e ’ , 1 ) ; % % o p t i o n s = o d e s e t ( ’ MaxStep ’ , 0 . 1 , ’ OutputFcn ’ , @outFcn , ’ R e l T o l ’ , 1 e −5 , ’ AbsTo % Simulate system tic [ t o u t , y o u t ] = ode45 (@( t , x ) n o n l i n e a r S a t e l l i t e _ e d i t ( t , x , P ) , t S p a n , x I n i t , o p t i o toc plots (); %************************************************************************ APPENDIX A. MATLAB CODE 76 % F i l e n o n l i n e a r S a t e l l i t e .m % % xDot = n o n l i n e a r S a t e l l i t e ( T , X , P ) % % S i m u l a t e s t h e e a r t h − s a t e l l i t e s y s t e m . To be u s e d w i t h an o r d i n a r y % d i f f e r e n t i a l e q u a t i o n s o l v e r s u c h a s MATLAB’ s Runge K u t t a ( 4 , 5 ) method , % ODE45 . % The i n p u t : % T − time vector ( i m p l i c i t ) % X − s t a t e v e c t o r , i n i t i a l s t a t e h a s t o be p r o v i d e d . The s t a t e v e c t o r i s % o f t h e f o r m X = [W^ B_IB ’ Q’ LAMBDA JOULE ] . W^ B_IB i s a 3 x1 v e c t o r % c o n t a i n i n g t he t h r e e r o t a t i o n a l v e l o c i t y components . Q i s t he q u a t e r n i o n % v e c t o r o f t h e f o r m Q = [ e t a e p s 1 e p s 2 e p s 3 ] . LAMBDA i s t h e l a t i t u d e o f % t h e s a t e l l i t e and JOULE i s o n l y a t e s t i n g p a r a m e m t e r w h i c h w i l l r e t u r n % the t o t a l Joule consumption of the s a t e l l i t e during the s im u la ti on . % I n i t i a l JOULE s h o u l d a l w a y s be s e t t o z e r o . % P − s t r u c t c o n t a i n g n e c e s s a r y p a r a m e t e r s ( w_o , I , Rc , c o i l d a t a , v o l t a g % and c u r r e n t r a t i n g s ) . % % Example : % [TOUT , YOUT] = ode45 (@( t , x ) n o n l i n e a r S a t e l l i t e ( t , x , P ) , t S p a n , x I n i t , o p t i o n s % t h i s produces : % TOUT − t i m e v e c t o r f o r t h e i n t e g r a t i o n % YOUT − I n t e g r a t e d xDot v e c t o r f o r e a c h t i m e s t e p s i z e ( YOUT)= l e n g t h ( TOUT ) % % W r i t t e n by Zdenko Tudor , 2 0 1 1 . E d i t e d by Gaute B r å t h e n , 2 0 1 2 . %************************************************************************ f u n c t i o n xDot = n o n l i n e a r S a t e l l i t e _ e d i t ( t , x , P ) g l o b a l R_B_O tmpVAR VAR p Btime B c n t B f i l t Bdot ; % t a u _ a t a u _ s t a u _ d ; % tic % Load n e c e s s a r y p a r a m e t e r s f r o m P s t r u c t . w_o = P . w_o ; I = P. I ; J = P. J ; A_drag = P . A_drag ; rho_a = P . rho_a ; vel = P . vel ; s_const = P . s_const ; d_const = P . d_const ; % Normalization of quartenions x ( 4 : 7 ) = x ( 4 : 7 ) . / norm ( x ( 4 : 7 ) ) ; APPENDIX A. MATLAB CODE % State vector x = []; w_B_IB = x ( 1 : 3 ) ; eta = x (4); eps = x ( 5 : 7 ) ; lat = x(8); % e = x (10:12); % e_tmp = e ; % tmpVAR . e = e ; satLimit1 = 400; satLimit2 = 400; 77 % % % % Angular v e l o c i t y Euler parameter Euler parameter Lambda % The i n t e g r a t e d vector eta epsilon error of epsilon % Storing integral of error % Saturation limit for integral action % Saturation limit for integral action % e u l = q 2 e u l e r ( [ e t a eps ’ ] ) ; % A n t i −wind up scheme . S e t t o a p r e s e t l i m i t i f e r r o r i s o v e r t h e l i m i t , % and s e t t o z e r o i f e r r o r i s s m a l l ( i n e f f e c t , d o n t u s e i n t e g r a l a c t i o n ) i f p >1 i f abs (VAR. e ( p , 1 ) ) > s a t L i m i t 1 VAR. e ( p , 1 ) = s a t L i m i t 1 * s i g n (VAR. e ( p , 1 ) ) ; %z e r o s ( s i z e ( VAR . e ) ) ; end i f abs (VAR. e ( p , 2 ) ) > s a t L i m i t 2 VAR. e ( p , 2 ) = s a t L i m i t 2 * s i g n (VAR. e ( p , 2 ) ) ; end i f abs (VAR. e ( p , 3 ) ) > s a t L i m i t 2 VAR. e ( p , 3 ) = s a t L i m i t 2 * s i g n (VAR. e ( p , 3 ) ) ; end i f abs ( e p s ( 1 ) ) < 0 . 1 VAR. e ( p , 1 ) = 0 ; end i f abs ( e p s ( 2 ) ) < 0 . 0 5 VAR. e ( p , 2 ) = 0 ; end i f abs ( e p s ( 3 ) ) < 0 . 1 VAR. e ( p , 3 ) = 0 ; end e_tmp = VAR. e ( p , : ) ’ ; tmpVAR . e = e p s * (VAR. t ( p)−VAR. t ( p − 1 ) ) ; APPENDIX A. MATLAB CODE 78 else e_tmp = z e r o s ( 3 , 1 ) ; tmpVAR . e = e_tmp ; end % E p s i l o n c r o s s m a t r i x , skew−s y m m e t r i c S _ e p s = [ 0 , −e p s ( 3 ) , e p s ( 2 ) ; e p s ( 3 ) , 0 , −e p s ( 1 ) ; −e p s ( 2 ) , e p s ( 1 ) , 0 ] ; % Rotation matrices R_O_B = e y e ( 3 ) + 2 * e t a * S _ e p s + 2 * S _ e p s ^ 2 ; R_B_O = R_O_B ’ ; % Angular v e l o c i t i e s o f frames r e l a t i v e each o t h e r w_O_IO = [0; − w_o ; 0 ] ; w_B_OB = w_B_IB−R_B_O * w_O_IO ; % w_B_OB = w_B_OB + 200 e −9. * r a n d n ( s i z e ( w_B_OB ) ) ; % A d d i n g n o i s e ( N o i s e f l o tmpVAR . omega = w_B_OB ; % S t o r i n g / s a v i n g t h e " m e a s u r e d " a n g u l a r v e l o c i t y % % w_B_OB c r o s s m a t r i x , skew−s y m m e t r i c % S_w_B_OB = [ 0 , −w_B_OB ( 3 ) , w_B_OB ( 2 ) ; % w_B_OB ( 3 ) , 0 , −w_B_OB ( 1 ) ; % −e p s ( 2 ) , w_B_OB ( 1 ) , 0 ] ; % % % % % % % F i l t e r i n g t h e a n g u l a r v e l o c i t y w_B_OB i f ( p >1) p a r t _ s u m 2 = 0 . 9 5 * p a r t _ s u m 2 + 0 . 0 5 * VAR . omega ( p , : ) ; w_B_OB = p a r t _ s u m 2 ’ ; end tmpVAR . o m e g a F i l t = w_B_OB ; % S t o r i n g / s a v i n g t h e f i l t e r e d a n g u l a r v e l o c i [ B_O , B_O_n ] = IGRF ( 1 0 , 1 0 , l a t , 0 , P ) ; tmpVAR . B = B_O_n ; % S t o r i n g / s a v i n g t h e " m e a s u r e d " B f i e l d B_B = R_B_O *B_O ; B_B_n = R_B_O * B_O_n ; tmpVAR . B_B = B_B_n ; % S t o r i n g / s a v i n g t h e " m e a s u r e d " B f i e l d r o t a t e d t o t h % i f p>1 % % e = ( B_O−B_B ) ; % APPENDIX A. MATLAB CODE 79 % i f abs ( eps ( 1 ) ) < 0.05 % VAR . e ( p , 1 ) = 0 ; % end % % i f abs ( eps ( 2 ) ) < 0.05 % VAR . e ( p , 2 ) = 0 ; % end % % i f abs ( eps ( 3 ) ) < 0.05 % VAR . e ( p , 3 ) = 0 ; % end % % e_tmp = VAR . e ( p , : ) ’ ; % tmpVAR . e = e * ( VAR . t ( p)−VAR . t ( p − 1 ) ) ; % % else % e_tmp = z e r o s ( 3 , 1 ) ; % tmpVAR . e = e_tmp ; % end % Here t h e u s a g e o f t h e a c t u a t o r s i s i m i t a t e d . E v e r y i t e r a t i o n t h e % c a l c u l a t e d ( " m e a s u r e d " ) B f i e l d a r e s a v e d i n o u t F c n . m . For e v e r y h a l f % second , r e t r i e v e t h e sequence o f " measured " B f i e l d s s i n c e l a s t t i m e t h % a c t u a t o r s were used , and u s e t h i s t o f i l t e r i t and c a l c u l a t e i t s % d e r i v a t i v e . Use t h e o u t p u t s f r o m B _ f i l t e r A n d D o t ( ) i n t h e c o n t r o l l o o p . i f ( ~ any ( B f i l t ) && t −Btime >=3) % d is p ( ’ S t a r t i n g a c t u a t i o n at time ’ ) Btime = t ; % Update B c o u n t e r s and r e t r i e v e " m e a s u r e d " B_B f i e l d and t i m e v e c t o r Bcnt ( 1 ) = Bcnt ( 2 ) ; Bcnt ( 2 ) = p ; B = VAR. B_B ( B c n t ( 1 ) : B c n t ( 2 ) , : ) ; t i m e S p a n = VAR. t ( B c n t ( 1 ) : B c n t ( 2 ) ) ; % % Compute f i l t e r e d g e o m a g n e t i c B f i e l d and t h e d e r i v a t i v e B d o t [ B f i l t , Bdot ] = B _ f i l t e r A n d D o t ( B , t i m e S p a n , ’ E s t i m a t o r _ 1 H z ’ ) ; [ B f i l t , Bdot ] = B _ f i l t e r A n d D o t (B , timeSpan , ’ c e n t r a l ’ ) ; end % Here t h e m e a s u r i n g i s i m i t a t e d . % A f t e r 0 . 5 s e c s t o p t h e a c t u a t i o n , i . e . s e t B f i l t and B d o t t o z e r o , and % s t a r t measuring again . APPENDIX A. MATLAB CODE 80 i f ( any ( B f i l t ) && t −Btime >=3) % d i s p ( ’ S t a r t i n g measurement a t time ’ ) Btime = t ; B f i l t = zeros ( 3 , 1 ) ; Bdot = z e r o s ( 3 , 1 ) ; end % S t o r i n g B f i l t and B d o t tmpVAR . B f i l t = B f i l t ; tmpVAR . Bdot = Bdot ; % Picking controller % [ tau_m ,W] = d e t u m b l i n g C o n t r o l l e r 3 ( P , B_B , B d o t ) ; [ tau_m ,W] = r e f e r e n c e C o n t r o l l e r ( P , w_B_OB , eps , B f i l t , e_tmp ) ; % [ tau_m ,W] = L Q c o n t r o l l e r ( P , e t a , eps , w_B_OB , B f i l t , S_eps , e_tmp ) ; % % % % % % % % % % % % S w i t c h c o n t r o l l e r a f t e r t h i s many o r b i t s o r b i t S w i t c h = 2; % Torque from c o n t r o l l e r s . Logic ’ i f ’ i s f o r c o n t r o l l e r s w i t c h i n g . i f t <P . o r b i t P e r i o d * o r b i t S w i t c h * 1000 % Pick detumbling c o n t r o l l e r [ tau_m ,W] = d e t u m b l i n g C o n t r o l l e r 3 ( P , B f i l t , B d o t ) ; else % [ tau_m ,W] = r e f e r e n c e C o n t r o l l e r ( P , w_B_OB , e t a , eps , B f i l t , S _ e p s ) ; [ tau_m ,W] = L Q c o n t r o l l e r ( P , e t a , eps , w_B_OB , B f i l t , S _ e p s ) ; end %−−−−−S t o r i n g v a r i a b l e s u s e d f o r t e s t i n g p u r p o s e s o n l y −−−−−S t a r t −−−−− tmpVAR . t o r q u e = tau_m ; tmpVAR .W = W; %−−−−−S t o r i n g v a r i a b l e s u s e d f o r t e s t i n g p u r p o s e s o n l y −−−−−−End−−−−−− % Gravitational torque c3 = R_B_O ( : , 3 ) ; t a u _ g = 3 * w_o ^2 * c r o s s ( c3 , I * c3 ) ; % tau_g = 0; % % % % % % S o l a r d r a g t o r q u e i n ORBOT f r a m e w i t h d i r e c t i o n i n t h e o r b i t a l v e l o c i t y plane i f ( mod ( p , 5 ) = = 0 ) t a u _ s _ O = [ 0 −s _ c o n s t 0 ] ’ ; t a u _ s = R_B_O * t a u _ s _ O ; % R o t a t e d t o t h e BODY f r a m e else APPENDIX A. MATLAB CODE 81 % tau_s = 0; % end t a u _ s _ O = [− s _ c o n s t 0 0 ] ’ ; t a u _ s = R_B_O * t a u _ s _ O ; % R o t a t e d t o t h e BODY f r a m e % A e r o d y n a m i c d r a g t o r q u e i n ORBOT f r a m e w i t h d i r e c t i o n i n t h e o r b i t a l % v e l o c i t y plane c_p = [ 0 . 0 2 0 . 0 2 0 . 0 2 ] ’ ; c_p_x = Smtrx ( c_p ) ; Vr = R_B_O * [−1 0 0 ] ’ ; Vr_x = Smtrx ( Vr ) ; t a u _ a = r h o _ a * v e l * ( v e l * A_drag * c_p_x * Vr − ( I + Vr_x * J ) * w_B_OB ) ; % % % % % % % % % Internal dipole torque tau_d = 0; i f ( mod ( p , 1 0 ) = = 0 ) d i = d _ c o n s t * randn ( 3 , 1 ) ; m_d = d _ c o n s t * ( d i / norm ( d i ) ) ; t a u _ d = c r o s s ( m_d , B_B ) ; % A l r e a d y i n t h e BODY f r a m e end Di = 0 . 1 3 8 6 * o n e s ( 3 , 1 ) ; t a u _ d = c r o s s ( Di , B f i l t ) ; % All disturbance torques t a u _ d i s t = t a u _ g + t a u _ a + t a u _ s ;%+t a u _ d ; tmpVAR . d i s t T o r q u e = t a u _ g + t a u _ a + t a u _ s ;%+t a u _ d ; tmpVAR . t o r q u e = t a u _ s ; % ************** D i f f e r e n t i a l e q u a t i o n s u p d a t e *************** % Angular a c c e l e r a t i o n wDot_B_IB= I \ ( tau_m + t a u _ d i s t −c r o s s ( w_B_IB , I * w_B_IB ) ) ; % wDot_B_IB=I \ ( tau_m+t a u _ g −c r o s s ( w_B_IB , I * w_B_IB ) ) ; % Eta e t a D o t = −0.5 * eps ’ * w_B_OB ; % Epsilon e p s D o t = 0 . 5 * ( e t a * e y e ( 3 ) + S _ e p s ) * w_B_OB ; % Variable assignment xDot ( 1 : 3 , 1 ) = wDot_B_IB ; xDot ( 4 , 1 ) = e t a D o t ; APPENDIX A. MATLAB CODE xDot ( 5 : 7 , 1 ) xDot ( 8 , 1 ) = xDot ( 9 , 1 ) = xDot ( 1 0 : 1 2 ) 82 = epsDot ; w_o ; W; = eps ; % toc end % Bdot d e t u m b l i n g c o n t r o l l e r % Controls the s a t e l l i t e to follow the geomagnetic f i e l d . f u n c t i o n [ tau_m ,W] = d e t u m b l i n g C o n t r o l l e r 3 ( P , B_B , Bdot_B ) % % % % % % % % % % % Sign o f Bdot c o n t r o l l e r i f ( norm ( w_B_OB ) > 0 . 0 0 1 ) % disp ( ’a ’) k _ s = −1; e l s e i f ( norm ( w_B_OB ) < 0 . 0 0 1 ) % disp ( ’b ’) k_s = 1; else % disp ( ’c ’) k_s = 0; end % C on tr ol le r gain k = 4 e −5; % k = 1; % Moment s e t up by c o i l s b e f o r e s c a l i n g ( s a t u r a t i n g c u r r e n t ) m_B = (−k / norm ( B_B , 2 ) ^ 2 ) * Bdot_B ; % Moment s e t up by c o i l s a f t e r s c a l i n g [ m_B ,W] = c u r r e n t S c a l i n g ( P , m_B ) ; % T o r q u e s e t up by c o i l s tau_m = c r o s s ( m_B , B_B ) ; % end end % S a t e l l i t e r e f e r e n c e c o n t r o l l e r f o r l a r g e d e v i a t i o n s f r o m R_B_O = e y e ( 3 ) f u n c t i o n [ tau_m ,W] = r e f e r e n c e C o n t r o l l e r ( P , w_B_OB , eps , B_B , e ) APPENDIX A. MATLAB CODE % p d i 83 Controller gains = 8 e −9; %. 4 e −9; %2.5 e−7 %5e−8 = 12 e −6; %. 8 e −6; %0.0004 %4e−5 = 0 ; %5 e −11; % Moment s e t up by c o i l s b e f o r e s c a l i n g ( s a t u r a t i n g c u r r e n t ) m_B = ( 1 / norm ( B_B , 2 ) ^ 2 ) * ( −p * c r o s s ( B_B , e p s ) − d * c r o s s ( B_B , w_B_OB ) − i * c r o % Moment s e t up by c o i l s a f t e r s c a l i n g [ m_B ,W] = c u r r e n t S c a l i n g ( P , m_B ) ; % T o r q u e s e t up by c o i l s tau_m = c r o s s ( m_B , B_B ) ; end % S a t e l l i t e r e f e r e n c e LQ−c o n t r o l l e r f o r d e v i a t i o n s f r o m R_B_O = e y e ( 3 ) . f u n c t i o n [ tau_m ,W] = L Q c o n t r o l l e r ( P , e t a , eps , w_B_OB , B_B , S_eps , e ) % Eta % e t a D o t = −0.5 * eps ’ * w_B_OB ; % Epsilon e p s D o t = 0 . 5 * ( e t a * e y e ( 3 ) + S _ e p s ) * w_B_OB ; % Check i f ’ m e a s u r i n g ’ o r n o t i f any ( B_B==0) m_B = z e r o s ( 3 , 1 ) ; else % LQ g a i n m a t r i x K = K2 ( P , B_B ) ; %Time v a r y i n g LQ % end % Moment s e t up by c o i l s b e f o r e s c a l i n g ( s a t u r a t i n g c u r r e n t ) m_B = −K * [ e p s ( 1 ) e p s D o t ( 1 ) e p s ( 2 ) e p s D o t ( 2 ) e p s ( 3 ) e p s D o t ( 3 ) ] ’ ; %e ( 1 ) m_B = c r o s s ( B_B , m_B ) ; % Moment s e t up by c o i l s a f t e r s c a l i n g [ m_B ,W] = c u r r e n t S c a l i n g ( P , m_B ) ; % T o r q u e s e t up by c o i l s tau_m = c r o s s ( m_B , B_B ) ; end % S c a l e s ( s a t u r a t e s ) t h e power c o n s u m p t i o n i f t h e maximum c u r r e n t s a r e APPENDIX A. MATLAB CODE 84 % exceeded f u n c t i o n [ m_B ,W] = c u r r e n t S c a l i n g ( P , m_B) % Load c o i l p a r a m e t e r s f r o m p a r a m e t e r s t r u c t N = P . N ; % Ny = P . Ny ; Nz = P . Nz ; Ax = P . Ax ; Ay = P . Ay ; Az = P . Az ; ix_max = P . ix_max ; iy_max = P . iy_max ; iz_max = P . iz_max ; V = P .V; % I f m_B i s z e r o o r NaN , i . e . one i s i n m e a s u r e m e n t mode , s e t t h e moment % t o z e r o . Also , t o avoid error , s e t t h e r a t i o v a r i a b l e t o ones . i f ( i s e m p t y (m_B) | | any (m_B==0) | | any ( i s n a n (m_B ) = = 1 ) ) % disp ( ’a ’) m_B = z e r o s ( 3 , 1 ) ; r a t i o = ones ( 3 , 1 ) ; else % disp ( ’b ’) % Current scaling % C r e a t e s r a t i o v a r i a b l e c o n t a i n i n g a c o i l ’ s : max c u r r e n t / w a n t e d c u r r % The l o w e s t v a l u e i n r a t i o v a r i a b l e , i f b e l o w 1 i s t h e h i g h e s t c u r r e % v i o l a t i o n , t h u s a l l t h e c u r r e n t s s h o u l d be s c a l e d by t h i s f a c t o r . i x = m_B ( 1 ) / ( N* Ax ) ; r a t i o ( 1 ) = ix_max / abs ( i x ) ; i y = m_B ( 2 ) / ( N* Ay ) ; r a t i o ( 2 ) = iy_max / abs ( i y ) ; i z = m_B ( 3 ) / ( N* Az ) ; r a t i o ( 3 ) = iz_max / abs ( i z ) ; end i f min ( r a t i o ) <1 % disp ( ’c ’) m_B = m_B* min ( r a t i o ) ; end % Power c o n s u m p t i o n ( W a t t ) Wx = abs (V*m_B ( 1 ) / ( N* Ax ) ) ; Wy = abs (V*m_B ( 2 ) / ( N* Ay ) ) ; Wz = abs (V*m_B ( 3 ) / ( N* Az ) ) ; W = Wx+Wy+Wz; %−−−−−S t o r i n g v a r i a b l e s u s e d f o r t e s t i n g p u r p o s e s o n l y −−−−−S t a r t −−−−− g l o b a l tmpVAR ; tmpVAR . moment=m_B ; % tmpVAR .W = W; % tmpVAR . J = j ; %−−−−−S t o r i n g v a r i a b l e s u s e d f o r t e s t i n g p u r p o s e s o n l y −−−−−−End−−−−−− APPENDIX A. MATLAB CODE 85 end % F u n c t i o n f o r f i l t e r i n g t h e " m e a s u r e d " B−f i e l d , and e s t i m a t i n g t h e % d e r i v a t i v e o f t h e B− f i e l d . function [ B f i l t _ a r r a y , Bdot_array ] = B_filterAndDot (B, t , f l a g ) d e l t a _ t = zeros ( s i z e ( t ) ) ; B f i l t _ a r r a y = zeros ( s i z e (B ) ) ; B d o t _ a r r a y = zeros ( s i z e (B ) ) ; Bfilt_array (1 ,:) = B(1 ,:); switch flag case ’ Estimator_10Hz ’ % F i r s t , LP f i l t e r i n g o f B u s i n g f i l t e r a p p r o a c h g o t t e n f r o m % Trygve Utstumo : a1 = 0 . 8 ; b1 = 1−a1 ; part_sum = B ( 1 , : ) ; f or k = 2 : l e n g t h (B) p a r t _ s u m = a1 * p a r t _ s u m + b1 *B ( k , : ) ; B f i l t _ a r r a y ( k , : ) = part_sum ; end % E s t i m a t i n g Bdot u s i n g d i s c r e t e L P f i l t e r K = 2.65; a2 = 0 . 9 3 2 ; %0 . 9 3 2 4 b2 = 0 . 7 ; b2 = K* b2 ; f or i =2: l e n g t h (B) B d o t _ a r r a y ( i , : ) = a2 * B d o t _ a r r a y ( i − 1 , : ) + b2 * (B ( i , : ) − B ( i end B d o t _ a r r a y ( ~ any ( B d o t _ a r r a y , 2 ) , : ) = [ ] ; % C a n c e l any z e r o s % Return l a s t f i l t e r e d / estimated value B f i l t _ a r r a y = B f i l t _ a r r a y ( end , : ) ’ ; B d o t _ a r r a y = B d o t _ a r r a y ( end , : ) ’ ; case ’ Estimator_1Hz ’ APPENDIX A. MATLAB CODE 86 % F i r s t , LP f i l t e r i n g o f B u s i n g f i l t e r a p p r o a c h g o t t e n f r o m % Trygve Utstumo : a1 = 0 . 8 ; b1 = 1−a1 ; part_sum = B ( 1 , : ) ; f or k = 2 : l e n g t h (B) p a r t _ s u m = a1 * p a r t _ s u m + b1 *B ( k , : ) ; B f i l t _ a r r a y ( k , : ) = part_sum ; end % E s t i m a t i n g Bdot u s i n g d i s c r e t e L P f i l t e r K = 3 ; %3 ; a2 = 0 . 9 3 2 4 ; %0 . 0 3 0 2 1 ; %0.9324; b2 = K* (1− a2 ) ; %(1− a2 ) ; %0.0676 %0.4156 f or i =2: l e n g t h (B) B d o t _ a r r a y ( i , : ) = a2 * B d o t _ a r r a y ( i − 1 , : ) + b2 * (B ( i , : ) − B ( i end B d o t _ a r r a y ( ~ any ( B d o t _ a r r a y , 2 ) , : ) = [ ] ; % C a n c e l any z e r o s % Return l a s t f i l t e r e d / estimated value B f i l t _ a r r a y = B f i l t _ a r r a y ( end , : ) ’ ; B d o t _ a r r a y = B d o t _ a r r a y ( end , : ) ’ ; case ’ c e n t r a l ’ % N u m e r i c a l d i f f e r e n t i a t i o n by c e n t r a l d i f f e r e n c e a p p r o x i m a t i o n a1 = 0 . 8 ; b1 = 1−a1 ; part_sum = B ( 1 , : ) ; f or k = 2 : l e n g t h (B) p a r t _ s u m = a1 * p a r t _ s u m + b1 *B ( k , : ) ; B f i l t _ a r r a y ( k , : ) = part_sum ; end f o r i = 2 : l e n g t h ( B)−1 d e l t a _ t ( i ) = ( t ( i +1)− t ( i − 1 ) ) ; B d o t _ a r r a y ( i , : ) = ( B f i l t _ a r r a y ( i +1 ,:) − B f i l t _ a r r a y ( i −1 ,:) end B d o t _ a r r a y ( ~ any ( B d o t _ a r r a y , 2 ) , : ) = [ ] ; % C a n c e l any z e r o s APPENDIX A. MATLAB CODE 87 % Return l a s t f i l t e r e d / estimated value B f i l t _ a r r a y = B f i l t _ a r r a y ( end , : ) ’ ; B d o t _ a r r a y = B d o t _ a r r a y ( end , : ) ’ ; end end %************************************************************************ % F i l e parameters .m % % P = parameters ( ) % % C r e a t e s a parameter s t r u c t P , which i s used t o pass t h e p ara met er s % between d i f f e r e n t f u n c t i o n s . % % W r i t t e n by Zdenko Tudor , 2 0 1 1 . E d i t e d by Gaute B r å t h e n , 2 0 1 2 . %************************************************************************ function P = parameters () % Coil data % Battery voltage V = 5; % % % Number o f c o i l w i n d i n g s ( t u r n s ) N = 2 2 1 ; %1 9 6 ; Ny = 2 2 1 ; %196; Nz = 2 2 1 ; %196; % [m^ 2 ] C o i l a r e a Ax = 0 . 0 6 3 * 0 . 1 6 5 ; %0 . 0 7 9 * 0 . 1 8 4 ; % 0 . 0 7 5 * 0 . 1 7 5 ; Ay = 0 . 0 6 3 * 0 . 1 6 5 ; %0 . 0 7 9 * 0 . 1 8 4 ; % 0 . 0 7 5 * 0 . 1 7 5 ; Az = 0 . 0 7 7 ^ 2 ; %0 . 0 7 9 ^ 2 ; %0.075^2; % [Ohm] C o i l r e s i s t a n c e Rx = 4 3 . 0 3 ; %3 4 . 7 8 ; %43.03; %55.47; %47.18; Ry = 4 3 . 0 3 ; %3 4 . 7 8 ; %43.03; %55.47; %47.18; Rz = 2 3 . 7 8 ; %1 9 . 2 2 ; %23.78; %33.32; %28.31; % [ A ] T h e o r e t i c a l maximum c u r r e n t t h r o u g h c o i l s ix_max = V / Rx ; iy_max = V / Ry ; iz_max = V / Rz ; APPENDIX A. MATLAB CODE % % % 88 % [ A ] R e a l maximum c u r r e n t t h r o u g h c o i l s f o r a g i v e n AWG number ( s e e % e x c e l −s h e e t ’ C o i l d e s i g n ’ ) : i_max = 0 . 2 2 6 0 ; % Max amps f o r AWG# 28 i_max = 0 . 1 4 2 0 ; % Max amps f o r AWG# 30 i_max = 0 . 1 1 3 0 ; % Max amps f o r AWG# 31 i_max = 0 . 0 9 1 0 ; % Max amps f o r AWG# 32 i f ( ix_max > i_max ) % Check i f ix_max = i_max ; iy_max = i_max ; end t h e o r e t i c a l max amps i s h i g h e r t h a n r e a l i f ( iz_max > i_max ) % Same a s a b o c e f o r t h e z−c o i l iz_max = i_max ; end Re = 6 3 7 1 . 2 e3 ; % [m] E a r t h r a d i u s Rs = 600 e3 ; % [m] S a t e l l i t e a l t i t u d e Rc = Re+Rs ; % [m] D i s t a n c e f r o m e a r t h c e n t e r t o s a t e l m = 2.6; % 2.66 % [ kg ] S a t e l l i t e mass dx = 0 . 0 5 ; % 0 . 0 5 % X−a x i s l e n g t h dy = 0 . 0 4 9 ; % 0 . 0 4 9 % Y−a x i s l e n g t h dz = 0 . 1 1 3 ; % Z−a x i s l e n g t h I x = (m/ 1 2 ) * ( dy ^2+ dz ^ 2 ) ; % X−a x i s i n e r t i a I y = (m/ 1 2 ) * ( dx ^2+ dz ^ 2 ) ; % Y−a x i s i n e r t i a I z = (m/ 1 2 ) * ( dx ^2+ dy ^ 2 ) ; % Z−a x i s i n e r t i a jx = 0.03; % 0.05 % X−a x i s l e n g t h jy = 0.03; % 0.049 % Y−a x i s l e n g t h jz = 0.093; % Z−a x i s l e n g t h J x = (m/ 1 2 ) * ( j y ^2+ j z ^ 2 ) ; % X−a x i s i n e r t i a J y = (m/ 1 2 ) * ( j x ^2+ j z ^ 2 ) ; % Y−a x i s i n e r t i a J z = (m/ 1 2 ) * ( j x ^2+ j y ^ 2 ) ; % Z−a x i s i n e r t i a x = 0.1; y = 0.1; z = 0.2; A_xo = x * z ; % O u t e r s a t e l l i t e area , x−p a n e l A_yo = y * z ; % O u t e r s a t e l l i t e area , y−p a n e l A_zo = x * y ; % O u t e r s a t e l l i t e area , z−p a n e l A_drag = z * s q r t ( x ^2 + y ^ 2 ) ; % Maximum a r e a f o r c a l c d i s t u r b a n c e d r a g s I = diag ( [ Ix Iy Iz ] ) ; J = diag ( [ Jx Jy Jz ] ) ; % I n e r t i a matrix % I n e r t i a matrix G = 6 . 6 7 4 2 8 e −11; % Earth g r a v i t a t i o n a l c o n s ta n t APPENDIX A. MATLAB CODE 89 M = 5 . 9 7 2 e24 ; % E a r t h mass w_o = s q r t (G*M/ Rc ^ 3 ) ; % S a t e l l i t e angular v e l o c i t y r e l a t i v e Ear o r b i t P e r i o d = ( 2 * p i ) / ( w_o ) ; % For d e f i n i n g s i m u l a t i o n l e n g t h s c a l e P l o t = 1 / o r b i t P e r i o d ; % For x−a x e s s c a l i n g when p l o t t i n g v e l = 2 * p i * Rc / o r b i t P e r i o d ; % O r b i t v e l o c i t y r h o _ a = 4 . 8 9 e −13; a _ c o n s t = 0 . 5 * r h o _ a * v e l ^ 2 * 2 . 5 * A_drag * 0 . 0 2 ; % Aero d r a g c o n s t s _ c o n s t = ( 1 3 6 7 / 3 e8 ) * A_drag * ( 1 + 0 . 6 ) * c o s ( 0 ) * 0 . 0 2 ; % S o l a r drag c o n s t d_const = 0.00072; % Calculated self , see notes % d _ c o n s t = 4 . 5 9 e −7; % I n t e r n a l d i p o l e c o n s t , G i e s s l m a n n , 2006 p . 4 4 / 5 % Store variables P . w_o = w_o ; P .V = V; P . I = I ; P . J = J ; P . N = N ; % P . Ny = Ny ; P . Nz = Nz ; P . Ax = Ax ; P . Ay = Ay ; P . Az = Az ; P . Rx = Rx ; P . Ry = Ry ; P . Rz = Rz ; P . ix_max = ix_max ; P . iy_max = iy_max ; P . iz_max = iz_max ; P . Re = Re ; P . Rc = Rc ; P. orbitPeriod = orbitPeriod ; P. scalePlot = scalePlot ; P . A_xo = A_xo ; P . A_yo = A_yo ; P . A_zo = A_zo ; P . A_drag = A_drag ; P . vel = vel ; P . rho_a = rho_a ; P . a_const = a_const ; P . s_const = s_const ; P . d_const = d_const ; end %************************************************************************ % F i l e IGRF . m % % A l g o r i t h m f o r f i n d i n g t h e m a g n e t i c f i e l d v e c t o r s f r o m t h e IGRF−11 % model f o r a g i v e n l a t i t u d e LAT and l o n g i t u d e LON i n r a d i a n s , w i t h % o r d e r n and d e g r e e m . The o u t p u t i s t h e m a g n e t i c f i e l d v e c t o r % r e p r e s e n t e d in t he o r b i t frame . % % C r e a t e d by Raymond K r i s t i a n s e n , 2000 % E d i t e d by Zdenko Tudor , 2011 %************************************************************************ f u n c t i o n [ B , B_n ] = IGRF ( n , m, l a t , l o n , P ) % tic % Load IGRF11 c o e f f i c i e n t v a r i a b l e s l o a d ( ’ IGRF11_data ’ ) APPENDIX A. MATLAB CODE 90 i = n; j = m; % Fix l a t i t u d e in case of p o s s i b l e s i n g u l a r i t y mt = mod ( l a t , 2 * p i ) ; t o l = 1 e −9; i f ( mt > ( p i /2) − t o l && mt < ( p i / 2 ) + t o l ) l a t =( pi / 2 ) + t o l ; e l s e i f ( mt > ( 3 * p i /2) − t o l && mt < ( 3 * p i / 2 ) + t o l ) l a t =(3* pi / 2 ) + t o l ; end % Defining constants Re = P . Re ; Rc = P . Rc ; % C a l c u l a t i n g c o l a t i t u d e and l o n g i t u d e i n r a d i a n s t h e t a = ( p i /2) − l a t ; phi = lon ; % Zero o f f s e t O = 1; % Defining temporary v a r i a b l e s Bt2 = 0 ; Bp2 = 0 ; Br2 = 0 ; % C a l c u l a t i n g Legendre polynominals [ P , dP , S ] = P f u n k ( n , m, t h e t a ) ; % Calculating f i e l d vectors for n =1: i Bt1 = 0 ; Bp1 = 0 ; Br1 = 0 ; f o r m= 0 : j Bt1 = Bt1 + ( S (O+n , O+m) * g _ d a t a (O+n , O+m) * c o s (m* p h i ) + S (O+n , O+m ) * . . . h _ d a t a (O+n , O+m) * s i n (m* p h i ) ) * dP (O+n , O+m ) ; Bp1 = Bp1 + (m* S (O+n , O+m) * h _ d a t a (O+n , O+m) * c o s (m* p h i )−m * . . . S (O+n , O+m) * g _ d a t a (O+n , O+m) * s i n (m* p h i ) ) * P (O+n , O+m ) ; Br1 = Br1 + ( S (O+n , O+m) * g _ d a t a (O+n , O+m) * c o s (m* p h i ) + S (O+n , O+m ) * . . . h _ d a t a (O+n , O+m) * s i n (m* p h i ) ) * P (O+n , O+m ) ; end Bt2 = Bt2 + ( ( Re / Rc ) ^ ( n + 2 ) ) * Bt1 ; APPENDIX A. MATLAB CODE 91 Bp2 = Bp2 + ( ( Re / Rc ) ^ ( n + 2 ) ) * Bp1 ; Br2 = Br2 + ( n + 1 ) * ( ( Re / Rc ) ^ ( n + 2 ) ) * Br1 ; end % In Cartesian coordinates eps = 0 ; X = Bt2 * c o s ( e p s )−Br2 * s i n ( e p s ) ; Y = −Bp2 / ( s i n ( t h e t a ) ) ; Z = −Bt2 * s i n ( e p s )−Br2 * c o s ( e p s ) ; B = [X ; Y ; Z ] * 1 e −9; B_n = B + 300 e −9. * randn ( s i z e ( B ) ) ; % A d d i n g n o i s e ( N o i s e f l o o r f r o m HMC598 % toc end %************************************************************************ % % Algorithm f o r c a l c u l a t i n g the a s s o c i a t e d Legendre polynominals % f o r t h e g i v e n o r d e r n , d e g r e e m and co− l a t i t u d e t h e t a . The o u t p u t % i s t h e L e g e n d r e p o l y n o m i n a l P , i t s p a r t i a l d e r i v a t i v e dP and % the Schmidt normalization matrix S . % % C r e a t e d by Raymond K r i s t i a n s e n , 2000 % E d i t e d by Zdenko Tudor , 2011 %************************************************************************ f u n c t i o n [ P , dP , S ] = P f u n k ( n , m, t h e t a ) O = 1 ; % Zero i n d e x o f f s e t % Defining zero matrices P = o n e s ( n+O, m+O ) ; dP = z e r o s ( n+O, m+O ) ; S = o n e s ( n+O, m+O ) ; i = n; j = m; % Calculating S matrix for n = 0:1: i for m = 0:1: j if n > 0 i f m == 0 S (O+n , O+m) = S ( n−1+O, 0+O) * ( 2 * n − 1 ) / n ; else i f m == 1 deltaFun = 1; APPENDIX A. MATLAB CODE 92 else deltaFun = 0; end S ( n+O, m+O) = S ( n+O, m−1+O) * s q r t ( ( ( n−m+ 1 ) * ( d e l t a F u n + 1 ) ) / ( end end end end % C a l c u l a t e s t h e L e g e n d r e p o l y n o m i n a l P and i t s p a r t i a l d e r i v a t i v e dP for n = 0 :1 : i for m = 0 :1 : j i f n==1 dP ( n+O, m+O) = c o s ( t h e t a ) * dP ( n−1+O, m+O)− s i n ( t h e t a ) * P ( n−1+O,m P ( n+O, m+O) = c o s ( t h e t a ) * P ( n−1+O, m+O ) ; e l s e i f n >1 K= ( ( n−1)^2−m^ 2 ) / ( ( 2 * n −1) * (2 * n − 3 ) ) ; dP ( n+O, m+O) = c o s ( t h e t a ) * dP ( n−1+O, m+O)− s i n ( t h e t a ) * P ( n−1+O,m K* dP ( n−2+O, m+O ) ; P ( n+O, m+O) = c o s ( t h e t a ) * P ( n−1+O, m+O) − K* P ( n−2+O, m+O ) ; end i f n==m && n >0 P ( n+O, m+O) = s i n ( t h e t a ) * P ( n−1+O, n−1+O ) ; dP ( n+O, m+O) = s i n ( t h e t a ) * dP ( n−1+O, n−1+O) + c o s ( t h e t a ) * P ( n−1+O end end end end % % % % % % % % % % % % % % % ********************************************************************** F i l e outFcn .m s t a t u s = outFcn ( t , ~ , f l a g ) I s r u n when ODE45 s u c c e s s f u l l y c o m p l e t e s a s t e p . T h i s f u n c t i o n i s u s e d i m p l i c i t l y by ODE45 , when ODE s e t t i n g s a r e properly set . Example : o p t i o n s = o d e s e t ( ’ OutputFcn ’ , @outFcn , ’ R e f i n e ’ , 1 ) ; R e f i n e s e t s how many s t e p s s h o u l d be c r e a t e d f o r e a c h s u c c e s s f u l l s t e p . W i t h t h i s s e t t o 1 l e n g t h o f a l l v e c t o r s c r e a t e d by t h e O u t p u t F c n w i l l t h e same a s t h e l e n g t h o f ODE t i m e v e c t o r TOUT . APPENDIX A. MATLAB CODE 93 % % W r i t t e n by Zdenko Tudor , 2011 %************************************************************************ function s t a t u s = outFcn ( t ,~ , f l a g ) persistent ite ; g l o b a l tmpVAR VAR p ; switch flag case ’ i n i t ’ %i n i t i a l i z e arrays e t c . p = 1; i t e = 1; VAR. e = z e r o s ( 2 0 0 0 0 , 3 ) ; VAR. moment = z e r o s ( 2 0 0 0 0 , 3 ) ; VAR. t o r q u e = z e r o s ( 2 0 0 0 0 , 3 ) ; VAR. d i s t T o r q u e = z e r o s ( 2 0 0 0 0 , 3 ) ; VAR. B = z e r o s ( 2 0 0 0 0 , 3 ) ; VAR. B_B = z e r o s ( 2 0 0 0 0 , 3 ) ; VAR. B f i l t = z e r o s ( 2 0 0 0 0 , 3 ) ; VAR. Bdot = z e r o s ( 2 0 0 0 0 , 3 ) ; VAR. omega = z e r o s ( 2 0 0 0 0 , 3 ) ; % VAR . o m e g a F i l t = z e r o s ( 2 0 0 0 0 , 3 ) ; VAR.W = z e r o s ( 2 0 0 0 0 , 1 ) ; VAR. t = z e r o s ( 2 0 0 0 0 , 1 ) ; % s t a t u s = 0; c a s e ’ done ’ VAR. e ( i t e + 1 : end , : ) = [ ] ; VAR. moment ( i t e + 1 : end , : ) = [ ] ; VAR. t o r q u e ( i t e + 1 : end , : ) = [ ] ; VAR. d i s t T o r q u e ( i t e + 1 : end , : ) = [ ] ; VAR. B( i t e + 1 : end , : ) = [ ] ; VAR. B_B ( i t e + 1 : end , : ) = [ ] ; VAR. B f i l t ( i t e + 1 : end , : ) = [ ] ; VAR. Bdot ( i t e + 1 : end , : ) = [ ] ; VAR. omega ( i t e + 1 : end , : ) = [ ] ; VAR . o m e g a F i l t ( i t e +1: end , : ) = [ ] ; VAR.W( i t e + 1 : end , : ) = [ ] ; VAR. t ( i t e + 1 : end , : ) = [ ] ; s t a t u s = 0; otherwise p = p +1; i t e = i t e +1; APPENDIX A. MATLAB CODE 94 VAR. e ( i t e , : ) = VAR. e ( i t e − 1 , : ) + tmpVAR . e ’ ; VAR. moment ( i t e , : ) = tmpVAR . moment ’ ; VAR. t o r q u e ( i t e , : ) = tmpVAR . t o r q u e ’ ; VAR. d i s t T o r q u e ( i t e , : ) = tmpVAR . d i s t T o r q u e ’ ; VAR. B( i t e , : ) = tmpVAR . B ’ ; VAR. B_B ( i t e , : ) = tmpVAR . B_B ’ ; VAR. B f i l t ( i t e , : ) = tmpVAR . B f i l t ’ ; VAR. Bdot ( i t e , : ) = tmpVAR . Bdot ’ ; VAR. omega ( i t e , : ) = tmpVAR . omega ’ ; VAR . o m e g a F i l t ( i t e , : ) = tmpVAR . o m e g a F i l t ’ ; VAR.W( i t e , : ) = tmpVAR .W; VAR. t ( i t e , 1 ) = t ( end ) ; % s t a t u s = 0; end end f u n c t i o n K = K2 ( P , B_B ) %************************************************************************ % LQ g a i n m a t r i x c a l c u l a t i o n % % W r i t t e n by E l i Overby 2 0 0 4 , m o d i f i e d by F r e d r i k S o l a H o l b e r g 2 0 1 1 . % M o d i f i e d by Gaute B r å t h e n 2 0 1 2 . % Ntnu , Trondheim , December 20 t h 2 0 1 2 . % %************************************************************************ % g l o b a l I omega_0 % I n i t i a l values w_o = P . w_o ; Ix = P . I ( 1 , 1 ) ; Iy = P . I ( 2 , 2 ) ; Iz = P . I (3 ,3); kx = ( I y − I z ) / I x ; ky = ( I x − I z ) / I y ; kz = ( I y − I x ) / I z ; % The g e o m a g n e t i c f i e l d Bx_0 = B_B ( 1 ) ; By_0 = B_B ( 2 ) ; Bz_0 = B_B ( 3 ) ; % The l i n e a r i z e d s y s t e m m a t r i x APPENDIX A. MATLAB CODE 95 A = [0 1 0 0 0 0; −4* kx * w_o^2 0 0 0 0 ( 1 − kx ) * w_o ; 0 0 0 1 0 0; 0 0 −3* ky * w_o^2 0 0 0 ; 0 0 0 0 0 1; 0 −(1 − kz ) * w_o 0 0 −kz * w_o^2 0 ] ; % s i z e (A) % eig (A) % The i n p u t m a t r i x f o r t h e l i n e a r i z e d s y s t e m B = [0 0 0; 0 Bz_0 / ( 2 * I x ) −By_0 / ( 2 * I x ) ; 0 0 0; −Bz_0 / ( 2 * I y ) 0 Bx_0 / ( 2 * I y ) ; 0 0 0; By_0 / ( 2 * I z ) −Bx_0 / ( 2 * I z ) 0 ] ; % % % % % C = diag ([1 1 1 1 1 1 1 1 1 ] ) ; D = 0; SYS = s s ( A , B , C , D) minSYS = m i n r e a l ( SYS ) % SYSd = c2d ( SYS , 1 ) ; % LQ−w e i g h t i n g m a t r i c e s % Qmat = d i a g ( [ 1 / ( ( 1 6 0 * p i / 1 8 0 ) ^ 2 ) 0 1 / ( ( 1 6 0 * p i / 1 8 0 ) ^ 2 ) 0 1 / ( ( 1 3 0 * p i / 1 8 0 ) 1 e−7 1 e−7 1 e−7 % Qmat = b l k d i a g ( d i a g ( [ 1 0 1 0 1 0 ] ) * 1 / ( ( 8 0 * p i / 1 8 0 ) ^ 2 ) , d i a g ( [ 1 0 1 0 1 Qmat = d i a g ( [ 1 0 1 0 1 0 ] ) * 1 / ( ( 6 0 * p i / 1 8 0 ) ^ 2 ) ; %x Pmat = d i a g ( [ 1 1 1 ] ) * 1 / ( ( 0 . 0 0 1 ) ^ 2 ) ; %u 0.00091 % Calculate the gain matrix K = l q r (A, B , Qmat , Pmat ) ; end Appendix B Mechanical Drawings and Data Mechanical drawings for coil (magnetorquer) frames and mechanical data of the satellite. All privided by Christian E. Nomme. Figure B.1: Mechanical drawing of magnetorquer to be used and the x- and y-sides. 96 APPENDIX B. MECHANICAL DRAWINGS AND DATA Figure B.2: Mechanical drawing of magnetorquer to be used on the z-side. 97 ============================================================ Measurement Mass Properties Displayed Mass Property Values Volume = 822752.789791495 mm^3 Area = 818187.509097557 mm^2 Mass = 1.200376087 kg Weight = 11.771678777 N Radius of Gyration = 92.368722593 mm Centroid = 0.217424347, 1.849467925, -13.335212988 mm ============================================================ Detailed Mass Properties Analysis calculated using accuracy of 0.990000000 Information Units kg - mm Density Volume Area Mass First Moments Mx, My, Mz = 0.000001459 = 822752.789791495 = 818187.509097557 = 1.200376087 = Center of Mass Xcbar, Ycbar, Zcbar = 0.260990987, 0.217424347, 2.220057071, -16.007270789 1.849467925, -13.335212988 Moments of Inertia (WCS) Ix, Iy, Iz = 7881.402909432, 7935.008012060, 5102.006880730 Moments of Inertia (Centroidal) Ixc, Iyc, Izc = 7663.836619764, 7721.490900940, 5097.844210592 Moments of Inertia (Spherical) I = 10241.585865648 Products of Inertia (WCS) Iyz, Ixz, Ixy = -16.579474684, -65.516622122, -0.072180012 Products of Inertia (Centroidal) Iyzc, Ixzc, Ixyc = 13.025459202, -62.036251727, -0.554874470 Radii of Gyration (WCS) Rx, Ry, Rz = 81.029488479, 81.304581213, 65.194634121 Radii of Gyration (Centroidal) Rxc, Ryc, Rzc = 79.903251286, 80.203240256, 65.168032909 Radii of Gyration (Spherical) R = 92.368722593 Principal Axes (Direction vectors relative to the WCS) Xp(X), Xp(Y), Xp(Z) = 0.004388892, 0.999978556, -0.004860637 file:///C|/Users/gautebra/Documents/Satellite/Report/graphics/data.txt[19.12.2012 14:02:25]

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement