|
@@ -11,7 +11,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
import rospy
|
|
|
import string
|
|
|
import math
|
|
@@ -21,6 +20,7 @@ import sys
|
|
|
from tf.transformations import quaternion_from_euler
|
|
|
from dynamic_reconfigure.server import Server
|
|
|
from rasp_imu_hat_6dof.cfg import imuConfig
|
|
|
+from std_msgs.msg import Float32
|
|
|
from sensor_msgs.msg import Imu
|
|
|
from imu_data import MyIMU
|
|
|
|
|
@@ -37,42 +37,33 @@ def reconfig_callback(config, level):
|
|
|
|
|
|
rospy.init_node("imu_node")
|
|
|
|
|
|
-
|
|
|
-topic_name = rospy.get_param('~pub_topic', 'imu')
|
|
|
+
|
|
|
+data_topic_name = rospy.get_param('~pub_data_topic', 'imu_data')
|
|
|
link_name = rospy.get_param('~link_name', 'base_imu_link')
|
|
|
-pub_hz = rospy.get_param('~pub_hz', '10')
|
|
|
+data_pub_hz = rospy.get_param('~data_pub_hz', '10')
|
|
|
+temp_pub_hz = rospy.get_param('~temp_pub_hz', '1')
|
|
|
|
|
|
|
|
|
-pub = rospy.Publisher(topic_name, Imu, queue_size=1)
|
|
|
+data_pub = rospy.Publisher(data_topic_name, Imu, queue_size=1)
|
|
|
+temp_pub = rospy.Publisher(temp_topic_name, Float32, queue_size=1)
|
|
|
srv = Server(imuConfig, reconfig_callback)
|
|
|
imuMsg = Imu()
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
imuMsg.orientation_covariance = [
|
|
|
0.0025 , 0 , 0,
|
|
|
0, 0.0025, 0,
|
|
|
0, 0, 0.0025
|
|
|
]
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
imuMsg.angular_velocity_covariance = [
|
|
|
0.02, 0 , 0,
|
|
|
0 , 0.02, 0,
|
|
|
0 , 0 , 0.02
|
|
|
]
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
imuMsg.linear_acceleration_covariance = [
|
|
|
0.04 , 0 , 0,
|
|
|
0 , 0.04, 0,
|
|
@@ -83,9 +74,8 @@ seq=0
|
|
|
|
|
|
accel_factor = 9.806/256.0
|
|
|
|
|
|
-
|
|
|
myIMU = MyIMU(0x50)
|
|
|
-rate = rospy.Rate(pub_hz)
|
|
|
+rate = rospy.Rate(data_pub_hz)
|
|
|
|
|
|
while not rospy.is_shutdown():
|
|
|
myIMU.get_YPRAG()
|
|
@@ -101,7 +91,7 @@ while not rospy.is_shutdown():
|
|
|
roll = float(myIMU.raw_roll)*degrees2rad
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
imuMsg.linear_acceleration.x = float(myIMU.raw_ax)*accel_factor
|
|
|
imuMsg.linear_acceleration.y = float(myIMU.raw_ay)*accel_factor
|
|
|
imuMsg.linear_acceleration.z = float(myIMU.raw_az)*accel_factor
|
|
@@ -110,12 +100,14 @@ while not rospy.is_shutdown():
|
|
|
imuMsg.angular_velocity.y = float(myIMU.raw_gy)*degrees2rad
|
|
|
imuMsg.angular_velocity.z = float(myIMU.raw_gz)*degrees2rad
|
|
|
|
|
|
+
|
|
|
myIMU.get_quatern()
|
|
|
imuMsg.orientation.x = myIMU.raw_q1
|
|
|
imuMsg.orientation.y = myIMU.raw_q2
|
|
|
imuMsg.orientation.z = myIMU.raw_q3
|
|
|
imuMsg.orientation.w = myIMU.raw_q0
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -125,8 +117,12 @@ while not rospy.is_shutdown():
|
|
|
imuMsg.header.stamp= rospy.Time.now()
|
|
|
imuMsg.header.frame_id = link_name
|
|
|
imuMsg.header.seq = seq
|
|
|
- pub.publish(imuMsg)
|
|
|
-
|
|
|
seq = seq + 1
|
|
|
+ data_pub.publish(imuMsg)
|
|
|
+
|
|
|
+
|
|
|
+ myIMU.get_temp()
|
|
|
+ temp_pub.publish(myIMU.temp)
|
|
|
+
|
|
|
rate.sleep()
|
|
|
|