Method: Roby::Application#action_from_model
- Defined in:
- lib/roby/app.rb
#action_from_model(model) ⇒ Actions::Models::Action
Find an action on the planning interface that can generate the given task model
3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 |
# File 'lib/roby/app.rb', line 3091 def action_from_model(model) candidates = [] planners.each do |planner_model| planner_model.find_all_actions_by_type(model).each do |action| candidates << [planner_model, action] end end candidates = candidates.uniq if candidates.empty? raise ActionResolutionError, "cannot find an action to produce #{model}" elsif candidates.size > 1 candidates_s = candidates .map { |pl, m| "#{pl}.#{m.name}" } .sort.join(", ") raise ActionResolutionError, "more than one actions available produce #{model}: #{candidates_s}" else candidates.first end end |