Skip to content

Commit 74fc742

Browse files
author
Janosch Machowinski
committed
reworked scripts from tutorials
1 parent a1f7198 commit 74fc742

File tree

3 files changed

+49
-58
lines changed

3 files changed

+49
-58
lines changed

scripts/rockTutorial1.rb

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
11
require 'orocos'
2-
require 'readline'
2+
require 'vizkit'
33
include Orocos
44

55
## Initialize orocos ##
66
Orocos.initialize
77

8+
## create a widget for 3d display
9+
view3d = Vizkit.default_loader.create_widget('vizkit::QVizkitWidget')
10+
11+
#show it
12+
view3d.show()
13+
14+
## load and add the 3d plugin for the rock
15+
vizkit_rock = view3d.createPlugin('rock_tutorial', 'RockVisualization')
16+
817
## Execute the deployment 'rock_tutorial' ##
918
Orocos.run 'rock_tutorial' do
1019

11-
## Get a specific task context ##
12-
rockVisualization = TaskContext.get 'rock_tutorial_visualization'
20+
## Get a specific task context ##
21+
rockControl = TaskContext.get 'rock_tutorial_control'
22+
23+
## Connect port to vizkit plugin
24+
con = Vizkit.connect_port_to 'rock_tutorial_control', 'pose', :auto_reconnect => true, :pull => false, :update_frequency => 33 do |sample, name|
25+
##pass every pose sample to our visualizer plugin
26+
vizkit_rock.updatePose(sample)
27+
sample
28+
end
1329

14-
## Start the tasks ##
15-
rockVisualization.start
30+
## Create a sample writer for a port ##
31+
sampleWriter = rockControl.motion_command.writer
32+
33+
## Start the tasks ##
34+
rockControl.start
35+
36+
## Write motion command sample ##
37+
sample = sampleWriter.new_sample
38+
sample.translation = 1
39+
sample.rotation = 0.5
40+
sampleWriter.write(sample)
1641

17-
Readline::readline('Press enter to exit')
42+
Vizkit.exec
1843
end

scripts/rockTutorial2.rb

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
require 'orocos'
2-
require 'readline'
32
require 'vizkit'
43
include Orocos
54

65
## Initialize orocos ##
76
Orocos.initialize
87

9-
##TODO THIS IS A BUG
10-
Orocos.load_typekit('base')
11-
128
## create a widget for 3d display
139
view3d = Vizkit.default_loader.create_widget('vizkit::QVizkitWidget')
1410

@@ -18,30 +14,32 @@
1814
## load and add the 3d plugin for the rock
1915
vizkit_rock = view3d.createPlugin('rock_tutorial', 'RockVisualization')
2016

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+
2720
## 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|
2922
##pass every pose sample to our visualizer plugin
3023
vizkit_rock.updatePose(sample)
3124
sample
3225
end
3326

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+
3740
## Start the tasks ##
41+
joystick.start
3842
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)
4543

4644
Vizkit.exec
4745
end

scripts/rockTutorial3.rb

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)