Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D alex #37

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generators/robot/templates/robot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#
# Add use statements here, as e.g.
#
# use <%= Roby.app.module_name %>::Actions::MyActionInterface
# use_library <%= Roby.app.module_name %>::Actions::MyActionInterface
#
# or, if you're using syskit
#
Expand Down
6 changes: 6 additions & 0 deletions lib/roby/actions/models/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ def run(action_interface, arguments = Hash.new)
raise ArgumentError, "#{name} expects no arguments, but #{arguments.size} are given"
end
result = action_interface.send(name).as_plan
if(!result.class.has_ancestor?(returned_type))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the #as_plan is really needed as e.g. syskit returns an object that's not a task (but object#as_plan turns it into one).

Why don't you check on the result of #as_plan ?

raise ArgumentError, "#{name} is expected to return #{returned_type} but returned #{result.class}"
end
else
default_arguments = self.arguments.inject(Hash.new) do |h, arg|
h[arg.name] = arg.default
Expand All @@ -211,6 +214,9 @@ def run(action_interface, arguments = Hash.new)
end
end
result = action_interface.send(name, arguments).as_plan
if(!result.class.has_ancestor?(returned_type))
raise ArgumentError, "#{name} is expected to return #{returned_type} but returned #{result.class}"
end
end
# Make the planning task inherit the model/argument flags
if planning_task = result.planning_task
Expand Down
6 changes: 5 additions & 1 deletion lib/roby/coordination/models/action_state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ module ActionStateMachine
# Declares the starting state
def start(state)
parse_task_names '_state'
@starting_state = validate_task(state)
state = validate_task(state)
if @starting_state && @starting_state != state
raise ArgumentError, "Setting more than one start state is forbidden. Use #depends_on to run multiple tasks at the same time."
end
@starting_state = state
end

def state(object, task_model = Roby::Task)
Expand Down
2 changes: 1 addition & 1 deletion lib/roby/coordination/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def execute(script)
event.resolve.emit
script.jump_to(timeout_stop)
else
raise TimedOut.new(script.root_task, script.current_instruction), "#{script.current_instruction} timed out"
raise TimedOut.new(script.root_task, script.current_instruction), "#{script.current_instruction} timed out and no custom event was set to be emitted."
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/roby/coordination/task_script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def transition!
# emit an event (and quit the block)
#
# @param [Hash] options
# @option options [Event] :event (nil) if set, the given event will
# @option options [Event] :emit (nil) if set, the given event will
# be emitted when the timeout is reached. Otherwise, a
# Script::TimedOut exception is generated with the script's
# supporting task as origin
Expand Down
5 changes: 4 additions & 1 deletion lib/roby/execution_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1732,8 +1732,11 @@ def self.call_every(plan) # :nodoc:
end

last_call = now
# delete block if it shall be called only once
[block, last_call, duration] unless block.respond_to?(:once?) && block.once?
else
[block, last_call, duration]
end
[block, last_call, duration]
end.compact!
end

Expand Down
2 changes: 1 addition & 1 deletion lib/roby/relations/dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ def pretty_print(pp) # :nodoc:
if mode == :failed_event
pp.text "triggered the failure predicate '#{relation[:failure]}': "
elsif mode == :unreachable_success
pp.text "cannot reach the success condition '#{relation[:success]}': "
pp.text "success condition can no longer be reached '#{relation[:success]}': "
end
explanation.pretty_print(pp)

Expand Down
2 changes: 2 additions & 0 deletions test/test_execution_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,8 @@ def test_delayed_block
process_events
time = time + 4
process_events
time = time + 6
process_events
end

def test_one_can_add_errors_during_garbage_collection
Expand Down