Module: Roby::Coordination::Models::ActionScript

Includes:
Actions, Script
Included in:
ActionScript
Defined in:
lib/roby/coordination/models/action_script.rb

Overview

Definition of model-level functionality for action scripts

Action scripts are sequential representations of action coordinations. Each step is a script instruction (created with one of the API calls in Script) whose argument is a Task object. The Task object represents the actual work that will be done there

Action script models are usually created through an action interface with Interface#action_script. The script model can then be retrieved using Actions::Models::Action#coordination_model.

Examples:

creating an action script

class Main < Roby::Actions::Interface
  action_script 'example_action' do
    # Start moving at 0.1 m/s until we move more than 0.1m
    move_task = task move(speed: 0.1)
    d_monitor = task monitor_movement_threshold(d: 0.1)
    d_monitor.depends_on move_task
    execute d_monitor

    # Then, once we're done with that, stand still for 20s
    stand_task = task move(speed: 0)
    t_monitor  = task monitor_time_threshold(t: 20)
    t_monitor.depends_on stand_task
    execute t_monitor

    # Finally, announce the success
    emit success_event
  end
end

retrieving a script model from an action

Main.find_action_by_name('example_action').coordination_model

Instance Attribute Summary

Attributes included from Actions

#action_interface

Attributes included from Base

#name, #root

Instance Method Summary collapse

Methods included from Script

#add, #call, #emit, #execute, #instructions, #sleep, #start, #terminal, #terminal?, #timeout_start, #timeout_stop, #wait

Methods included from Actions

#dependency, #depends_on, #event_active_in_state?, #forward, #from, #from_state, #map_tasks, #parse, #rebind, #required_tasks_for, #root_event?, #setup_submodel, #toplevel_state?

Methods included from Base

#find_event, #find_task_by_name, #map_tasks, #parse_names, #setup_submodel, #task, #task_model, #use_fault_response_table, #used_fault_response_table, #validate_event, #validate_or_create_task, #validate_task

Methods included from Arguments

#argument, #validate_arguments

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/roby/coordination/models/action_script.rb', line 53

def method_missing(m, *args)
    if m =~ /(.*)!/
        action_name = $1
        action = action_interface.find_action_by_name(action_name)
        task = task(action.new(*args))
        task.name = action_name
        execute(task)
    else
        super
    end
end

Instance Method Details

#respond_to_missing?(m, include_private) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
# File 'lib/roby/coordination/models/action_script.rb', line 45

def respond_to_missing?(m, include_private)
    if m =~ /(.*)!/
        action_interface&.find_action_by_name(m.to_s)
    else
        super
    end
end