Skip to content

Commit 77a099a

Browse files
committed
Added first stab at rviz_python_tutorial
1 parent 01dd47e commit 77a099a

File tree

6 files changed

+189
-0
lines changed

6 files changed

+189
-0
lines changed

rviz_python_tutorial/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 2.4.6)
2+
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
3+
rosbuild_init()

rviz_python_tutorial/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include $(shell rospack find mk)/cmake.mk

rviz_python_tutorial/config.myviz

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Panels:
2+
[]
3+
Visualization Manager:
4+
Class: ""
5+
Displays:
6+
- Alpha: 0.5
7+
Cell Size: 1
8+
Class: rviz/Grid
9+
Color: 160; 160; 164
10+
Enabled: true
11+
Line Style:
12+
Line Width: 0.03
13+
Value: Billboards
14+
Name: Grid
15+
Normal Cell Count: 0
16+
Offset:
17+
Value: 0; 0; 0
18+
X: 0
19+
Y: 0
20+
Z: 0
21+
Plane: XY
22+
Plane Cell Count: 10
23+
Reference Frame: <Fixed Frame>
24+
Value: true
25+
Enabled: true
26+
Global Options:
27+
Background Color: 48; 48; 48
28+
Fixed Frame: /map
29+
Name: root
30+
Tools:
31+
- Class: rviz/MoveCamera
32+
- Class: rviz/Interact
33+
- Class: rviz/Select
34+
- Class: rviz/SetInitialPose
35+
Topic: /initialpose
36+
- Class: rviz/SetGoal
37+
Topic: /move_base_simple/goal
38+
Value: true
39+
Views:
40+
Current:
41+
Class: rviz/Orbit
42+
Distance: 23.7169
43+
Focal Point:
44+
Value: 2.265e-06; 3.8147e-06; -3.8147e-06
45+
X: 2.26498e-06
46+
Y: 3.8147e-06
47+
Z: -3.8147e-06
48+
Name: Current View
49+
Near Clip Distance: 0.01
50+
Pitch: 0.349797
51+
Target Frame: <Fixed Frame>
52+
Value: Orbit (rviz)
53+
Yaw: 2.6004
54+
Saved:
55+
- Class: rviz/Orbit
56+
Distance: 23.7169
57+
Focal Point:
58+
Value: 2.265e-06; 3.8147e-06; -3.8147e-06
59+
X: 2.26498e-06
60+
Y: 3.8147e-06
61+
Z: -3.8147e-06
62+
Name: Top View
63+
Near Clip Distance: 0.01
64+
Pitch: 1.5698
65+
Target Frame: <Fixed Frame>
66+
Value: Orbit (rviz)
67+
Yaw: 1.5654
68+
- Class: rviz/Orbit
69+
Distance: 23.7169
70+
Focal Point:
71+
Value: 2.265e-06; 3.8147e-06; -3.8147e-06
72+
X: 2.26498e-06
73+
Y: 3.8147e-06
74+
Z: -3.8147e-06
75+
Name: Side View
76+
Near Clip Distance: 0.01
77+
Pitch: 0.0347963
78+
Target Frame: <Fixed Frame>
79+
Value: Orbit (rviz)
80+
Yaw: 1.5854
81+
Window Geometry:
82+
Height: 1406
83+
Hide Left Dock: false
84+
Hide Right Dock: false
85+
QMainWindow State: 000000ff00000000fd00000004000000000000013c00000487fc0200000007fb000000100044006900730070006c0061007900730100000041000002930000000000000000fb0000001200530065006c0065006300740069006f006e01000000410000013a0000000000000000fb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb0000000c00540065006c0065006f00700100000041000004870000000000000000fb0000000c0042007500740074006f006e01000003de000001320000000000000000000000010000010f00000487fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a005600690065007700730100000041000004870000000000000000fb0000001200530065006c0065006300740069006f006e010000025a000000b2000000000000000000000002000004b0000000ddfc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000005ce0000006afc0100000003fb0000000800540069006d00650000000000000004b00000000000000000fb0000000800540069006d00650100000000000004500000000000000000fb0000001c0045007800740072006100200043006f006e00740072006f006c00730000000000000005ce000000c200ffffff000005ce0000051f00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730000000000ffffffff0000000000000000
86+
Width: 1508
87+
X: 134
88+
Y: 52

