# Tianwen-1 attitude during cruise and early orbit

In a previous post I talked about the ADCS telemetry of Tianwen-1. In there I showed that Space Packets in APID 1281 had several fields corresponding to the ADCS, including the quaternion giving the spacecraft attitude. I used these quaternions to show that the spacecraft had made a turn of 15º about its Y axis. However, at that time I still lacked some details to give a full interpretation of the attitude quaternions, such as what frame of reference they used or how were the spacecraft body axes defined.

Now I have looked at all the telemetry we have collected so far and with this I’ve been able to guess the missing details, so I can give a complete interpretation of the attitude quaternions. In this post I will show the attitude control law of Tianwen-1 on its cruise orbit to Mars and also the attitude during early orbit operations.

When examining the spacecraft’s attitude data, it helps to know the locations of the Sun and Earth with respect to the spacecraft, as it needs to orient its solar panels towards the Sun and its high-gain antenna towards Earth. By using the positions of the Sun and Earth as references, we can check if we are interpreting the attitude data correctly.

The position of the Sun with respect to the spacecraft is taken directly from the state vectors in the telemetry. These are transmitted in APID 1287 and include the spacecraft’s position and velocity in heliocentric ICRF coordinates (see this post for more information).

The figure below shows the state vectors we have gathered from the low rate telemetry. Note that we have almost continuous coverage any time the spacecraft is in view from Europe. The AMSAT-DL people operating the 20m antenna at Bochum observatory and Paul Marsh M0EYT deserve a huge thank you for tracking the spacecraft and decoding the telemetry day after day. Their continuous effort is what allows me to do studies like this one.

(In this figure the size of the dots exaggerates the periods when the spacecraft is in tracking; we have about 12 hours of data per day).

In APID 1281 we have some fields that give the spacecraft attitude as a quaternion. These are plotted below. As I will show later, the quaternions give the transformation from body frame coordinates to ICRF coordinates. This means that if $$p$$ are the coordinates of a vector with respect to the spacecraft body frame, written as a pure quaternion, and $$q$$ is the attitude quaternion, then the pure quaternion $$qpq^{-1}$$ gives the coordinates of this vector with respect to the ICRF system. For example, $$qiq^{-1}$$, $$qjq^{-1}$$ and $$qkq^{-1}$$ are the body frame X, Y and Z vectors in ICRF coordinates.

The beginning of the data is from the early orbit on 2020-07-23 and will be examined later. We concentrate on the data after 2020-07-25, which corresponds to the cruise orbit. We see that there are a couple of jumps in the quaternions (including the large jump on 2020-07-30 which was studied in this post), but otherwise they change quite slowly.

To interpret the quaternions, it helps to plot the spacecraft to Sun vector in the spacecraft body frame. To do so, if $$r$$ is the heliocentric state vector shown above, we write $$-r/\|r\|$$ as a pure quaternion $$S$$ and compute $$q^{-1}Sq$$. The result is shown here (the few stray dots around 2020-07-28 are from a few corrupted packets).

This plot shows a number of things. First, except for the two jumps the Sun vector is constant. This means that the spacecraft maintains a constant attitude with respect to the Sun. Second, the Y coordinate is very close to zero, which means that the spacecraft Y axis is always held orthogonal to the Sun direction. These two properties already validate our interpretation of the quaternions in APID 1281 as the body to ICRF rotation. We also note that for the first part of the cruise the Sun vector is just X = 1, which means that the spacecraft is pointing its X axis directly towards the Sun.

When interpreting this data it helps to know the geometry of the spacecraft body and how the body axes are placed. After TCM-1 on 2020-08-01, in the Chinese website spaceflightfans.cn the following infographic appeared. This is specially interesting because the X, Y and Z axes are drawn on the spacecraft body. One should take this kind of graphics that appear in the mainstream media with a grain of salt, as they might have been drown by an artist and not be technically accurate.

However, from analysing the quaternion data it turns out that this graphic is in fact correct. We note that the solar panels are placed along the Y axis, the high gain antenna points towards the -Z axis, and the thruster points towards the -X axis. However, both the depiction of the spacecraft’s orbit and its attitude in the graphic above are not technically correct.

