module OroGen::ROS

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

Constants

OROGEN_ROS_LIB_DIR

Public Class Methods

normalize_name(name) click to toggle source

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

# File lib/orogen/ros/base.rb, line 55
def self.normalize_name(name)
     "/#{name}".sub(/^\/+/,'/')
end
normalize_topic_name(topic_name) click to toggle source

Normalize the topic name (to match port names) see normalize_name @return [String] (prefixed) node name

# 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) click to toggle source

Locate the launch file in a given ros package @return [String] absolute path to the launch file @throws [ArgumentError] if the launch file cannot be found in the ros package

# 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) click to toggle source

Find the path of a rosnode binary @return [String] Path to the rosnode binary

# 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_list() click to toggle source

List running ROS nodes using the ROS tooling @return [Array] List of running ros nodes

# 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 = (%x`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) click to toggle source

Normalize the rosnode name see normalize_name @return [String] (prefixed) node name

# File lib/orogen/ros/base.rb, line 42
def self.rosnode_normalize_name(node_name)
    normalize_name(node_name)
end
rosnode_running?(node_name) click to toggle source

Test whether a ROS node of the given name is running @return [Bool] True if a ros node of given name is currenlty running

# 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