Module: OroGen::ROS

Extended by:
Logger::Hierarchy
Defined in:
lib/orogen/ros.rb,
lib/orogen/ros/base.rb,
lib/orogen/ros/loader.rb,
lib/orogen/ros/spec/node.rb,
lib/orogen/ros/spec/package.rb,
lib/orogen/ros/spec/launcher.rb,
lib/orogen/ros/default_loader.rb,
lib/orogen/ros/spec/input_topic.rb,
lib/orogen/ros/spec/output_topic.rb

Overview

Toplevel module for all the functionality that allows to describe ROS nodes using oroGen models

Defined Under Namespace

Modules: Spec Classes: DefaultLoader, Loader

Constant Summary collapse

OROGEN_ROS_LIB_DIR =
File.expand_path(File.dirname(__FILE__))

Class Method Summary collapse

Class Method Details

.normalize_name(name) ⇒ Object

Normalize the name, i.e. make sure the name is(!) prefixed with a '/'



55
56
57
# File 'lib/orogen/ros/base.rb', line 55

def self.normalize_name(name)
     "/#{name}".sub(/^\/+/,'/')
end

.normalize_topic_name(topic_name) ⇒ String

Normalize the topic name (to match port names) see #normalize_name

Returns:

  • (String)

    (prefixed) node name



49
50
51
# File 'lib/orogen/ros/base.rb', line 49

def self.normalize_topic_name(topic_name)
    normalize_name(topic_name)
end

.roslaunch_find(package_name, launch_name) ⇒ String

Locate the launch file in a given ros package

Returns:

  • (String)

    absolute path to the launch file



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/orogen/ros/base.rb', line 62

def self.roslaunch_find(package_name, launch_name)
    package_path = rospack_find(package_name)
    launch_path = File.join(package_path, "launch")

    launch_name = launch_name.gsub(/\.launch$/,"")
    launch_name += ".launch"

    launch_path = File.join(launch_path, launch_name)
    if !File.file?(launch_path)
        raise ArgumentError, "there is no launch_file called #{launch_name} in #{package_name} (looked in #{launch_path})"
    end
    launch_path
end

.rosnode_find(package_name, binary_name) ⇒ String

Find the path of a rosnode binary

Returns:

  • (String)

    Path to the rosnode binary



7
8
9
10
11
12
13
14
15
# File 'lib/orogen/ros/base.rb', line 7

def self.rosnode_find(package_name, binary_name)
    package_path = rospack_find(package_name)

    bin_path = File.join(package_path, 'bin', binary_name)
    if !File.file?(bin_path)
        raise ArgumentError, "there is no node called #{binary_name} in #{package_name} (looked in #{bin_path})"
    end
    bin_path
end

.rosnode_listArray

List running ROS nodes using the ROS tooling

Returns:

  • (Array)

    List of running ros nodes



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/orogen/ros/base.rb', line 19

def self.rosnode_list
    # Redirect error to stdout, since rosnode does not support
    # proper error reporting
    running_nodes = (`rosnode list 2>&1` || []).split("\n")

    # Handle ROS error message
    if running_nodes.size == 1 && running_nodes.first =~ /ERROR/
        raise InternalError, "cannot query node list. Master node is not available."
    end
    running_nodes
end

.rosnode_normalize_name(node_name) ⇒ String

Normalize the rosnode name see #normalize_name

Returns:

  • (String)

    (prefixed) node name



42
43
44
# File 'lib/orogen/ros/base.rb', line 42

def self.rosnode_normalize_name(node_name)
    normalize_name(node_name)
end

.rosnode_running?(node_name) ⇒ Bool

Test whether a ROS node of the given name is running

Returns:

  • (Bool)

    True if a ros node of given name is currenlty running



33
34
35
36
37
# File 'lib/orogen/ros/base.rb', line 33

def self.rosnode_running?(node_name)
    # making sure node name conform to 
    # pattern "/nodename"
    rosnode_list.include?(rosnode_normalize_name(node_name))
end