rviz_python_tutorial/manifest.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<package>
2+
<description brief="rviz_python_tutorial">
3+
4+
Tutorial demonstrating the embedding of rviz visualization in a python program.
5+
6+
</description>
7+
<author>Dave Hershberger</author>
8+
<license>BSD</license>
9+
<review status="unreviewed" notes=""/>
10+
<url>http://ros.org/wiki/rviz_python_tutorial</url>
11+
<depend package="rviz"/>
12+
<export>
13+
<rosdoc config="${prefix}/rosdoc.yaml"/>
14+
</export>
15+
</package>

rviz_python_tutorial/myviz

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env python
2+
3+
import roslib; roslib.load_manifest('rviz_python_tutorial')
4+
import sys
5+
6+
from python_qt_binding.QtGui import *
7+
from python_qt_binding.QtCore import *
8+
9+
import rviz
10+
11+
class MyViz( QWidget ):
12+
def __init__(self):
13+
QWidget.__init__(self)
14+
15+
self.frame = rviz.VisualizationFrame()
16+
self.frame.setSplashPath( "" )
17+
self.frame.initialize()
18+
19+
reader = rviz.YamlConfigReader()
20+
config = rviz.Config()
21+
reader.readFile( config, "config.myviz" )
22+
self.frame.load( config )
23+
self.frame.setMenuBar( None )
24+
self.frame.setStatusBar( None )
25+
self.frame.setHideButtonVisibility( False )
26+
self.frame.show()
27+
28+
self.manager = self.frame.getManager()
29+
self.grid_display = self.manager.getRootDisplayGroup().getDisplayAt( 0 )
30+
31+
layout = QVBoxLayout()
32+
layout.addWidget( self.frame )
33+
34+
thickness_slider = QSlider( Qt.Horizontal )
35+
thickness_slider.setTracking( True )
36+
thickness_slider.setMinimum( 1 )
37+
thickness_slider.setMaximum( 1000 )
38+
thickness_slider.valueChanged.connect( self.onThicknessSliderChanged )
39+
layout.addWidget( thickness_slider )
40+
41+
h_layout = QHBoxLayout()
42+
43+
top_button = QPushButton( "Top View" )
44+
top_button.clicked.connect( self.onTopButtonClick )
45+
h_layout.addWidget( top_button )
46+
47+
side_button = QPushButton( "Side View" )
48+
side_button.clicked.connect( self.onSideButtonClick )
49+
h_layout.addWidget( side_button )
50+
51+
layout.addLayout( h_layout )
52+
53+
self.setLayout( layout )
54+
55+
def onThicknessSliderChanged( self, new_value ):
56+
if self.grid_display != None:
57+
self.grid_display.subProp( "Line Style" ).subProp( "Line Width" ).setValue( new_value / 1000.0 )
58+
59+
def onTopButtonClick( self ):
60+
self.switchToView( "Top View" );
61+
62+
def onSideButtonClick( self ):
63+
self.switchToView( "Side View" );
64+
65+
def switchToView( self, view_name ):
66+
view_man = self.manager.getViewManager()
67+
for i in range( view_man.getNumViews() ):
68+
if view_man.getViewAt( i ).getName() == view_name:
69+
view_man.setCurrentFrom( view_man.getViewAt( i ))
70+
return
71+
print( "Did not find view named %s." % view_name )
72+
73+
if __name__ == '__main__':
74+
app = QApplication( sys.argv )
75+
76+
myviz = MyViz()
77+
myviz.resize( 500, 500 )
78+
myviz.show()
79+
80+
app.exec_()

rviz_python_tutorial/rosdoc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- builder: sphinx
2+
sphinx_root_dir: doc-src

0 commit comments

Comments
 (0)