Class: OroGen::ROS::Spec::Package

Inherits:
Spec::Project show all
Extended by:
Logger::Hierarchy
Defined in:
lib/orogen/ros/spec/package.rb

Constant Summary collapse

OROGEN_ROS_NODE_NAME =

The name of the root model for all ROS nodes

"ROS::Node"

Instance Attribute Summary collapse

Attributes inherited from Spec::Project

#deployers, #disabled_namespaces, #enabled_transports, #loader, #self_tasks, #tasks, #typekit

Instance Method Summary collapse

Methods inherited from Spec::Project

blank, default_deployment_name, #deployment, #disable_namespace, #each_deployment, #enable_namespace, #enable_transports, #external_task_context, #find_deployment_by_name, #find_interface_type, #find_task_context, #find_type, #has_deployment?, #intermediate_type_for, #max_sizes, #name, #namespace_disabled?, #pretty_print, #resolve_interface_type, #resolve_type, #task_context, #task_model_from_name, #to_s, #using_task_library, #using_typekit, #validate_max_sizes_spec, #version

Constructor Details

#initialize(root_loader, ros_loader = root_loader) ⇒ Package


14
15
16
17
18
# File 'lib/orogen/ros/spec/package.rb', line 14

def initialize(root_loader, ros_loader = root_loader)
    super(root_loader)
    @ros_loader = ros_loader
    self.define_default_deployments = false
end

Instance Attribute Details

#ros_loaderLoader (readonly)

The loader that should be used for ROS-specific stuff


9
10
11
# File 'lib/orogen/ros/spec/package.rb', line 9

def ros_loader
  @ros_loader
end

Instance Method Details

#__eval__(deffile, deftext, verbose = (::OroGen.logger.level == ::Logger::DEBUG)) ⇒ Object


77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/orogen/ros/spec/package.rb', line 77

def __eval__(deffile, deftext, verbose = (::OroGen.logger.level == ::Logger::DEBUG))
    if !deffile
        @load_doc = false
        instance_eval deftext
    else
        @load_doc = ::File.file?(deffile)
        instance_eval deftext, deffile, 1
    end
    self
rescue ::Exception => e
    if true || verbose then ::Kernel.raise
    else
        this_level = ::Kernel.caller.size
        until_here = e.backtrace[-(this_level-1)..-1] || []
        subcalls = e.backtrace[0, e.backtrace.size - this_level - 1] || []
        subcalls.delete_if { |line| line =~ /eval|method_missing/ && line !~ /\.orogen/ }
        subcalls = subcalls.map { |line| line.gsub(/:in `(?:block in )?__eval__'/, '') }
        ::Kernel.raise e, e.message, (subcalls + until_here)
    end
end

#default_task_superclassObject


20
21
22
23
24
25
# File 'lib/orogen/ros/spec/package.rb', line 20

def default_task_superclass
    if @default_task_superclass.nil?
        @default_task_superclass = loader.task_model_from_name "ROS::Node"
    else @default_task_superclass
    end
end

#import_types_from(typekit) ⇒ Object

Load a typekit to import RTT-to-ROS mappings


28
29
30
# File 'lib/orogen/ros/spec/package.rb', line 28

def import_types_from(typekit)
    using_typekit(typekit)
end

#ros_launcher(name, &block) ⇒ Object

Declares a ros launcher that exists within the package defined by the project name

ros_launcher “test”

use_existing

end

If use existing is given it will search for “test.lauch” in the ros package and extract the nodes started by the launch- file


60
61
62
63
64
65
66
67
# File 'lib/orogen/ros/spec/package.rb', line 60

def ros_launcher(name, &block)
    launcher = Spec::Launcher.new(self, name)
    launcher.instance_eval(&block) if block_given?
    deployers[launcher.name] = launcher
    launcher
rescue Exception => e
    raise e, "defining ROS launcher #{name} on #{self} failed: #{e.message}", e.backtrace
end

#ros_node(name, options = Hash.new, &block) ⇒ Node

Declares a ros node that exists within the package define by the project name

name “ros_package” ros_node “ros_node” do

.. node specification ..

end

defines a ros_package::ros_node class.

Nodes are represented as instances of RosNode. See the documentation of that class for more details


45
46
47
48
# File 'lib/orogen/ros/spec/package.rb', line 45

def ros_node(name, options = Hash.new, &block)
    task = external_task_context(name, Hash[:class => Spec::Node].merge(options), &block)
    self_tasks[task.name] = task
end

#simple_deploymentObject

Raises:

  • (NotImplementedError)

73
74
75
# File 'lib/orogen/ros/spec/package.rb', line 73

def simple_deployment
    raise NotImplementedError, "cannot create simple deployments on #{self.class}"
end

#using_ros_package(name) ⇒ Object


69
70
71
# File 'lib/orogen/ros/spec/package.rb', line 69

def using_ros_package(name)
    using_task_library(name)
end