#! /usr/bin/python

import PyKDL
import rospy
from sensor_msgs.msg import Imu
from nav_msgs.msg import Odometry
from geometry_msgs.msg import Twist
from math import *
import threading
import os
import subprocess
import yaml def quat_to_angle(quat):
rot = PyKDL.Rotation.Quaternion(quat.x, quat.y, quat.z, quat.w)
return rot.GetRPY()[]
def normalize_angle(angle):
res = angle
while res > pi:
res -= 2.0*pi
while res < -pi:
res += 2.0*pi
return res class CalibrateRobot:
def __init__(self):
self.lock = threading.Lock()
self.sub_imu = rospy.Subscriber('imu', Imu, self.imu_cb)
self.last_imu_angle =
self.imu_angle =
while not rospy.is_shutdown():
rospy.sleep(0.3)
rospy.loginfo("imu_angle:"+str((self.imu_angle)*/3.1415926)) def imu_cb(self, msg):
with self.lock:
angle = quat_to_angle(msg.orientation)
self.imu_angle = angle
self.imu_time = msg.header.stamp def main():
rospy.init_node('scan_to_angle')
CalibrateRobot() if __name__ == '__main__':
main()

最新文章

  1. thinkphp 3.2.3 动态修改conf配置文件
  2. Implement Queue using Stacks
  3. Freemarker 各种格式化
  4. javascript的对象 和 JSON 对象?
  5. 原生JavaScript技巧大收集(11~20)-(终于又被我找到这篇文章了)
  6. AFN框架基本使用
  7. LightOJ1057 Collecting Gold(状压DP)
  8. 操作系统:cpu调度 6-25
  9. About Curah
  10. 山寨小小军团开发笔记 之 Arrow Projectile
  11. QUI操作超时弹出登录窗口登录的处理方式
  12. L010-oldboy-mysql-dba-lesson10
  13. Windows 键盘操作快捷方式积累
  14. EntityFramework 异常 -- An entity object cannot be referenced by multiple instances of IEntityChangeTracker
  15. pythond对象、异常、反射的学习笔记
  16. Eclipse配置注释模板详细介绍
  17. mssql sql server 其它系统函数 parsename 点语法字符串分割函数应用简介
  18. git format-patch制作内核补丁
  19. npm常用模块
  20. How to write a professional email?

热门文章

  1. GRPC代替webapi Demo。
  2. interface Part1(接口详解)
  3. iOS - Objective-C 关联(objc_setAssociatedObject、objc_getAssociatedObject、objc_removeAssociatedObjects)
  4. 【转载】 C#中使用Count方法获取List集合中符合条件的个数
  5. 【前端适配】vw单位移动端适配方案
  6. c# 属性成员
  7. MySQL面试问题
  8. VGridControl 使用技巧
  9. 更新studio 3T的试用期时间
  10. 神经网络(1)--Non-linear hypotheses,为什么我们要学习神经网络这种算法来处理non-linear hypotheses