1 Star 1 Fork 2

gzl2012/gazebo_drone_tutorials

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
imu_processing.py 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
李谨杰 提交于 2020-03-28 22:39 . use robot_localization successfully
#!/usr/bin/env python
# coding=utf-8
'''
@Author : LI Jinjie
@Date : 2020-03-27 11:24:31
@LastEditors : LI Jinjie
@LastEditTime : 2020-03-28 20:40:10
@Units : None
@Description : file content
@Dependencies : None
@NOTICE : None
'''
import rospy
from sensor_msgs.msg import Imu
import numpy as np
imu = Imu()
def imu_callback(data):
global imu
imu.header.frame_id = 'uav1/odom'
imu = data
cov = np.eye(3)
cov[0, 0] = np.square(0.1) # (x error)^2
cov[1, 1] = np.square(0.1) # (y error)^2
cov[2, 2] = np.square(0.1) # (z error)^2
imu.linear_acceleration_covariance = tuple(cov.ravel().tolist())
def sub():
sub = rospy.Subscriber('/uav1/raw_imu', Imu, imu_callback)
def pub():
global imu
rospy.init_node('imu_processing', anonymous=True)
print 'imu_processing_node is running......'
sub = rospy.Subscriber('/uav1/raw_imu', Imu, imu_callback)
pub = rospy.Publisher('/imu_new', Imu, queue_size=10)
rate = rospy.Rate(100) # 100hz
while not rospy.is_shutdown():
pub.publish(imu)
rate.sleep()
if __name__ == '__main__':
try:
pub()
except rospy.ROSInterruptException:
pass
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gzl2012/gazebo_drone_tutorials.git
git@gitee.com:gzl2012/gazebo_drone_tutorials.git
gzl2012
gazebo_drone_tutorials
gazebo_drone_tutorials
master

搜索帮助