Class: OroGen::ROS::Spec::Node

Inherits:
Spec::TaskContext show all
Defined in:
lib/orogen/ros/spec/node.rb

Overview

Representation of a ROS node as an oroGen model

Constant Summary

Constants inherited from Spec::TaskContext

Spec::TaskContext::STATE_TYPES

Instance Attribute Summary collapse

Attributes inherited from Spec::TaskContext

#dynamic_ports, #extensions, #implemented_classes, #name, #project, #superclass, #uses_qt

Instance Method Summary collapse

Methods inherited from Spec::TaskContext

#abstract, #abstract?, #all_ports, #ancestors, apply_default_extensions, #attribute, blank, #check_uniqueness, #configuration_object, #default_activity, default_extensions, #define_state, #doc, #dynamic_input_port, #dynamic_output_port, #dynamic_port, #each_dynamic_input_port, #each_dynamic_output_port, #each_extension, #each_interface_type, #each_port, #each_state, #error_states, #exception_states, #extended_state_support, #extended_state_support?, #extension, #external_definition=, #external_definition?, #fatal_states, #fd_driven, #fd_driven?, #find_dynamic_input_ports, #find_dynamic_output_ports, #find_extension, #find_port, #fixed_initial_state, #fixed_initial_state?, #has_dynamic_attributes?, #has_dynamic_input_port?, #has_dynamic_output_port?, #has_dynamic_port?, #has_dynamic_properties?, #has_extension?, #has_input_port?, #has_output_port?, #has_port?, #has_property?, #hidden_operation, #implements, #implements?, #initialize_copy, #input_port, #inspect, #loader, #make_property_dynamic, #merge_ports_from, #needs_configuration, #needs_configuration?, #new_operations, #operation, #output_port, #periodic, pop_default_extensions_state, #port_driven, #pretty_print, #pretty_print_interface, #property, push_default_extensions_state, #register_extension, #reports, #required_activity, #required_activity=, #required_activity?, #ro_ptr, #root_model, #runtime_states, #self_ports, #shared_ptr, #state?, #state_kind, #states, #subclasses, #to_dot, #to_h, #toplevel_states, #type, #use_qt, #uses_qt?, #worstcase_processing_time

Constructor Details

#initialize(project, name = nil) ⇒ Node

Returns a new instance of Node



11
12
13
14
15
16
# File 'lib/orogen/ros/spec/node.rb', line 11

def initialize(project, name = nil)
    super

    @ros_name = name
    @ros_package = project.name
end

Instance Attribute Details

#ros_nameString

Returns the name on the ROS side

Returns:

  • (String)

    the name on the ROS side



7
8
9
# File 'lib/orogen/ros/spec/node.rb', line 7

def ros_name
  @ros_name
end

#ros_packageString

Returns the name of the ROS package

Returns:

  • (String)

    the name of the ROS package



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

def ros_package
  @ros_package
end

Instance Method Details

#==(other) ⇒ Boolean

Equals operator

Returns:

  • (Boolean)

    True, if ros node and package name equal equal, False otherwise



54
55
56
57
58
59
60
61
62
# File 'lib/orogen/ros/spec/node.rb', line 54

def ==(other)
    if other.respond_to?(:ros_name)
        if ros_name.empty? || other.ros_name.empty?
            raise ArgumentError, "Cannot compare ROS Spec node with empty ros_name: #{self} vs. #{other}"
        end
        return ros_name == other.ros_name && ros_package == other.ros_package
    end
    false
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


64
# File 'lib/orogen/ros/spec/node.rb', line 64

def eql?(other); self == other end

#input_topic(topic_name, name, message_type) ⇒ InputTopic

Declares that this node subscribes to a specific topic

Parameters:

  • topic_name (String)

    the topic name

  • name (String)

    the name on which this topic should be registered on self

  • message_type (String)

    the name of the ROS message type. A ROS mapping must exist for it

Returns:



41
42
43
44
45
46
# File 'lib/orogen/ros/spec/node.rb', line 41

def input_topic(topic_name, name, message_type)
    data_type = project.ros_loader.map_message_type_to_orogen(message_type)
    topic = input_port(name, data_type, :class => InputTopic)
    topic.ros_name = ROS.normalize_topic_name(topic_name)
    topic
end

#output_topic(topic_name, name, message_type) ⇒ OutputTopic

Declares that this node produces data on a specific topic

Parameters:

  • topic_name (String)

    the topic name

  • name (String)

    the name on which this topic should be registered on self

  • message_type (String)

    the name of the ROS message type. A ROS mapping must exist for it

Returns:



26
27
28
29
30
31
# File 'lib/orogen/ros/spec/node.rb', line 26

def output_topic(topic_name, name, message_type)
    data_type = project.ros_loader.map_message_type_to_orogen(message_type)
    topic = output_port(name, data_type, :class => OutputTopic)
    topic.ros_name = ROS.normalize_topic_name(topic_name)
    topic
end

#to_sObject



48
49
50
# File 'lib/orogen/ros/spec/node.rb', line 48

def to_s
    "#{self.class} ros_name: #{ros_name}, ros_package: #{ros_package}"
end