Class: ROS::SlaveProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/ros/slave_proxy.rb

Overview

you can access to ROS Slave nodes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(caller_id, slave_uri) ⇒ SlaveProxy

Returns a new instance of SlaveProxy.

Parameters:

  • caller_id (String)

    caller id of this node

  • slave_uri (String)

    URI to connect



23
24
25
26
27
# File 'lib/ros/slave_proxy.rb', line 23

def initialize(caller_id, slave_uri)
  @caller_id = caller_id
  @slave_uri = slave_uri
  @proxy = XMLRPC::Client.new2(@slave_uri).proxy
end

Instance Attribute Details

#caller_idString

Returns caller_id of this caller.

Returns:

  • (String)

    caller_id of this caller



151
152
153
# File 'lib/ros/slave_proxy.rb', line 151

def caller_id
  @caller_id
end

#slave_uriString

Returns URI of target.

Returns:

  • (String)

    URI of target



148
149
150
# File 'lib/ros/slave_proxy.rb', line 148

def slave_uri
  @slave_uri
end

Instance Method Details

#get_bus_infoArray

Returns bus information.

Returns:

  • (Array)

    bus information

Raises:

  • (RuntimeError)

    if fail



42
43
44
45
46
47
48
49
# File 'lib/ros/slave_proxy.rb', line 42

def get_bus_info
  code, message, info = @proxy.getBusInfo(@caller_id)
  if code == 1
    return info
  else
    raise message
  end
end

#get_bus_statsArray

Returns stats.

Returns:

  • (Array)

    stats

Raises:

  • (RuntimeError)

    if fail



31
32
33
34
35
36
37
38
# File 'lib/ros/slave_proxy.rb', line 31

def get_bus_stats
  code, message, stats = @proxy.getBusStats(@caller_id)
  if code == 1
    return stats
  else
    raise message
  end
end

#get_master_uriString

Returns URI of master.

Returns:

  • (String)

    URI of master

Raises:

  • (RuntimeError)

    if fail



53
54
55
56
57
58
59
60
# File 'lib/ros/slave_proxy.rb', line 53

def get_master_uri
  code, message, uri = @proxy.getMasterUri(@caller_id)
  if code == 1
    return uri
  else
    raise message
  end
end

#get_pidInteger

Returns pid of the slave process.

Returns:

  • (Integer)

    pid of the slave process

Raises:

  • (RuntimeError)

    if fail



77
78
79
80
81
82
83
84
# File 'lib/ros/slave_proxy.rb', line 77

def get_pid
  code, message, pid = @proxy.getPid(@caller_id)
  if code == 1
    return pid
  else
    raise message
  end
end

#get_publicationsArray

Returns publications.

Returns:

  • (Array)

    publications

Raises:

  • (RuntimeError)

    if fail



99
100
101
102
103
104
105
106
# File 'lib/ros/slave_proxy.rb', line 99

def get_publications
  code, message, topic = @proxy.getPublications(@caller_id)
  if code == 1
    return topic
  else
    raise message
  end
end

#get_subscriptionsArray

Returns topiccs.

Returns:

  • (Array)

    topiccs

Raises:

  • (RuntimeError)

    if fail



88
89
90
91
92
93
94
95
# File 'lib/ros/slave_proxy.rb', line 88

def get_subscriptions
  code, message, topic = @proxy.getSubscriptions(@caller_id)
  if code == 1
    return topic
  else
    raise message
  end
end

#param_update(param_key, param_value) ⇒ Boolean

Returns true.

Parameters:

  • param_key (String)

    key for param

  • param_value (String, Integer, Float, Boolean, Array)

    new value for key

Returns:

  • (Boolean)

    true

Raises:

  • (RuntimeError)

    if fail



112
113
114
115
116
117
118
119
# File 'lib/ros/slave_proxy.rb', line 112

def param_update(param_key, param_value)
  code, message, val = @proxy.paramUpdate(@caller_id, param_key, param_value)
  if code == 1
    return true
  else
    raise message
  end
end

#publisher_update(topic, publishers) ⇒ Boolean

Returns true.

Parameters:

  • topic (String)

    name of topic

  • publishers (Array)

    array of publisher uri

Returns:

  • (Boolean)

    true

Raises:

  • (RuntimeError)

    if fail



125
126
127
128
129
130
131
132
# File 'lib/ros/slave_proxy.rb', line 125

def publisher_update(topic, publishers)
  code, message, val = @proxy.publisherUpdate(@caller_id, topic, publishers)
  if code == 1
    return true
  else
    raise message
  end
end

#request_topic(topic, protocols) ⇒ Object

Parameters:

  • topic (String)

    name of topic



136
137
138
139
140
141
142
143
144
145
# File 'lib/ros/slave_proxy.rb', line 136

def request_topic(topic, protocols)
  code, message, protocol = @proxy.requestTopic(@caller_id,
                                                topic,
                                                protocols)
  if code == 1
    return protocol
  else
    raise message
  end
end

#shutdown(msg = '') ⇒ Object

Parameters:

  • msg (String) (defaults to: '')

    message to slave (reason of shutdown request)

Raises:

  • (RuntimeError)

    if fail



64
65
66
67
68
69
70
71
72
73
# File 'lib/ros/slave_proxy.rb', line 64

def shutdown(msg='')
  code, message, val = @proxy.shutdown(@caller_id, msg)
  if code == 1
    return true
  elsif code == 0
    return false
  else
    raise message
  end
end