Module: Robot

Defined in:
lib/roby/robot.rb

Class Method Summary collapse

Class Method Details

.action_from_model(model) ⇒ Object

Deprecated.

use Roby.app.action_from_model instead



11
12
13
# File 'lib/roby/robot.rb', line 11

def self.action_from_model(model)
    return Roby.app.action_from_model(model)
end

.action_from_name(name) ⇒ Object

Deprecated.

use Roby.app.action_from_name instead



21
22
23
# File 'lib/roby/robot.rb', line 21

def self.action_from_name(name)
    return Roby.app.action_from_name(name)
end

.actions(&block) ⇒ Object



96
97
98
# File 'lib/roby/robot.rb', line 96

def self.actions(&block)
    Roby.app.actions(&block)
end

.cleanup(&block) ⇒ Object



84
85
86
# File 'lib/roby/robot.rb', line 84

def self.cleanup(&block)
    Roby.app.on_cleanup(&block)
end

.clear_models(&block) ⇒ Object



80
81
82
# File 'lib/roby/robot.rb', line 80

def self.clear_models(&block)
    Roby.app.on_clear_models(&block)
end

.config(&block) ⇒ Object



88
89
90
# File 'lib/roby/robot.rb', line 88

def self.config(&block)
    Roby.app.on_config(&block)
end

.controller(&block) ⇒ Object



92
93
94
# File 'lib/roby/robot.rb', line 92

def self.controller(&block)
    Roby.app.controller(&block)
end

.find_action_from_name(name) ⇒ Object

Deprecated.

use Roby.app.find_action_from_name instead



16
17
18
# File 'lib/roby/robot.rb', line 16

def self.find_action_from_name(name)
    return Roby.app.find_action_from_name(name)
end

.init(&block) ⇒ Object



68
69
70
# File 'lib/roby/robot.rb', line 68

def self.init(&block)
    Roby.app.on_init(&block)
end

.log_formatter(severity, time, progname, msg) ⇒ Object



4
5
6
7
# File 'lib/roby/robot.rb', line 4

def self.log_formatter(severity, time, progname, msg)
    Roby.app.notify(progname, severity.to_s, msg)
    Roby.logger.formatter.call(severity, time, progname, msg)
end

.method_missing(name, *args) ⇒ Object

Implements that one can call

Robot.action_name! arg0: value0, arg1: value1

To inject a given action in Roby.plan. The added action is added as a mission.

See also Robot.prepare_action



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/roby/robot.rb', line 41

def self.method_missing(name, *args)
    if name.to_s =~ /!$/
        name = $`.to_sym
    else
        super
    end

    if args.size > 1
        raise ArgumentError, "wrong number of arguments (#{args.size} for 1) in #{name}!"
    end

    options = args.first || {}
    task, planner = Roby.app.prepare_action(name, job_id: Roby::Interface::Job.allocate_job_id, **options)
    task.plan.add_mission_task(task)
    return task, planner
end

.prepare_action(plan, name, **arguments) ⇒ Object

Deprecated.

use Roby.app.prepare_action instead



26
27
28
29
30
31
# File 'lib/roby/robot.rb', line 26

def self.prepare_action(plan, name, **arguments)
    if plan != Roby.app.plan
        raise ArgumentError, "cannot call prepare_action with any other plan than Roby.app.plan"
    end
    return Roby.app.prepare_action(name, **arguments)
end

.requires(&block) ⇒ Object



76
77
78
# File 'lib/roby/robot.rb', line 76

def self.requires(&block)
    Roby.app.on_require(&block)
end

.robot_type(robot_type) ⇒ Object

Declare the robot type of the robot configuration being loaded

Place this on top of the robot file in config/robots/



61
62
63
64
65
66
# File 'lib/roby/robot.rb', line 61

def self.robot_type(robot_type)
    # Declare it first
    Roby.app.robots.declare_robot_type(Roby.app.robot_name, robot_type)
    # And then set it up
    Roby.app.robot(Roby.app.robot_name, robot_type)
end

.setup(&block) ⇒ Object



72
73
74
# File 'lib/roby/robot.rb', line 72

def self.setup(&block)
    Roby.app.on_setup(&block)
end