One of the most important constraints to decide the attitude of a spacecraft is to orient its solar panels orthogonally to the Sun, in order to receive the maximum power. In this case, the panels can swivel around the Y axis, so by making sure that the Y axis is orthogonal to the Sun, the panels will then be able to swivel to the appropriate orientation. Many spacecraft work like this (see for example this paper about GNSS satellites).

As the spacecraft leaves Earth on its transfer orbit to Mars, it is more or less on the same orbit as Earth but ahead of it. This means that, viewed from the spacecraft, the Sun and Earth will be roughly at right angles. Thus, by pointing the X axis towards the Sun, we allow the high gain antenna on the -Z axis to point towards Earth. Therefore, pointing the X axis towards the Sun makes a lot of sense for the first days of the mission.

In fact, we can compute the spacecraft to Earth vector in body frame coordinates. To do so, we use astropy to compute the Sun position vector in GCRS coordinates, which we call $$s$$ and then write $$-(s+r)/\|s+r\|$$ as a pure quaternion $$E$$ and compute $$q^{-1}Eq$$.

We see that the Earth vector is indeed close to the -Z vector throughout all the cruise orbit so far, but not exactly, since the X coordinate is not zero. The high gain antenna can pivot some degrees (we don’t know exactly how much), so it is not necessary to point the -Z axis exactly towards Earth. We also see that the Y coordinate is close to zero.

Below we show the angle of the Sun and Earth vectors with respect to the XZ plane. We see that the Sun angle is basically zero, because the Y axis is always oriented orthogonal to the Sun for optimal illumination of the solar panels. I think that the Earth angle should also be zero. The small error we see here might have to do with how I have computed the relative position of the spacecraft and Earth.

Since we’ve seen that the Sun and Earth vectors lie in the XZ plane, it makes sense to study the Sun and Earth angles in this plane. Below we show the angle between the Sun vector and the X axis and the angle between the Earth vector and the -Z axis. Recall that this last angle needs to be small so that the high gain antenna can aim towards Earth.

This is what happens. Above I commented that on a first approximation we might think that Tianwen-1 leaves the Earth with the Sun and Earth at right angles as viewed from the spacecraft. Therefore, we start with the X axis pointing towards the Sun and the -Z axis pointing towards the Earth. However, as the spacecraft’s distance from the Sun increases, the angle between the Sun and Earth decreases.

If the X axis is always held towards the Sun, at some point the angle between the Earth and the -Z will be excessive to point the high gain antenna towards the Earth, so it is necessary to change the angle between the Sun and the X axis. As shown above, this is done in discrete steps. The angles, 0º, 15º and 20º look pretty much dialled in by hand for simplicity. In this post we saw the first of these attitude change manoeuvres: a turn of 15º about the Y axis to change the Sun angle with the X axis from 0º to 15º.

It makes sense to have the spacecraft’s attitude steering law be defined by the Sun vector. In this way, the spacecraft is turning constantly (very slowly) to track the Sun, which is easy to do accurately with a Sun sensor, and the solar panels only need to swivel when the Sun to X axis angle is changed.

So we have seen that the attitude quaternion data gives us a complete description of Tianwen-1’s attitude law in its cruise orbit. The Y axis is orthogonal to the vectors joining the spacecraft to the Sun and the Earth, and the angle between the Sun and the X axis is held to a constant simple value that is updated to prevent the angle between the Earth and the -Z axis from becoming excessively large to aim the high gain antenna.

It is interesting to study the attitude during early orbit. Below we show the real time telemetry data for the UTC morning of 2020-07-23. Recall that the spacecraft was launched at 04:41 UTC. The data shown here was collected by Paul Marsh, who was one of the first Amateurs to receive the spacecraft.

Around 06:30 we see that the spacecraft is coasting in most likely whatever attitude and angular momentum it had when it was released from the launcher. Around 06:40 the ADCS is engaged to the cruise law with a Sun to X axis angle of 0º and the spacecraft rolls quickly to aim its solar panels (compare with this attitude change manoeuvre, where it took more than 5 minutes to roll 15º).

There is a small oscillation of a few degrees which is best seen in the figures below. This might have been caused by the full ADCS not being completely enabled yet or by the control loop gains not being completely tuned for precision (as hinted by the rather fast roll when the ADCS is enabled).

The Jupyter notebook used to do the calculations and plots in this post can be found here, together with the relevant telemetry data. The space_packet_extract.py was used to extract the Space Packets from the AOS telemetry frames and classify them by APID.