roby 0.7.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +7 -5
- data/Manifest.txt +91 -16
- data/README.txt +24 -24
- data/Rakefile +92 -64
- data/app/config/app.yml +42 -43
- data/app/config/init.rb +26 -0
- data/benchmark/alloc_misc.rb +123 -0
- data/benchmark/discovery_latency.rb +67 -0
- data/benchmark/garbage_collection.rb +48 -0
- data/benchmark/genom.rb +31 -0
- data/benchmark/transactions.rb +62 -0
- data/bin/roby +1 -1
- data/bin/roby-log +16 -6
- data/doc/guide/.gitignore +2 -0
- data/doc/guide/config.yaml +34 -0
- data/doc/guide/ext/init.rb +14 -0
- data/doc/guide/ext/previous_next.rb +40 -0
- data/doc/guide/ext/rdoc_links.rb +33 -0
- data/doc/guide/index.rdoc +16 -0
- data/doc/guide/overview.rdoc +62 -0
- data/doc/guide/plan_modifications.rdoc +67 -0
- data/doc/guide/src/abstraction/achieve_with.page +8 -0
- data/doc/guide/src/abstraction/forwarding.page +8 -0
- data/doc/guide/src/abstraction/hierarchy.page +19 -0
- data/doc/guide/src/abstraction/index.page +28 -0
- data/doc/guide/src/abstraction/task_models.page +13 -0
- data/doc/guide/src/basics.template +6 -0
- data/doc/guide/src/basics/app.page +139 -0
- data/doc/guide/src/basics/code_examples.page +33 -0
- data/doc/guide/src/basics/dry.page +69 -0
- data/doc/guide/src/basics/errors.page +443 -0
- data/doc/guide/src/basics/events.page +179 -0
- data/doc/guide/src/basics/hierarchy.page +275 -0
- data/doc/guide/src/basics/index.page +11 -0
- data/doc/guide/src/basics/log_replay/goForward_1.png +0 -0
- data/doc/guide/src/basics/log_replay/goForward_2.png +0 -0
- data/doc/guide/src/basics/log_replay/goForward_3.png +0 -0
- data/doc/guide/src/basics/log_replay/goForward_4.png +0 -0
- data/doc/guide/src/basics/log_replay/goForward_5.png +0 -0
- data/doc/guide/src/basics/log_replay/hierarchy_error_1.png +0 -0
- data/doc/guide/src/basics/log_replay/hierarchy_error_2.png +0 -0
- data/doc/guide/src/basics/log_replay/hierarchy_error_3.png +0 -0
- data/doc/guide/src/basics/log_replay/plan_repair_1.png +0 -0
- data/doc/guide/src/basics/log_replay/plan_repair_2.png +0 -0
- data/doc/guide/src/basics/log_replay/plan_repair_3.png +0 -0
- data/doc/guide/src/basics/log_replay/plan_repair_4.png +0 -0
- data/doc/guide/src/basics/log_replay/roby_log_main_window.png +0 -0
- data/doc/guide/src/basics/log_replay/roby_log_relation_window.png +0 -0
- data/doc/guide/src/basics/log_replay/roby_replay_event_representation.png +0 -0
- data/doc/guide/src/basics/plan_objects.page +71 -0
- data/doc/guide/src/basics/relations_display.page +203 -0
- data/doc/guide/src/basics/roby_cycle_overview.png +0 -0
- data/doc/guide/src/basics/shell.page +102 -0
- data/doc/guide/src/basics/summary.page +32 -0
- data/doc/guide/src/basics/tasks.page +357 -0
- data/doc/guide/src/basics_shell_header.txt +16 -0
- data/doc/guide/src/cycle/cycle-overview.png +0 -0
- data/doc/guide/src/cycle/cycle-overview.svg +208 -0
- data/doc/guide/src/cycle/error_handling.page +168 -0
- data/doc/guide/src/cycle/error_instantaneous_repair.png +0 -0
- data/doc/guide/src/cycle/error_instantaneous_repair.svg +1224 -0
- data/doc/guide/src/cycle/garbage_collection.page +10 -0
- data/doc/guide/src/cycle/index.page +23 -0
- data/doc/guide/src/cycle/propagation.page +154 -0
- data/doc/guide/src/cycle/propagation_diamond.png +0 -0
- data/doc/guide/src/cycle/propagation_diamond.svg +1279 -0
- data/doc/guide/src/default.css +319 -0
- data/doc/guide/src/default.template +74 -0
- data/doc/guide/src/htmldoc.metainfo +20 -0
- data/doc/guide/src/htmldoc.virtual +18 -0
- data/doc/guide/src/images/bodybg.png +0 -0
- data/doc/guide/src/images/contbg.png +0 -0
- data/doc/guide/src/images/footerbg.png +0 -0
- data/doc/guide/src/images/gradient1.png +0 -0
- data/doc/guide/src/images/gradient2.png +0 -0
- data/doc/guide/src/index.page +7 -0
- data/doc/guide/src/introduction/index.page +29 -0
- data/doc/guide/src/introduction/install.page +133 -0
- data/doc/{papers.rdoc → guide/src/introduction/publications.page} +5 -2
- data/doc/{videos.rdoc → guide/src/introduction/videos.page} +4 -2
- data/doc/guide/src/plugins/fault_tolerance.page +44 -0
- data/doc/guide/src/plugins/index.page +11 -0
- data/doc/guide/src/plugins/subsystems.page +45 -0
- data/doc/guide/src/relations/dependency.page +89 -0
- data/doc/guide/src/relations/index.page +12 -0
- data/doc/misc/update_github +24 -0
- data/doc/tutorials/02-GoForward.rdoc +3 -3
- data/ext/graph/graph.cc +46 -0
- data/lib/roby.rb +57 -22
- data/lib/roby/app.rb +132 -112
- data/lib/roby/app/plugins/rake.rb +21 -0
- data/lib/roby/app/rake.rb +0 -7
- data/lib/roby/app/run.rb +1 -1
- data/lib/roby/app/scripts/distributed.rb +1 -2
- data/lib/roby/app/scripts/generate/bookmarks.rb +1 -1
- data/lib/roby/app/scripts/results.rb +2 -1
- data/lib/roby/app/scripts/run.rb +6 -2
- data/lib/roby/app/scripts/shell.rb +11 -11
- data/lib/roby/config.rb +1 -1
- data/lib/roby/decision_control.rb +62 -3
- data/lib/roby/distributed.rb +4 -0
- data/lib/roby/distributed/base.rb +8 -0
- data/lib/roby/distributed/communication.rb +12 -8
- data/lib/roby/distributed/connection_space.rb +61 -44
- data/lib/roby/distributed/distributed_object.rb +1 -1
- data/lib/roby/distributed/notifications.rb +22 -30
- data/lib/roby/distributed/peer.rb +13 -8
- data/lib/roby/distributed/proxy.rb +5 -5
- data/lib/roby/distributed/subscription.rb +4 -4
- data/lib/roby/distributed/transaction.rb +3 -3
- data/lib/roby/event.rb +176 -110
- data/lib/roby/exceptions.rb +12 -4
- data/lib/roby/execution_engine.rb +1604 -0
- data/lib/roby/external_process_task.rb +225 -0
- data/lib/roby/graph.rb +0 -6
- data/lib/roby/interface.rb +221 -137
- data/lib/roby/log/console.rb +5 -3
- data/lib/roby/log/data_stream.rb +94 -16
- data/lib/roby/log/dot.rb +8 -8
- data/lib/roby/log/event_stream.rb +13 -3
- data/lib/roby/log/file.rb +43 -18
- data/lib/roby/log/gui/basic_display_ui.rb +89 -0
- data/lib/roby/log/gui/chronicle_view_ui.rb +90 -0
- data/lib/roby/log/gui/data_displays.rb +4 -5
- data/lib/roby/log/gui/data_displays_ui.rb +146 -0
- data/lib/roby/log/gui/relations.rb +18 -18
- data/lib/roby/log/gui/relations_ui.rb +120 -0
- data/lib/roby/log/gui/relations_view_ui.rb +144 -0
- data/lib/roby/log/gui/replay.rb +41 -13
- data/lib/roby/log/gui/replay_controls.rb +3 -0
- data/lib/roby/log/gui/replay_controls.ui +133 -110
- data/lib/roby/log/gui/replay_controls_ui.rb +249 -0
- data/lib/roby/log/hooks.rb +19 -18
- data/lib/roby/log/logger.rb +7 -6
- data/lib/roby/log/notifications.rb +4 -4
- data/lib/roby/log/plan_rebuilder.rb +20 -22
- data/lib/roby/log/relations.rb +44 -16
- data/lib/roby/log/server.rb +1 -4
- data/lib/roby/log/timings.rb +88 -19
- data/lib/roby/plan-object.rb +135 -11
- data/lib/roby/plan.rb +408 -224
- data/lib/roby/planning/loops.rb +32 -25
- data/lib/roby/planning/model.rb +157 -51
- data/lib/roby/planning/task.rb +47 -20
- data/lib/roby/query.rb +128 -92
- data/lib/roby/relations.rb +254 -136
- data/lib/roby/relations/conflicts.rb +6 -9
- data/lib/roby/relations/dependency.rb +358 -0
- data/lib/roby/relations/ensured.rb +0 -1
- data/lib/roby/relations/error_handling.rb +0 -1
- data/lib/roby/relations/events.rb +0 -2
- data/lib/roby/relations/executed_by.rb +26 -11
- data/lib/roby/relations/planned_by.rb +14 -14
- data/lib/roby/robot.rb +46 -0
- data/lib/roby/schedulers/basic.rb +34 -0
- data/lib/roby/standalone.rb +4 -0
- data/lib/roby/standard_errors.rb +21 -15
- data/lib/roby/state/events.rb +5 -4
- data/lib/roby/support.rb +107 -6
- data/lib/roby/task-operations.rb +23 -19
- data/lib/roby/task.rb +522 -148
- data/lib/roby/task_index.rb +80 -0
- data/lib/roby/test/common.rb +283 -44
- data/lib/roby/test/distributed.rb +53 -37
- data/lib/roby/test/testcase.rb +9 -204
- data/lib/roby/test/tools.rb +3 -3
- data/lib/roby/transactions.rb +154 -111
- data/lib/roby/transactions/proxy.rb +40 -7
- data/manifest.xml +20 -0
- data/plugins/fault_injection/README.txt +0 -3
- data/plugins/fault_injection/Rakefile +2 -8
- data/plugins/fault_injection/app.rb +1 -1
- data/plugins/fault_injection/fault_injection.rb +3 -3
- data/plugins/fault_injection/test/test_fault_injection.rb +19 -25
- data/plugins/subsystems/README.txt +0 -3
- data/plugins/subsystems/Rakefile +2 -7
- data/plugins/subsystems/app.rb +27 -16
- data/plugins/subsystems/test/app/config/init.rb +3 -0
- data/plugins/subsystems/test/app/planners/main.rb +1 -1
- data/plugins/subsystems/test/app/tasks/services.rb +1 -1
- data/plugins/subsystems/test/test_subsystems.rb +23 -16
- data/test/distributed/test_communication.rb +32 -15
- data/test/distributed/test_connection.rb +28 -26
- data/test/distributed/test_execution.rb +59 -54
- data/test/distributed/test_mixed_plan.rb +34 -34
- data/test/distributed/test_plan_notifications.rb +26 -26
- data/test/distributed/test_protocol.rb +57 -48
- data/test/distributed/test_query.rb +11 -7
- data/test/distributed/test_remote_plan.rb +71 -71
- data/test/distributed/test_transaction.rb +50 -47
- data/test/mockups/external_process +28 -0
- data/test/planning/test_loops.rb +163 -119
- data/test/planning/test_model.rb +3 -3
- data/test/planning/test_task.rb +27 -7
- data/test/relations/test_conflicts.rb +3 -3
- data/test/relations/test_dependency.rb +324 -0
- data/test/relations/test_ensured.rb +2 -2
- data/test/relations/test_executed_by.rb +94 -19
- data/test/relations/test_planned_by.rb +11 -9
- data/test/suite_core.rb +6 -3
- data/test/suite_distributed.rb +1 -0
- data/test/suite_planning.rb +1 -0
- data/test/suite_relations.rb +2 -2
- data/test/tasks/test_external_process.rb +126 -0
- data/test/{test_thread_task.rb → tasks/test_thread_task.rb} +17 -20
- data/test/test_bgl.rb +21 -1
- data/test/test_event.rb +229 -155
- data/test/test_exceptions.rb +79 -80
- data/test/test_execution_engine.rb +987 -0
- data/test/test_gui.rb +1 -1
- data/test/test_interface.rb +11 -5
- data/test/test_log.rb +18 -7
- data/test/test_log_server.rb +1 -0
- data/test/test_plan.rb +229 -395
- data/test/test_query.rb +193 -35
- data/test/test_relations.rb +88 -8
- data/test/test_state.rb +55 -37
- data/test/test_support.rb +1 -1
- data/test/test_task.rb +371 -218
- data/test/test_testcase.rb +32 -16
- data/test/test_transactions.rb +211 -170
- data/test/test_transactions_proxy.rb +37 -19
- metadata +169 -71
- data/.gitignore +0 -29
- data/doc/styles/allison.css +0 -314
- data/doc/styles/allison.js +0 -316
- data/doc/styles/allison.rb +0 -276
- data/doc/styles/jamis.rb +0 -593
- data/lib/roby/control.rb +0 -746
- data/lib/roby/executives/simple.rb +0 -30
- data/lib/roby/propagation.rb +0 -562
- data/lib/roby/relations/hierarchy.rb +0 -239
- data/lib/roby/transactions/updates.rb +0 -139
- data/test/relations/test_hierarchy.rb +0 -158
- data/test/test_control.rb +0 -399
- data/test/test_propagation.rb +0 -210
|
@@ -78,7 +78,11 @@ module Roby::Transactions
|
|
|
78
78
|
alias :== :eql?
|
|
79
79
|
|
|
80
80
|
def pretty_print(pp)
|
|
81
|
-
|
|
81
|
+
if plan
|
|
82
|
+
plan.disable_proxying { super }
|
|
83
|
+
else
|
|
84
|
+
super
|
|
85
|
+
end
|
|
82
86
|
end
|
|
83
87
|
def proxying?; plan && plan.proxying? end
|
|
84
88
|
|
|
@@ -199,6 +203,8 @@ module Roby::Transactions
|
|
|
199
203
|
include Proxy
|
|
200
204
|
proxy_for Roby::Task
|
|
201
205
|
|
|
206
|
+
def to_s; "tProxy(#{__getobj__.name})#{arguments}" end
|
|
207
|
+
|
|
202
208
|
def_delegator :@__getobj__, :running?
|
|
203
209
|
def_delegator :@__getobj__, :finished?
|
|
204
210
|
def_delegator :@__getobj__, :pending?
|
|
@@ -212,11 +218,34 @@ module Roby::Transactions
|
|
|
212
218
|
def_delegator :@__getobj__, :finished?
|
|
213
219
|
|
|
214
220
|
proxy :event
|
|
215
|
-
proxy :each_event
|
|
216
|
-
alias :each_plan_child :each_event
|
|
217
|
-
proxy :fullfills?
|
|
218
221
|
proxy :same_state?
|
|
219
222
|
|
|
223
|
+
def each_plan_child(only_wrapped = false, &block)
|
|
224
|
+
each_event(only_wrapped, &block)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def each_event(only_wrapped = false)
|
|
228
|
+
__getobj__.each_event(only_wrapped) do |ev|
|
|
229
|
+
if proxy = plan[ev, !only_wrapped]
|
|
230
|
+
yield(proxy)
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
self
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def kind_of?(klass)
|
|
237
|
+
super || __getobj__.kind_of?(klass)
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# Remove all relations in which +self+ or its event are involved
|
|
241
|
+
def clear_relations
|
|
242
|
+
each_event(true) do |ev|
|
|
243
|
+
ev.clear_relations
|
|
244
|
+
end
|
|
245
|
+
super(false)
|
|
246
|
+
self
|
|
247
|
+
end
|
|
248
|
+
|
|
220
249
|
# Create a new proxy representing +object+ in +transaction+
|
|
221
250
|
def initialize(object, transaction)
|
|
222
251
|
super(object, transaction)
|
|
@@ -246,9 +275,13 @@ module Roby::Transactions
|
|
|
246
275
|
# Transaction proxies do not have history
|
|
247
276
|
def history; "" end
|
|
248
277
|
def plan=(new_plan) # :nodoc:
|
|
249
|
-
if new_plan
|
|
250
|
-
|
|
251
|
-
|
|
278
|
+
if new_plan
|
|
279
|
+
if new_plan.plan != __getobj__.plan
|
|
280
|
+
raise "invalid plan #{new_plan}"
|
|
281
|
+
elsif !new_plan.kind_of?(Roby::Transaction)
|
|
282
|
+
raise "trying to insert a transaction proxy in something else than a transaction (#{new_plan})"
|
|
283
|
+
end
|
|
284
|
+
end
|
|
252
285
|
@plan = new_plan
|
|
253
286
|
end
|
|
254
287
|
|
data/manifest.xml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<package>
|
|
2
|
+
<description brief="advanced supervision framework">
|
|
3
|
+
</description>
|
|
4
|
+
<author>Sylvain Joyeux/sylvain.joyeux@m4x.org</author>
|
|
5
|
+
<copyright>
|
|
6
|
+
LAAS-CNRS/openrobots@laas.fr
|
|
7
|
+
DFKI/robotik@dfki.de
|
|
8
|
+
Sylvain Joyeux/sylvain.joyeux@m4x.org
|
|
9
|
+
</copyright>
|
|
10
|
+
<license>CeCILL-B (BSD-like)</license>
|
|
11
|
+
|
|
12
|
+
<depend package="utilmm" />
|
|
13
|
+
<depend package="utilrb" />
|
|
14
|
+
<rosdep name="flexmock" />
|
|
15
|
+
<rosdep name="activesupport" />
|
|
16
|
+
<rosdep name="qtruby" />
|
|
17
|
+
<rosdep name="boost" />
|
|
18
|
+
<rosdep name="graphviz" />
|
|
19
|
+
</package>
|
|
20
|
+
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
rdoc_base_dir = Dir.pwd
|
|
2
1
|
if ENV['ROBY_ROOT_DIR']
|
|
3
2
|
$LOAD_PATH << File.join(ENV['ROBY_ROOT_DIR'], 'lib')
|
|
4
|
-
rdoc_base_dir = ENV['ROBY_ROOT_DIR']
|
|
5
3
|
end
|
|
6
|
-
require 'rake
|
|
7
|
-
require 'roby/app/rake'
|
|
4
|
+
require 'roby/app/plugins/rake'
|
|
8
5
|
|
|
9
|
-
Rake
|
|
10
|
-
rdoc.options << "--inline-source" << "--accessor" << "attribute" << "--accessor" << "attr_predicate"
|
|
11
|
-
rdoc.rdoc_dir = "#{rdoc_base_dir}/doc/rdoc/plugins/fault_injection"
|
|
6
|
+
Roby::Rake.plugin_doc("fault_injection") do |rdoc|
|
|
12
7
|
rdoc.title = "Fault injection plugin for Roby"
|
|
13
|
-
rdoc.template = Roby::Rake.rdoc_template
|
|
14
8
|
rdoc.options << '--main' << 'README.txt'
|
|
15
9
|
rdoc.rdoc_files.include('README.txt', 'TODO.txt', 'History.txt')
|
|
16
10
|
rdoc.rdoc_files.include('fault_injection.rb', 'app.rb')
|
|
@@ -45,7 +45,7 @@ module Roby
|
|
|
45
45
|
Application.register_plugin('fault_injection', Roby::FaultInjection::Application) do
|
|
46
46
|
require 'fault_injection'
|
|
47
47
|
Roby.every(1) do
|
|
48
|
-
FaultInjection.apply(Roby.app.fault_models)
|
|
48
|
+
FaultInjection.apply(Roby.app.fault_models, Roby.plan)
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -34,12 +34,12 @@ module Roby
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
# Apply the given fault models to the main Roby plan
|
|
37
|
-
def self.apply(fault_models)
|
|
37
|
+
def self.apply(fault_models, plan)
|
|
38
38
|
injected_faults = Array.new
|
|
39
39
|
|
|
40
40
|
for model, faults in fault_models
|
|
41
41
|
for ev, p in faults
|
|
42
|
-
|
|
42
|
+
plan.find_tasks(model).
|
|
43
43
|
running.not_finishing.
|
|
44
44
|
interruptible.each do |task|
|
|
45
45
|
if p.fault?(task)
|
|
@@ -80,7 +80,7 @@ module Roby
|
|
|
80
80
|
old_task = self
|
|
81
81
|
|
|
82
82
|
plan.replace_task(old_task, new_task)
|
|
83
|
-
old_task.event(:stop).filter(context).
|
|
83
|
+
old_task.event(:stop).filter(context).forward_to new_task.event(event)
|
|
84
84
|
|
|
85
85
|
new_task
|
|
86
86
|
end
|
|
@@ -7,40 +7,35 @@ require 'fault_injection'
|
|
|
7
7
|
|
|
8
8
|
class TC_FaultInjection < Test::Unit::TestCase
|
|
9
9
|
include Roby::Test
|
|
10
|
+
include Roby::Test::Assertions
|
|
10
11
|
|
|
11
12
|
def test_inject_fault
|
|
12
|
-
|
|
13
|
+
model = Class.new(Roby::Test::SimpleTask) do
|
|
14
|
+
event :specialized_fault
|
|
15
|
+
forward :specialized_fault => :failed
|
|
16
|
+
end
|
|
17
|
+
plan.add_permanent(task = model.new)
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
Roby.execute do
|
|
16
|
-
model = Class.new(Roby::Test::SimpleTask) do
|
|
17
|
-
event :specialized_fault
|
|
18
|
-
forward :specialized_fault => :failed
|
|
19
|
-
end
|
|
19
|
+
engine.run
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
assert_any_event(task.start_event) do
|
|
22
22
|
assert_raises(ArgumentError) { task.inject_fault(:start) }
|
|
23
|
-
|
|
24
23
|
task.start!
|
|
25
24
|
end
|
|
26
|
-
Roby.wait_one_cycle
|
|
27
25
|
|
|
28
26
|
fake_task = nil
|
|
29
|
-
|
|
27
|
+
assert_any_event(task.stop_event) do
|
|
30
28
|
assert_raises(ArgumentError) { task.inject_fault(:updated_data) }
|
|
31
29
|
assert_nothing_raised { task.inject_fault(:specialized_fault) }
|
|
32
30
|
assert_equal(2, plan.known_tasks.size)
|
|
33
31
|
fake_task = plan.known_tasks.find { |t| t != task }
|
|
34
32
|
end
|
|
35
|
-
Roby.wait_one_cycle
|
|
36
33
|
|
|
37
34
|
assert(fake_task.finished?)
|
|
38
35
|
assert(fake_task.event(:specialized_fault).happened?)
|
|
39
36
|
end
|
|
40
37
|
|
|
41
38
|
def test_apply
|
|
42
|
-
Roby.control.run :detach => true
|
|
43
|
-
|
|
44
39
|
model = Class.new(Roby::Test::SimpleTask) do
|
|
45
40
|
event :specialized_fault
|
|
46
41
|
forward :specialized_fault => :failed
|
|
@@ -49,24 +44,23 @@ class TC_FaultInjection < Test::Unit::TestCase
|
|
|
49
44
|
fault_models = Hash.new { |h, k| h[k] = Hash.new }
|
|
50
45
|
fault_models[model][:specialized_fault] = FaultInjection::Rate.new(0.01, 1.0)
|
|
51
46
|
fault_models[Roby::Test::SimpleTask][:stop] = FaultInjection::Rate.new(1_000_000, 1.0)
|
|
47
|
+
plan.add_permanent(simple = Roby::Test::SimpleTask.new)
|
|
48
|
+
plan.add_permanent(specialized = model.new)
|
|
49
|
+
both_started = simple.start_event & specialized.start_event
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
plan.permanent(specialized = model.new)
|
|
51
|
+
engine.run
|
|
52
|
+
|
|
53
|
+
assert_any_event(both_started) do
|
|
57
54
|
simple.start!
|
|
58
55
|
specialized.start!
|
|
59
56
|
end
|
|
60
|
-
Roby.wait_one_cycle
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Roby.execute do
|
|
65
|
-
result = Roby::FaultInjection.apply(fault_models)
|
|
58
|
+
fake_specialized = engine.execute do
|
|
59
|
+
result = Roby::FaultInjection.apply(fault_models, plan)
|
|
66
60
|
assert_equal(1, result.size)
|
|
67
|
-
|
|
61
|
+
result.first.last
|
|
68
62
|
end
|
|
69
|
-
|
|
63
|
+
engine.wait_one_cycle
|
|
70
64
|
|
|
71
65
|
assert(simple.running?)
|
|
72
66
|
assert(specialized.finished?)
|
data/plugins/subsystems/Rakefile
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
rdoc_base_dir = Dir.pwd
|
|
2
1
|
if ENV['ROBY_ROOT_DIR']
|
|
3
2
|
$LOAD_PATH << File.join(ENV['ROBY_ROOT_DIR'], 'lib')
|
|
4
|
-
rdoc_base_dir = ENV['ROBY_ROOT_DIR']
|
|
5
3
|
end
|
|
6
|
-
require 'rake
|
|
7
|
-
require 'roby/app/rake'
|
|
4
|
+
require 'roby/app/plugins/rake'
|
|
8
5
|
|
|
9
|
-
Rake
|
|
10
|
-
rdoc.options << "--inline-source" << "--accessor" << "attribute" << "--accessor" << "attr_predicate"
|
|
11
|
-
rdoc.rdoc_dir = "#{rdoc_base_dir}/doc/rdoc/plugins/subsystems"
|
|
6
|
+
Roby::Rake.plugin_doc("subsystems") do |rdoc|
|
|
12
7
|
rdoc.title = "Subsystems plugin for Roby"
|
|
13
8
|
rdoc.template = Roby::Rake.rdoc_template
|
|
14
9
|
rdoc.options << '--main' << 'README.txt'
|
data/plugins/subsystems/app.rb
CHANGED
|
@@ -51,9 +51,9 @@ module Roby
|
|
|
51
51
|
|
|
52
52
|
# This method generates the initial plan built upon the set of
|
|
53
53
|
# required subsystems.
|
|
54
|
-
def self.initialize_plan
|
|
54
|
+
def self.initialize_plan(plan)
|
|
55
55
|
setup_main_planner
|
|
56
|
-
|
|
56
|
+
trsc = Transaction.new(plan)
|
|
57
57
|
|
|
58
58
|
# Event which is emitted when all subsystems are properly
|
|
59
59
|
# initialized
|
|
@@ -61,7 +61,7 @@ module Roby
|
|
|
61
61
|
|
|
62
62
|
# Create the one task for each subsystem. +ready+ is an event
|
|
63
63
|
# which is fired when all subsystems are properly initialized
|
|
64
|
-
planner = MainPlanner.new(
|
|
64
|
+
planner = MainPlanner.new(trsc)
|
|
65
65
|
|
|
66
66
|
tasks = Array.new
|
|
67
67
|
task_objects = ValueSet.new
|
|
@@ -75,7 +75,7 @@ module Roby
|
|
|
75
75
|
|
|
76
76
|
State.services.tasks.send("#{name}=", new_task)
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
trsc.add_permanent(new_task)
|
|
79
79
|
started_with = if new_task.has_event?(:ready) then :ready
|
|
80
80
|
else :start
|
|
81
81
|
end
|
|
@@ -104,6 +104,11 @@ module Roby
|
|
|
104
104
|
|
|
105
105
|
ev = if children.empty?
|
|
106
106
|
starting_point
|
|
107
|
+
elsif children.size == 1
|
|
108
|
+
child = children.first
|
|
109
|
+
if child.has_event?(:ready) then child.event(:ready)
|
|
110
|
+
else child.event(:start)
|
|
111
|
+
end
|
|
107
112
|
else
|
|
108
113
|
children.inject(AndGenerator.new) do |ev, child|
|
|
109
114
|
started_with = if child.has_event?(:ready) then :ready
|
|
@@ -114,18 +119,18 @@ module Roby
|
|
|
114
119
|
end
|
|
115
120
|
|
|
116
121
|
ev.on { Robot.info "starting subsystem #{name} (#{type})" }
|
|
117
|
-
ev.
|
|
122
|
+
ev.signals task.event(:start)
|
|
118
123
|
end
|
|
119
124
|
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
plan.execute do
|
|
126
|
+
trsc.commit_transaction
|
|
122
127
|
end
|
|
123
128
|
[starting_point, ready]
|
|
124
129
|
end
|
|
125
130
|
|
|
126
131
|
# Hook to generate the initial plan and start subsystems when the
|
|
127
132
|
# application starts.
|
|
128
|
-
def self.run(
|
|
133
|
+
def self.run(app, &block)
|
|
129
134
|
unless Roby::State.services? && !Roby::State.services.empty?
|
|
130
135
|
Robot.info "No subsystems defined"
|
|
131
136
|
return yield
|
|
@@ -133,16 +138,22 @@ module Roby
|
|
|
133
138
|
|
|
134
139
|
Robot.info "Starting subsystems ..."
|
|
135
140
|
|
|
136
|
-
starting_point, ready = initialize_plan
|
|
141
|
+
starting_point, ready = initialize_plan(Roby.plan)
|
|
137
142
|
# Start the deepest tasks. The signalling order will do the rest.
|
|
138
143
|
# The 'ready' event is emitted when all the subsystem tasks are
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
begin
|
|
145
|
+
Roby.wait_until(ready) do
|
|
146
|
+
Roby.execute do
|
|
147
|
+
starting_point.call
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
rescue Exception => e
|
|
151
|
+
Robot.fatal "failed to start subsystems"
|
|
152
|
+
Roby.log_exception(e, Robot, :fatal)
|
|
153
|
+
raise
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
yield if block_given?
|
|
146
157
|
end
|
|
147
158
|
end
|
|
148
159
|
end
|
|
@@ -7,10 +7,6 @@ require 'roby/test/tasks/simple_task'
|
|
|
7
7
|
APP_DIR = File.expand_path('app', File.dirname(__FILE__))
|
|
8
8
|
require "#{APP_DIR}/tasks/services"
|
|
9
9
|
require "#{APP_DIR}/planners/main"
|
|
10
|
-
Roby.app.using :subsystems
|
|
11
|
-
|
|
12
|
-
State = Roby::State
|
|
13
|
-
Robot = Roby
|
|
14
10
|
|
|
15
11
|
class TC_Subsystems < Test::Unit::TestCase
|
|
16
12
|
include Roby::Test
|
|
@@ -18,12 +14,18 @@ class TC_Subsystems < Test::Unit::TestCase
|
|
|
18
14
|
|
|
19
15
|
def setup
|
|
20
16
|
super
|
|
17
|
+
|
|
18
|
+
Roby.app.setup_global_singletons
|
|
19
|
+
Roby.app.using :subsystems
|
|
21
20
|
DRb.start_service
|
|
22
|
-
State.pos = 0
|
|
23
|
-
State.services do |s|
|
|
21
|
+
Roby::State.pos = 0
|
|
22
|
+
Roby::State.services do |s|
|
|
24
23
|
s.localization = 'test'
|
|
25
24
|
s.navigation = 'test'
|
|
26
25
|
end
|
|
26
|
+
|
|
27
|
+
@plan = Roby.plan
|
|
28
|
+
@engine = Roby.engine
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def nav_loc
|
|
@@ -36,17 +38,19 @@ class TC_Subsystems < Test::Unit::TestCase
|
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
def test_initialize_plan
|
|
39
|
-
start_with, ready = Application.initialize_plan
|
|
41
|
+
start_with, ready = Application.initialize_plan(plan)
|
|
40
42
|
|
|
41
43
|
nav, loc = nav_loc
|
|
42
44
|
assert(plan.permanent?(nav))
|
|
43
45
|
assert(plan.permanent?(loc))
|
|
44
|
-
assert(nav.
|
|
46
|
+
assert(nav.depends_on?(loc))
|
|
45
47
|
|
|
46
48
|
assert_equal([loc.event(:start)], start_with.child_objects(EventStructure::Signal).to_a)
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
signalled_events = loc.event(:ready).child_objects(EventStructure::Signal).to_value_set
|
|
51
|
+
assert_equal 2, signalled_events.size
|
|
52
|
+
assert_equal([nav.start_event, ready].to_value_set,
|
|
53
|
+
loc.event(:ready).child_objects(EventStructure::Signal).to_value_set)
|
|
50
54
|
|
|
51
55
|
assert_equal([nav.event(:start), loc.event(:ready)].to_set, ready.parent_objects(EventStructure::Signal).to_set)
|
|
52
56
|
|
|
@@ -57,15 +61,18 @@ class TC_Subsystems < Test::Unit::TestCase
|
|
|
57
61
|
|
|
58
62
|
def test_start_subsystems
|
|
59
63
|
Roby.logger.level = Logger::FATAL
|
|
60
|
-
|
|
64
|
+
Robot.logger.level = Logger::FATAL
|
|
65
|
+
engine.run
|
|
66
|
+
Subsystems::Application.run(Roby.app)
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
Roby.execute do
|
|
69
|
+
nav, loc = nav_loc
|
|
70
|
+
assert(nav.running?)
|
|
71
|
+
assert(loc.running?)
|
|
72
|
+
end
|
|
66
73
|
|
|
67
74
|
sleep(0.5)
|
|
68
|
-
assert(State.pos > 0)
|
|
75
|
+
assert(Roby::State.pos > 0)
|
|
69
76
|
end
|
|
70
77
|
end
|
|
71
78
|
|