Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Star Tracker's Quaternion seems to be off #351

Closed
lucapizzuto99 opened this issue Aug 9, 2024 · 3 comments
Closed

Star Tracker's Quaternion seems to be off #351

lucapizzuto99 opened this issue Aug 9, 2024 · 3 comments
Assignees
Labels
Support User Support

Comments

@lucapizzuto99
Copy link

lucapizzuto99 commented Aug 9, 2024

Hi everyone,

I am developing an attitude mode to align a vector in ECI (N) frame with the b2 axis, similar to what the Sunsafe mode does.
To move from the inertial frame to the body frame I need to retrieve the inertial quaternion of the body, which should be provided by the Star Tracker in the generic_adcs/fsw/src/generic_adcs_ingest.c script as:

void Generic_ADCS_ingest_generic_st(CFE_MSG_Message_t * Msg, Generic_ADCS_DI_St_Tlm_Payload_t *St)
{
    GENERIC_STAR_TRACKER_Device_tlm_t *st = (GENERIC_STAR_TRACKER_Device_tlm_t *)Msg;

    St->valid = st->Generic_star_tracker.IsValid;
    double q[4] = {st->Generic_star_tracker.Q0, st->Generic_star_tracker.Q1, st->Generic_star_tracker.Q2, st->Generic_star_tracker.Q3};
    QxQ(q, St->qbs, St->q);
}

In particular, the QxQ method should move from the Sensor frame to the Body frame, by using the quaternion specified in generic_adcs/fsw/cfg/Inp_DI.txt as :

!!!!!!!!!!!!!!! Star Tracker !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-0.5510871 -0.4059919 -0.5108982 0.5200544 ! Quaternion from sensor to body frame

As far as I understand, then the resulting quaternion stored in the DI_St_Tlm_Payload data structure should be the body quaternion that I am looking for. However, when I confront this quaternion with the one directly retrieved from 42 in the 42Truth Sim, they are totally different.
This leads to a wrong conversion between my ECI and body frame, while the conversion becomes correct when, instead of retrieving the ST quaternion, I retrieve directly the body quaternion from 42.

Is there something that I am missing, or is perhaps the quaternion specified in Inp_DI the wrong one?

Also, to get the body quaternion from 42, I had to modify the 42 code itself to return the ST quaternion as S->B[O].qn instead of the one computed by the method in the (42sensors.c script).
For some reason, modifying the data_provider.cpp code of the ST in this way:

qn_key.append("SC[").append(std::to_string(_sc)).append("].B[0].qn"); 
std::string qn_values = _dp.get_value_for_key(qn_key);

_generic_star_tracker_data_is_valid = (valid_value == "1");
std::vector<double> data;
parse_double_vector(qn_values, data);

leads to the collapse of the ST sim.

Thanks in advance for the support, I really appreciate it!

@jlucas9 jlucas9 moved this to In Progress in NOS3 Path Forward Oct 18, 2024
@jlucas9 jlucas9 added the Support User Support label Oct 18, 2024
@jlucas9
Copy link
Contributor

jlucas9 commented Oct 18, 2024

@marksuder can you check this one out?

msuder added a commit to nasa-itc/generic_star_tracker that referenced this issue Nov 6, 2024
msuder added a commit that referenced this issue Nov 6, 2024
msuder added a commit to nasa-itc/generic_star_tracker that referenced this issue Dec 4, 2024
msuder added a commit to nasa-itc/generic_thruster that referenced this issue Dec 4, 2024
msuder added a commit to nasa-itc/sample that referenced this issue Dec 4, 2024
msuder added a commit to nasa-itc/truth_42_sim that referenced this issue Dec 9, 2024
msuder added a commit that referenced this issue Dec 17, 2024
…) rotation. This causes the DI quaternion and the truth quaternion to track each other (when the star tracker is valid).
msuder added a commit to nasa-itc/generic_adcs that referenced this issue Dec 17, 2024
…ntity (no) rotation. This causes the DI quaternion and the truth quaternion to track each other (when the star tracker is valid).
@msuder
Copy link
Contributor

msuder commented Dec 17, 2024

Change Inp_DI.txt and SC_NOS3.txt to both use the identity (no) rotation. This causes the DI quaternion and the truth quaternion to track each other (when the star tracker is valid).

This issue is being closed and a new issue is being opened to get Inp_DI.txt and SC_NOS3.txt to have inverse, non-identity rotations for the star tracker.

@msuder
Copy link
Contributor

msuder commented Dec 17, 2024

The new issue to track fixing the inverse rotations is: #431.

jlucas9 added a commit to nasa-itc/generic_star_tracker that referenced this issue Jan 6, 2025
[nasa/nos3#351] Fix initialization of _not_parsed flag.  Debug tweaks.
jlucas9 added a commit to nasa-itc/generic_thruster that referenced this issue Jan 6, 2025
nasa/nos3#351 - Fix initialization and usag…
jlucas9 added a commit to nasa-itc/sample that referenced this issue Jan 6, 2025
jlucas9 added a commit to nasa-itc/truth_42_sim that referenced this issue Jan 6, 2025
nasa/nos3#351 - Fix quaternion initializati…
jlucas9 added a commit to nasa-itc/generic_adcs that referenced this issue Jan 6, 2025
nasa/nos3#351 - Change Inp_DI.txt and SC_NO…
jlucas9 added a commit that referenced this issue Jan 6, 2025
[#351] Resolve star tracker quaternion issue
@github-project-automation github-project-automation bot moved this from In Progress to Done in NOS3 Path Forward Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support User Support
Projects
Status: Done
Development

No branches or pull requests

4 participants