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

Adjust scale for acc and gyro #23

Merged
merged 1 commit into from
Jan 16, 2024
Merged

Adjust scale for acc and gyro #23

merged 1 commit into from
Jan 16, 2024

Conversation

iory
Copy link
Owner

@iory iory commented Jan 16, 2024

Related to #14
This PR sets the scales for gyro and acc to meters and degrees per second.

test code

#!/usr/bin/env python
import rospy
from sensor_msgs.msg import Imu
import numpy as np


def callback(msg):
    angular_norm = np.sqrt(msg.angular_velocity.x ** 2
                           + msg.angular_velocity.y ** 2
                           + msg.angular_velocity.z ** 2)

    acc_norm = np.sqrt(msg.linear_acceleration.x ** 2
                       + msg.linear_acceleration.y ** 2
                       + msg.linear_acceleration.z ** 2)

    if acc_norm > 1.4:
        rospy.loginfo("Detect impact {}".format(acc_norm))


def listener():
    rospy.init_node('listener', anonymous=True)
    rospy.Subscriber("imu", Imu, callback, queue_size=10)
    rospy.spin()

if __name__ == '__main__':
    listener()
[INFO] [1705382302.899259]: Detect impact 1.4350709673397826
[INFO] [1705382304.198912]: Detect impact 2.5297361374467084
[INFO] [1705382305.154315]: Detect impact 2.13326023903858
[INFO] [1705382321.513858]: Detect impact 1.4318167515840723
[INFO] [1705382321.616729]: Detect impact 1.6437944926118708
[INFO] [1705382321.776413]: Detect impact 1.740089856369743
[INFO] [1705382322.314692]: Detect impact 1.5967120085012034
[INFO] [1705382327.652455]: Detect impact 3.636909679445078
[INFO] [1705382329.275340]: Detect impact 2.246232104121857
[INFO] [1705382330.204769]: Detect impact 1.537381589994245

@iory iory merged commit 594f1d7 into master Jan 16, 2024
3 checks passed
@iory iory deleted the imu branch January 16, 2024 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant