Class: ROS::Publisher
Overview
end
Instance Attribute Summary
Attributes inherited from Topic
#caller_id, #topic_name, #topic_type
Instance Method Summary collapse
-
#add_connection(caller_id) ⇒ TCPROS::Server
add tcpros connection as server.
-
#get_connection_data ⇒ Array
Connection data for slave api.
-
#get_connection_info ⇒ array
Connection info for slave api.
-
#initialize(caller_id, topic_name, topic_type, is_latched, host) ⇒ Publisher
constructor
A new instance of Publisher.
-
#publish(message) ⇒ Publisher
publish msg object.
-
#shutdown ⇒ nil
user interface of shutdown this publisher.
Methods inherited from Topic
Constructor Details
#initialize(caller_id, topic_name, topic_type, is_latched, host) ⇒ Publisher
Returns a new instance of Publisher.
34 35 36 37 38 39 |
# File 'lib/ros/publisher.rb', line 34 def initialize(caller_id, topic_name, topic_type, is_latched, host) super(caller_id, topic_name, topic_type) @host = host @is_latched = is_latched @seq = 0 end |
Instance Method Details
#add_connection(caller_id) ⇒ TCPROS::Server
add tcpros connection as server
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ros/publisher.rb', line 61 def add_connection(caller_id) #:nodoc: connection = TCPROS::Server.new(@caller_id, @topic_name, @topic_type, :host=>@host, :latched=>@is_latched, :last_published_msg=>@last_published_msg) connection.start connection.id = "#{@topic_name}_out_#{@connection_id_number}" @connection_id_number += 1 @connections.push(connection) return connection end |
#get_connection_data ⇒ Array
Returns connection data for slave api.
74 75 76 77 78 |
# File 'lib/ros/publisher.rb', line 74 def get_connection_data @connections.map do |connection| [connection.id, connection.byte_sent, connection.num_sent, 1] end end |
#get_connection_info ⇒ array
Returns connection info for slave api.
81 82 83 84 85 86 87 |
# File 'lib/ros/publisher.rb', line 81 def get_connection_info info = [] @connections.each do |connection| info.push([connection.id, connection.caller_id, 'o', connection.protocol, @topic_name]) end info end |
#publish(message) ⇒ Publisher
publish msg object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ros/publisher.rb', line 45 def publish() @seq += 1 @last_published_msg = if .has_header? .header.seq = @seq end @connections.each do |connection| connection.msg_queue.push() end self end |
#shutdown ⇒ nil
user interface of shutdown this publisher
92 93 94 |
# File 'lib/ros/publisher.rb', line 92 def shutdown @manager.shutdown_publisher(self) end |