Type of task that allows to modify the Orocos/Roby engine’s requirements. The modifications will be applied when the task is started, and the task will fail if the modification failed.
The task calls the block given to #initialize to modify the requirements. Example:
task = RequirementModificationTask.new do |engine| engine.remove Driving end
Alternatively, if a common modification needs to be done repeatedly, one can define a task model for it
class StopDriving < Orocos::RobyPlugin::RequirementModificationTask implementation do |engine| engine.remove Driving end end
See also ModalitySelectionTask
Defines a requirement modification block for all instances of this task model
# File lib/orocos/roby/selection_tasks.rb, line 87 def self.implementation(&block) if !block raise ArgumentError, "no block given" end check_arity(block, 1) define_method(:implementation, &block) end
# File lib/orocos/roby/selection_tasks.rb, line 57 def initialize(arguments = Hash.new, &block) super(arguments) do end @implementation_method = if block check_arity(block, 1) block elsif respond_to?(:implementation) method(:implementation) else raise "no requirement modification block given" end end
If the modification result can be identified by a single task, returns it. Otherwise, returns nil.
# File lib/orocos/roby/selection_tasks.rb, line 97 def result_task if @result if @result.respond_to?(:task) @result.task elsif @result.respond_to?(:to_task) @result.to_task end end end
Requests the modifications to be applied
# File lib/orocos/roby/selection_tasks.rb, line 76 event :start do |context| if !@implementation_method raise ArgumentError, "no implementation set for this RequirementModificationTask" end @result = @implementation_method.call(Roby.app.orocos_engine) emit :start end