Skip to content

Conversation

@maloel
Copy link
Contributor

@maloel maloel commented Jun 17, 2024

No API existed to get the combined motion data.
The previous API in rs2::motion_frame is get_motion_data() returning rs2_vector which ASSUMES the data type. This should be used with RS2_FORMAT_MOTION_XYZ32F.
I did the same: added get_combined_motion_data() returning rs2_combined_motion. This should be used with RS2_FORMAT_COMBINED_MOTION.
I.e., it is up to the user to call the right one.

Added Python API.

Tracked on [RSDEV-2243]

@maloel
Copy link
Contributor Author

maloel commented Jun 18, 2024

I pushed a change to the comments in rs_frame.hpp, to make it clearer when to use either function.

@maloel maloel merged commit 4f9227f into realsenseai:development Jun 18, 2024
@maloel maloel deleted the motion-py branch June 18, 2024 05:37
@maloel
Copy link
Contributor Author

maloel commented Oct 10, 2024

Just for reference, an example of usage:

def frame_callback( frame ):
    global total_gravity, n_gravity
    m = frame.as_motion_frame()
    if m:
        md = m.get_combined_motion_data()
        log.d( md )
        la = md.linear_acceleration
        total_gravity += math.sqrt( la.x * la.x + la.y * la.y + la.z * la.z )
        n_gravity += 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants