Browse Source

完善数据显示功能,直接使用rviz显示

corvin 5 years ago
parent
commit
8533a42e40

+ 1 - 2
CMakeLists.txt

@@ -34,6 +34,5 @@ install(DIRECTORY src
 
 catkin_install_python(PROGRAMS 
 	nodes/imu_node.py
-	nodes/display_3D_visualization.py
-        DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/nodes
+    DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/nodes
 )

+ 141 - 0
cfg/imu_display.rviz

@@ -0,0 +1,141 @@
+Panels:
+  - Class: rviz/Displays
+    Help Height: 123
+    Name: Displays
+    Property Tree Widget:
+      Expanded:
+        - /Global Options1
+        - /Grid1/Offset1
+        - /Imu1/Status1
+        - /Imu1/Box properties1
+        - /Imu1/Axes properties1
+      Splitter Ratio: 0.486111104
+    Tree Height: 730
+  - Class: rviz/Selection
+    Name: Selection
+  - Class: rviz/Tool Properties
+    Expanded:
+      - /2D Pose Estimate1
+      - /2D Nav Goal1
+      - /Publish Point1
+    Name: Tool Properties
+    Splitter Ratio: 0.588679016
+  - Class: rviz/Views
+    Expanded:
+      - /Current View1
+    Name: Views
+    Splitter Ratio: 0.5
+  - Class: rviz/Time
+    Experimental: false
+    Name: Time
+    SyncMode: 0
+    SyncSource: ""
+Toolbars:
+  toolButtonStyle: 2
+Visualization Manager:
+  Class: ""
+  Displays:
+    - Alpha: 0.699999988
+      Cell Size: 1
+      Class: rviz/Grid
+      Color: 50; 115; 54
+      Enabled: true
+      Line Style:
+        Line Width: 0.0299999993
+        Value: Lines
+      Name: Grid
+      Normal Cell Count: 0
+      Offset:
+        X: 0
+        Y: 0
+        Z: 0
+      Plane: XY
+      Plane Cell Count: 10
+      Reference Frame: <Fixed Frame>
+      Value: true
+    - Acceleration properties:
+        Acc. vector alpha: 0.800000012
+        Acc. vector color: 179; 200; 255
+        Acc. vector scale: 0.0500000007
+        Derotate acceleration: true
+        Enable acceleration: true
+      Axes properties:
+        Axes scale: 1
+        Enable axes: true
+      Box properties:
+        Box alpha: 0.600000024
+        Box color: 255; 0; 0
+        Enable box: true
+        x_scale: 0.5
+        y_scale: 0.5
+        z_scale: 0.5
+      Class: rviz_imu_plugin/Imu
+      Enabled: true
+      Name: Imu
+      Topic: /imu
+      Unreliable: false
+      Value: true
+      fixed_frame_orientation: true
+  Enabled: true
+  Global Options:
+    Background Color: 45; 32; 41
+    Default Light: true
+    Fixed Frame: base_imu_link
+    Frame Rate: 30
+  Name: root
+  Tools:
+    - Class: rviz/Interact
+      Hide Inactive Objects: true
+    - Class: rviz/MoveCamera
+    - Class: rviz/Select
+    - Class: rviz/FocusCamera
+    - Class: rviz/Measure
+    - Class: rviz/SetInitialPose
+      Topic: /initialpose
+    - Class: rviz/SetGoal
+      Topic: /move_base_simple/goal
+    - Class: rviz/PublishPoint
+      Single click: true
+      Topic: /clicked_point
+  Value: true
+  Views:
+    Current:
+      Class: rviz/Orbit
+      Distance: 8.40952873
+      Enable Stereo Rendering:
+        Stereo Eye Separation: 0.0599999987
+        Stereo Focal Distance: 1
+        Swap Stereo Eyes: false
+        Value: false
+      Focal Point:
+        X: 0.0269238316
+        Y: 0.0480619296
+        Z: 0.0609069802
+      Focal Shape Fixed Size: true
+      Focal Shape Size: 0.0500000007
+      Invert Z Axis: false
+      Name: Current View
+      Near Clip Distance: 0.00999999978
+      Pitch: 0.545399547
+      Target Frame: <Fixed Frame>
+      Value: Orbit (rviz)
+      Yaw: 1.29048622
+    Saved: ~
+Window Geometry:
+  Displays:
+    collapsed: false
+  Height: 1056
+  Hide Left Dock: false
+  Hide Right Dock: true
+  QMainWindow State: 000000ff00000000fd00000004000000000000016a00000396fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006100fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000002800000396000000d700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002e2fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a005600690065007700730000000028000002e2000000ad00fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000007800000003efc0100000002fb0000000800540069006d00650100000000000007800000030000fffffffb0000000800540069006d00650100000000000004500000000000000000000006100000039600000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
+  Selection:
+    collapsed: false
+  Time:
+    collapsed: false
+  Tool Properties:
+    collapsed: false
+  Views:
+    collapsed: true
+  Width: 1920
+  X: 1600
+  Y: 24

+ 0 - 0
config/param.yaml → cfg/param.yaml


+ 0 - 4
launch/imu-display.launch

@@ -1,4 +0,0 @@
-<launch>
-  <node pkg="rasp_imu_hat_6dof" type="display_3D_visualization.py" name="display_3D_visualization_node" output="screen">
-  </node>
-</launch>

+ 0 - 9
launch/imu-pub-and-display.launch

@@ -1,9 +0,0 @@
-<launch>
-  <arg name="imu_config_file" default="$(find rasp_imu_hat_6dof)/config/param.yaml"/>
-  <node pkg="rasp_imu_hat_6dof" type="imu_node.py" name="imu_node" output="screen">
-    <rosparam file="$(arg imu_config_file)" command="load"/>
-  </node>
-
-  <node pkg="rasp_imu_hat_6dof" type="display_3D_visualization.py" name="display_3D_visualization_node" output="screen">
-  </node>
-</launch>

+ 0 - 7
launch/imu-pub.launch

@@ -1,7 +0,0 @@
-<launch>
-  <arg name="imu_config_file" default="$(find rasp_imu_hat_6dof)/config/param.yaml"/>
-  <node pkg="rasp_imu_hat_6dof" type="imu_node.py" name="imu_node" output="screen">
-    <rosparam file="$(arg imu_config_file)" command="load"/>
-  </node>
-</launch>
-

+ 7 - 0
launch/imu_data_pub.launch

@@ -0,0 +1,7 @@
+<launch>
+  <arg name="imu_cfg_file" default="$(find rasp_imu_hat_6dof)/cfg/param.yaml"/>
+  <node pkg="rasp_imu_hat_6dof" type="imu_node.py" name="imu_node" output="screen">
+    <rosparam file="$(arg imu_cfg_file)" command="load"/>
+  </node>
+</launch>
+

+ 5 - 0
launch/imu_rviz_display.launch

@@ -0,0 +1,5 @@
+<launch>
+  <node pkg="rviz" type="rviz" name="imu_rviz_node" 
+        args="-d $(find rasp_imu_hat_6dof)/cfg/imu_display.rviz">
+  </node>
+</launch>

+ 0 - 144
nodes/display_3D_visualization.py

@@ -1,144 +0,0 @@
-#!/usr/bin/env python
-
-import rospy
-from visual import *
-import math
-import wx
-
-from sensor_msgs.msg import Imu
-from tf.transformations import euler_from_quaternion
-
-rad2degrees = 180.0/math.pi
-precision = 2 #round to this number of digits
-yaw_offset = 0 #used to align animation upon key press
-
-
-#Create shutdown hook to kill visual displays
-def shutdown_hook():
-    #print "Killing displays"
-    wx.Exit()
-
-#register shutdown hook
-rospy.on_shutdown(shutdown_hook)
-
-
-# Main scene
-scene=display(title="9DOF Razor IMU Main Screen")
-scene.range=(1.3,1.3,1.3)
-scene.forward = (1,0,-0.25)
-# Change reference axis (x,y,z) - z is up
-scene.up=(0,0,1)
-scene.width=500
-scene.height=500
-
-# Second scene (Roll, Pitch, Yaw)
-scene2 = display(title='6DOF IMU Roll, Pitch, Yaw',x=550, y=0, width=500, height=500,center=(0,0,0), background=(0,0,0))
-scene2.range=(1,1,1)
-scene2.select()
-#Roll, Pitch, Yaw
-#Default reference, i.e. x runs right, y runs up, z runs backward (out of screen)
-cil_roll = cylinder(pos=(-0.5,0.3,0),axis=(0.2,0,0),radius=0.01,color=color.red)
-cil_roll2 = cylinder(pos=(-0.5,0.3,0),axis=(-0.2,0,0),radius=0.01,color=color.red)
-cil_pitch = arrow(pos=(0.5,0.3,0),axis=(0,0,-0.4),shaftwidth=0.02,color=color.green)
-arrow_course = arrow(pos=(0.0,-0.4,0),color=color.cyan,axis=(0,0.2,0), shaftwidth=0.02, fixedwidth=1)
-
-#Roll,Pitch,Yaw labels
-label(pos=(-0.5,0.6,0),text="Roll (degrees / radians)",box=0,opacity=0)
-label(pos=(0.5,0.6,0),text="Pitch (degrees / radians)",box=0,opacity=0)
-label(pos=(0.0,0.02,0),text="Yaw (degrees / radians)",box=0,opacity=0)
-label(pos=(0.0,-0.16,0),text="E",box=0,opacity=0,color=color.yellow)
-label(pos=(0.0,-0.64,0),text="W",box=0,opacity=0,color=color.yellow)
-label(pos=(-0.24,-0.4,0),text="N",box=0,opacity=0,color=color.yellow)
-label(pos=(0.24,-0.4,0),text="S",box=0,opacity=0,color=color.yellow)
-label(pos=(0.18,-0.22,0),height=7,text="SE",box=0,color=color.yellow)
-label(pos=(-0.18,-0.22,0),height=7,text="NE",box=0,color=color.yellow)
-label(pos=(0.18,-0.58,0),height=7,text="SW",box=0,color=color.yellow)
-label(pos=(-0.18,-0.58,0),height=7,text="NW",box=0,color=color.yellow)
-
-rollLabel = label(pos=(-0.5,0.52,0),text="-",box=0,opacity=0,height=12)
-pitchLabel = label(pos=(0.5,0.52,0),text="-",box=0,opacity=0,height=12)
-yawLabel = label(pos=(0,-0.06,0),text="-",box=0,opacity=0,height=12)
-
-#acceleration labels
-label(pos=(0,0.9,0),text="Linear Acceleration x / y / z (m/s^2)",box=0,opacity=0)
-label(pos=(0,-0.8,0),text="Angular Velocity x / y / z (rad/s)",box=0,opacity=0)
-linAccLabel = label(pos=(0,0.82,0),text="-",box=0,opacity=0,height=12)
-angVelLabel = label(pos=(0,-0.88,0),text="-",box=0,opacity=0,height=12)
-
-# Main scene objects
-scene.select()
-# Reference axis (x,y,z) - using ROS conventions (REP 103) - z is up, y left (north, 90 deg), x is forward (east, 0 deg)
-# In visual, z runs up, x runs forward, y runs left (see scene.up command earlier)
-# So everything is good
-arrow(color=color.green,axis=(1,0,0), shaftwidth=0.04, fixedwidth=1)
-arrow(color=color.green,axis=(0,1,0), shaftwidth=0.04 , fixedwidth=1)
-arrow(color=color.green,axis=(0,0,1), shaftwidth=0.04, fixedwidth=1)
-
-# labels
-label(pos=(0,0,-1.2),text="Press 'a' to align",box=0,opacity=0)
-label(pos=(1,0.1,0),text="X",box=0,opacity=0)
-label(pos=(0,1,-0.1),text="Y",box=0,opacity=0)
-label(pos=(0,-0.1,1),text="Z",box=0,opacity=0)
-# IMU object
-platform = box(length=1.0, height=0.05, width=0.65, color=color.red,up=(0,0,1),axis=(-1,0,0))
-p_line = box(length=1.1,height=0.08,width=0.1,color=color.yellow,up=(0,0,1),axis=(-1,0,0))
-plat_arrow = arrow(length=-0.8,color=color.cyan,up=(0,0,1),axis=(-1,0,0), shaftwidth=0.06, fixedwidth=1)
-plat_arrow_up = arrow(length=0.4,color=color.cyan,up=(-1,0,0),axis=(0,0,1), shaftwidth=0.06, fixedwidth=1)
-rospy.init_node("display_3D_visualization_node")
-
-def processIMU_message(imuMsg):
-    global yaw_offset
-
-    roll=0
-    pitch=0
-    yaw=0
-
-    quaternion = (
-      imuMsg.orientation.x,
-      imuMsg.orientation.y,
-      imuMsg.orientation.z,
-      imuMsg.orientation.w)
-    (roll,pitch,yaw) = euler_from_quaternion(quaternion)
-
-    #add align offset to yaw
-    yaw += yaw_offset
-
-    axis=(-cos(pitch)*cos(yaw),-cos(pitch)*sin(yaw),sin(pitch))
-    up=(sin(roll)*sin(yaw)+cos(roll)*sin(pitch)*cos(yaw),-sin(roll)*cos(yaw)+cos(roll)*sin(pitch)*sin(yaw),cos(roll)*cos(pitch))
-    platform.axis=axis
-    platform.up=up
-    platform.length=1.0
-    plat_arrow_up.axis=up
-    plat_arrow_up.up=axis
-    plat_arrow_up.length=0.4
-    plat_arrow.axis=axis
-    plat_arrow.up=up
-    plat_arrow.length=-0.8
-    p_line.axis=axis
-    p_line.up=up
-    p_line.length=1.1
-    cil_roll.axis=(-0.2*cos(roll),0.2*sin(roll),0)
-    cil_roll2.axis=(0.2*cos(roll),-0.2*sin(roll),0)
-    cil_pitch.axis=(0,-0.4*sin(pitch),-0.4*cos(pitch))
-    #remove yaw_offset from yaw display
-    arrow_course.axis=(-0.2*sin(yaw-yaw_offset),0.2*cos(yaw-yaw_offset),0)
-
-    #display in degrees / radians
-    rollLabel.text = str(round(roll*rad2degrees, precision)) + " / " + str(round(roll,precision))
-    pitchLabel.text = str(round(pitch*rad2degrees, precision)) + " / " + str(round(pitch, precision))
-    #remove yaw_offset from yaw display
-    yawLabel.text = str(round((yaw-yaw_offset)*rad2degrees, precision)) + " / " + str(round((yaw-yaw_offset), precision))
-
-    linAccLabel.text = str(round(imuMsg.linear_acceleration.x, precision)) + " / " + str(round(imuMsg.linear_acceleration.y, precision)) + " / " + str(round(imuMsg.linear_acceleration.z, precision))
-    angVelLabel.text = str(round(imuMsg.angular_velocity.x, precision)) + " / " + str(round(imuMsg.angular_velocity.y, precision)) + " / " + str(round(imuMsg.angular_velocity.z, precision))
-
-    #check for align key press - if pressed, next refresh will be aligned
-    if scene.kb.keys: # event waiting to be processed?
-        s = scene.kb.getkey() # get keyboard info
-        if s == 'a':
-            #align key pressed - align
-            yaw_offset += -yaw
-
-sub = rospy.Subscriber('imu', Imu, processIMU_message)
-rospy.spin()
-