Class: ROS::MasterProxy
- Inherits:
-
Object
- Object
- ROS::MasterProxy
- Defined in:
- lib/ros/master_proxy.rb
Overview
ROS Master Proxy
access to ROS Master. But there are not documented API.
Instance Attribute Summary collapse
-
#caller_id ⇒ String
caller id of this node.
-
#master_uri ⇒ String
Master URI.
-
#slave_uri ⇒ String
Slave URI.
Instance Method Summary collapse
-
#get_published_topics(subgraph = '') ⇒ Array
get the all published topics.
-
#get_system_state ⇒ Array
get system state.
-
#get_uri ⇒ String
get the master URI.
-
#initialize(caller_id, master_uri, slave_uri) ⇒ MasterProxy
constructor
A new instance of MasterProxy.
-
#lookup_node(node_name) ⇒ String?
lookup a node by name.
-
#lookup_service(service) ⇒ String?
look up a service by name.
-
#register_publisher(topic, topic_type) ⇒ Array
register a publisher.
-
#register_service(service, service_api) ⇒ Boolean
register a service.
-
#register_subscriber(topic, topic_type) ⇒ Array
register a subscriber.
-
#subscribe_param(key) ⇒ Boolean
this method is not described in the wiki.
-
#unregister_publisher(topic) ⇒ Boolean
unregister a publisher.
-
#unregister_service(service, service_api) ⇒ Boolean
unregister a service.
-
#unregister_subscriber(topic) ⇒ Boolean
unregister a subscriber.
-
#unsubscribe_param(key) ⇒ Boolean
unsubscribe to the parameter key.
Constructor Details
#initialize(caller_id, master_uri, slave_uri) ⇒ MasterProxy
Returns a new instance of MasterProxy.
28 29 30 31 32 33 |
# File 'lib/ros/master_proxy.rb', line 28 def initialize(caller_id, master_uri, slave_uri) @caller_id = caller_id @master_uri = master_uri @slave_uri = slave_uri @proxy = XMLRPC::Client.new2(@master_uri).proxy end |
Instance Attribute Details
#caller_id ⇒ String
caller id of this node
254 255 256 |
# File 'lib/ros/master_proxy.rb', line 254 def caller_id @caller_id end |
#master_uri ⇒ String
Master URI
237 238 239 |
# File 'lib/ros/master_proxy.rb', line 237 def master_uri @master_uri end |
#slave_uri ⇒ String
Slave URI
250 251 252 |
# File 'lib/ros/master_proxy.rb', line 250 def slave_uri @slave_uri end |
Instance Method Details
#get_published_topics(subgraph = '') ⇒ Array
get the all published topics
191 192 193 194 195 196 197 198 |
# File 'lib/ros/master_proxy.rb', line 191 def get_published_topics(subgraph='') code, , topics = @proxy.getPublishedTopics(@caller_id, subgraph) if code == 1 return topics elsif raise end end |
#get_system_state ⇒ Array
get system state
202 203 204 205 206 207 208 209 |
# File 'lib/ros/master_proxy.rb', line 202 def get_system_state code, , state = @proxy.getSystemState(@caller_id) if code == 1 return state else raise end end |
#get_uri ⇒ String
get the master URI
214 215 216 217 218 219 220 221 |
# File 'lib/ros/master_proxy.rb', line 214 def get_uri code, , uri = @proxy.getUri(@caller_id) if code == 1 return uri else raise end end |
#lookup_node(node_name) ⇒ String?
lookup a node by name.
178 179 180 181 182 183 184 185 |
# File 'lib/ros/master_proxy.rb', line 178 def lookup_node(node_name) code, , uri = @proxy.lookupNode(@caller_id, node_name) if code == 1 uri else nil end end |
#lookup_service(service) ⇒ String?
look up a service by name
226 227 228 229 230 231 232 233 |
# File 'lib/ros/master_proxy.rb', line 226 def lookup_service(service) code, , uri = @proxy.lookupService(@caller_id, service) if code == 1 uri else false end end |
#register_publisher(topic, topic_type) ⇒ Array
register a publisher
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/ros/master_proxy.rb', line 114 def register_publisher(topic, topic_type) code, , uris = @proxy.registerPublisher(@caller_id, topic, topic_type, @slave_uri) if code == 1 uris else raise end end |
#register_service(service, service_api) ⇒ Boolean
register a service
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ros/master_proxy.rb', line 40 def register_service(service, service_api) code, , val = @proxy.registerService(@caller_id, service, service_api, @slave_uri) if code == 1 return true else raise end end |
#register_subscriber(topic, topic_type) ⇒ Array
register a subscriber
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ros/master_proxy.rb', line 76 def register_subscriber(topic, topic_type) code, ,val = @proxy.registerSubscriber(@caller_id, topic, topic_type, @slave_uri) if code == 1 val elsif code == 0 puts val else raise end end |
#subscribe_param(key) ⇒ Boolean
this method is not described in the wiki. subscribe to the parameter key.
151 152 153 154 155 156 157 158 |
# File 'lib/ros/master_proxy.rb', line 151 def subscribe_param(key) code, , uri = @proxy.subscribeParam(@caller_id, @slave_uri, key) if code == 1 return true else raise end end |
#unregister_publisher(topic) ⇒ Boolean
unregister a publisher
130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/ros/master_proxy.rb', line 130 def unregister_publisher(topic) code, , val = @proxy.unregisterPublisher(@caller_id, topic, @slave_uri) if code == 1 return val elsif code == 0 puts return true else raise end return false end |
#unregister_service(service, service_api) ⇒ Boolean
unregister a service
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ros/master_proxy.rb', line 57 def unregister_service(service, service_api) code, , val = @proxy.unregisterService(@caller_id, service, service_api) if code == 1 return true elsif code == 0 puts return true else raise end end |
#unregister_subscriber(topic) ⇒ Boolean
unregister a subscriber
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ros/master_proxy.rb', line 95 def unregister_subscriber(topic) code, ,val = @proxy.unregisterSubscriber(@caller_id, topic, @slave_uri) if code == 1 return true elsif code == 0 puts return true else raise end end |
#unsubscribe_param(key) ⇒ Boolean
unsubscribe to the parameter key. this method is not described in the wiki.
166 167 168 169 170 171 172 173 |
# File 'lib/ros/master_proxy.rb', line 166 def unsubscribe_param(key) code, , uri = @proxy.unsubscribeParam(@caller_id, @slave_uri, key) if code == 1 return true else raise end end |