Class: Orocos::ROS::Topic
- Inherits:
-
Object
- Object
- Orocos::ROS::Topic
- Includes:
- PortBase
- Defined in:
- lib/orocos/ros/topic.rb
Overview
A Port-compatible implementation of a ROS topic. To map topics to ports, a Node will announce all the topics it is subscribed / it publishes as its own ports
Direct Known Subclasses
Constant Summary collapse
- @@local_transient_port_id =
0
Constants included from PortBase
PortBase::D_DIFFERENT_HOSTS, PortBase::D_SAME_HOST, PortBase::D_SAME_PROCESS, PortBase::D_UNKNOWN
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Documentation string.
-
#ros_message_type ⇒ Object
readonly
The ROS message type name.
-
#topic_name ⇒ Object
readonly
The topic name.
Attributes included from PortBase
#model, #name, #orocos_type_name, #task, #type
Class Method Summary collapse
-
.default_port_name(topic_name) ⇒ String
The default port name generated from a topic name.
- .transient_local_port_name(topic_name) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #doc? ⇒ Boolean
-
#initialize(task, topic_name, ros_message_type, model = nil, name = Topic.default_port_name(topic_name), orocos_type_name = nil) ⇒ Topic
constructor
A new instance of Topic.
-
#pretty_print(pp) ⇒ Object
:nodoc:.
Methods included from PortBase
#distance_to, #ensure_type_available, #full_name, #log_metadata, #max_marshalling_size, #max_sizes, #new_sample, #to_s
Constructor Details
#initialize(task, topic_name, ros_message_type, model = nil, name = Topic.default_port_name(topic_name), orocos_type_name = nil) ⇒ Topic
Returns a new instance of Topic
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/orocos/ros/topic.rb', line 28 def initialize(task, topic_name, , model = nil, name = Topic.default_port_name(topic_name), orocos_type_name = nil) if !orocos_type_name candidates = ROS.find_all_types_for() if candidates.empty? raise ArgumentError, "ROS message type #{} has no corresponding type on the oroGen side" end orocos_type_name = candidates.first end @ros_message_type = @topic_name = topic_name super(task, name, orocos_type_name, model) end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Documentation string
14 15 16 |
# File 'lib/orocos/ros/topic.rb', line 14 def doc @doc end |
#ros_message_type ⇒ Object (readonly)
The ROS message type name
12 13 14 |
# File 'lib/orocos/ros/topic.rb', line 12 def @ros_message_type end |
#topic_name ⇒ Object (readonly)
The topic name
10 11 12 |
# File 'lib/orocos/ros/topic.rb', line 10 def topic_name @topic_name end |
Class Method Details
.default_port_name(topic_name) ⇒ String
Returns the default port name generated from a topic name
24 25 26 |
# File 'lib/orocos/ros/topic.rb', line 24 def self.default_port_name(topic_name) topic_name.gsub(/^~?\//, '') end |
.transient_local_port_name(topic_name) ⇒ Object
19 20 21 |
# File 'lib/orocos/ros/topic.rb', line 19 def self.transient_local_port_name(topic_name) "rostopics#{topic_name.gsub('/', '.')}.#{@@local_transient_port_id += 1}" end |
Instance Method Details
#==(other) ⇒ Object
50 51 52 53 54 |
# File 'lib/orocos/ros/topic.rb', line 50 def ==(other) other.class == self.class && other.topic_name == self.topic_name && other.task == self.task end |
#doc? ⇒ Boolean
16 |
# File 'lib/orocos/ros/topic.rb', line 16 def doc?; false end |
#pretty_print(pp) ⇒ Object
:nodoc:
46 47 48 |
# File 'lib/orocos/ros/topic.rb', line 46 def pretty_print(pp) # :nodoc: pp.text " #{name} (#{orocos_type_name}), ros: #{topic_name}(#{})" end |