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

Fix euler angles representation for strain2 #286

Merged
merged 4 commits into from
Jul 28, 2022
Merged

Fix euler angles representation for strain2 #286

merged 4 commits into from
Jul 28, 2022

Conversation

Nicogene
Copy link
Member

@Nicogene Nicogene commented Jul 25, 2022

This PR fixes the Euler angles representation on strain2.

This conversion keep count of this math:

rpy_newSens = rot2rpy(A_R_newSens) = rot2rpy(A_R_oldSens * oldSens_R_newSens) =

= rot2rpy(A_R_oldSens * (newSens_R_oldSens)^T ) =

= rot2rpy(rpy2rot(rpy_oldSens) * (newSens_R_oldSens)^T )
rpy2rot(rpy_oldSens) = B =  0     0     1
                            0    -1     0
                            1     0     0
                            
(newSens_R_oldSens)^T = A =  0    -1     0
                            -1     0     0
                             0     0    -1

C = B*A = 0     0    -1
          1     0     0
          0    -1     0

rpy_newSens = rotm2eul(C, 'XYZ') =  0 -1.5707963267949 1.5707963267949                

That results in this conversion;

x = -z
y = x
z = -y

To be tested on the hardware

@Nicogene Nicogene self-assigned this Jul 25, 2022
Nicogene added 2 commits July 27, 2022 14:19
We used to leave the axis as it is (P1) but the imu on strain2 is mounted in the configuration P6 of datasheet. This allows us to configure the imu correctly at startup and do not do any conversion when gathering the data
@Nicogene
Copy link
Member Author

Unfortunately, this analysis had some flaws and it didn't solve the problem.

Looking at the bno055 datasheet I found out that it is possible to request to bno055 a different axis mapping, we can define it at the startup of the sensor, and then the data that will publish will respect that reference system.

On strain 2 given that:
immagine

We have to define the mapping as follows:
immagine
immagine

We have

AXIS_MAP_CONFIG=00100001=0x21
AXIS_MAP_SIGN=00000111=0x07

Then with this piece of code:

#if defined(STM32HAL_BOARD_STRAIN2)
    // In strain2 we have the P6 configuration reported in the bno055 datasheet
    embot::hw::bno055::write(pImpl->config.sensor, embot::hw::bno055::Register::AXIS_MAP_CONFIG, 0x21, 5*embot::core::time1millisec);
    embot::hw::bno055::write(pImpl->config.sensor, embot::hw::bno055::Register::AXIS_MAP_SIGN, 0x07, 5*embot::core::time1millisec);
#endif

On strain2 we have the p6 configuration

immagine

This change allowed us to remove all the conversions around the code, the only conversion that remains is the one regarding the Euler angle that was addressed in robotology/icub-main#701 | #154

@Nicogene Nicogene marked this pull request as ready for review July 27, 2022 12:37
@Nicogene Nicogene added the bug label Jul 27, 2022
Copy link
Contributor

@marcoaccame marcoaccame left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@Nicogene Nicogene merged commit 2aa2ecb into robotology:master Jul 28, 2022
@Nicogene Nicogene deleted the fix/strainEul branch July 28, 2022 08:34
marcoaccame added a commit to robotology/icub-firmware-build that referenced this pull request Jul 29, 2022
compiled on 2022 july 29 w/
- icub-firmware-shared SHA-1: e9d8baf4a9af7bb623a0e5632fb6d5c559254b0c
- icub-firmware SHA-1: 2aa2ecb

differences w/ previous versions:
- strain2: it fixes the euler angle representation. See robotology/icub-firmware#286
- mtb4 and rfe: no new features. just recompilation since the original code has changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants