Module: ROS

Defined in:
lib/ros/ros.rb,
lib/ros/log.rb,
lib/ros/name.rb,
lib/ros/rate.rb,
lib/ros/node.rb,
lib/ros/time.rb,
lib/ros/topic.rb,
lib/ros/master.rb,
lib/ros/roscore.rb,
lib/ros/message.rb,
lib/ros/service.rb,
lib/ros/package.rb,
lib/ros/duration.rb,
lib/ros/publisher.rb,
lib/ros/subscriber.rb,
lib/ros/slave_proxy.rb,
lib/ros/xmlrpcserver.rb,
lib/ros/master_proxy.rb,
lib/ros/graph_manager.rb,
lib/ros/service_server.rb,
lib/ros/service_client.rb,
lib/ros/parameter_manager.rb,
lib/ros/parameter_subscriber.rb

Overview

ros/parameter_subscriber.rb

License: BSD

Copyright (C) 2012 Takashi Ogura <t.ogura@gmail.com>

Parameter Subscriber

callback object for paramUpdate

Defined Under Namespace

Modules: Name, TCPROS Classes: Duration, GraphManager, LocalLogger, Log, Master, MasterProxy, Message, Node, Package, ParameterManager, ParameterSubscriber, Publisher, Rate, Service, ServiceClient, ServiceServer, SlaveProxy, Struct, Subscriber, Time, TimeValue, Topic, XMLRPCServer

Class Method Summary (collapse)

Class Method Details

+ (Object) load_manifest(package)

load manifest and add all dependencies

Parameters:

  • package (String)

    name of package



169
170
171
# File 'lib/ros/package.rb', line 169

def self.load_manifest(package)
  ROS::Package.add_path_with_depend_packages(package)
end

+ (Object) start_roscore

Start roscore. starts rosmaster and rosout.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ros/roscore.rb', line 35

def self.start_roscore
  # master
  thread = Thread.new do
    ROS::Master.new.start
  end

  if not wait_roscore(10.0)
    raise "rosmaster did not response in 10.0 secs"
  end

  # rosout
  rosout_node = ROS::Node.new('/rosout', :nologger=>true)
  rosout_agg_publisher = rosout_node.advertise('/rosout_agg', Rosgraph_msgs::Log)
  rosout_node.subscribe('/rosout', Rosgraph_msgs::Log) do |msg|
    rosout_agg_publisher.publish(msg)
  end
  rosout_node.spin
end

+ (Bool) wait_roscore(timeout_sec = 10.0)

Wait until roscore is ready.

Parameters:

  • timeout_sec (Float) (defaults to: 10.0)

    time to wait [sec]

Returns:

  • (Bool)

    true: roscore is ready now. false: timeout.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ros/roscore.rb', line 13

def self.wait_roscore(timeout_sec=10.0)
  proxy = XMLRPC::Client.new2(ENV['ROS_MASTER_URI']).proxy
  pid = nil
  begin
    timeout(timeout_sec) do
      while not pid
        begin
          pid = proxy.getPid('/roscore')
        rescue
          sleep 0.5
        end
      end
    end
    true
  rescue Timeout::Error
    false
  end
end