|
1 | 1 | require 'orocos'
|
2 |
| -require 'readline' |
3 | 2 | require 'vizkit'
|
4 | 3 | include Orocos
|
5 | 4 |
|
6 | 5 | ## Initialize orocos ##
|
7 | 6 | Orocos.initialize
|
8 | 7 |
|
9 |
| -##TODO THIS IS A BUG |
10 |
| -Orocos.load_typekit('base') |
11 |
| - |
12 | 8 | ## create a widget for 3d display
|
13 | 9 | view3d = Vizkit.default_loader.create_widget('vizkit::QVizkitWidget')
|
14 | 10 |
|
|
18 | 14 | ## load and add the 3d plugin for the rock
|
19 | 15 | vizkit_rock = view3d.createPlugin('rock_tutorial', 'RockVisualization')
|
20 | 16 |
|
21 |
| -## Execute the deployment 'rock_tutorial' ## |
22 |
| -Orocos.run 'rock_tutorial' do |
23 |
| - |
24 |
| - ## Get a specific task context ## |
25 |
| - rockControl = TaskContext.get 'rock_tutorial_control' |
26 |
| - |
| 17 | +## Execute the deployments 'rock_tutorial' and 'joystick_local' ## |
| 18 | +Orocos.run 'rock_tutorial', 'joystick' do |
| 19 | + |
27 | 20 | ## Connect port to vizkit plugin
|
28 |
| - con = Vizkit.connect_port_to 'rock_tutorial_control', 'pose', :auto_reconnect => true, :pull => false, :update_frequency => 33 do |sample, name| |
| 21 | + con = Vizkit.connect_port_to 'rock_tutorial_control', 'pose', :update_frequency => 33 do |sample, name| |
29 | 22 | ##pass every pose sample to our visualizer plugin
|
30 | 23 | vizkit_rock.updatePose(sample)
|
31 | 24 | sample
|
32 | 25 | end
|
33 | 26 |
|
34 |
| - ## Create a sample writer for a port ## |
35 |
| - sampleWriter = rockControl.motion_command.writer |
36 |
| - |
| 27 | + ## Get the specific task context ## |
| 28 | + rockControl = TaskContext.get 'rock_tutorial_control' |
| 29 | + joystick = TaskContext.get 'joystick' |
| 30 | + |
| 31 | + ## Connect the ports ## |
| 32 | + joystick.motion_command.connect_to rockControl.motion_command |
| 33 | + |
| 34 | + ## Set some properties ## |
| 35 | + joystick.device = "/dev/input/js0" |
| 36 | + |
| 37 | + ## Configure the tasks ## |
| 38 | + joystick.configure |
| 39 | + |
37 | 40 | ## Start the tasks ##
|
| 41 | + joystick.start |
38 | 42 | rockControl.start
|
39 |
| - |
40 |
| - ## Write motion command sample ## |
41 |
| - sample = sampleWriter.new_sample |
42 |
| - sample.translation = 1 |
43 |
| - sample.rotation = 0.5 |
44 |
| - sampleWriter.write(sample) |
45 | 43 |
|
46 | 44 | Vizkit.exec
|
47 | 45 | end
|
0 commit comments