Module: Rclrb
- Defined in:
- lib/rclrb/qos.rb,
lib/rclrb/capi.rb,
lib/rclrb/init.rb,
lib/rclrb/node.rb,
lib/rclrb/time.rb,
lib/rclrb/clock.rb,
lib/rclrb/timer.rb,
lib/rclrb/client.rb,
lib/rclrb/fields.rb,
lib/rclrb/future.rb,
lib/rclrb/service.rb,
lib/rclrb/version.rb,
lib/rclrb/executor.rb,
lib/rclrb/internal.rb,
lib/rclrb/wait_set.rb,
lib/rclrb/publisher.rb,
lib/rclrb/interfaces.rb,
lib/rclrb/subscription.rb,
lib/rclrb/callback_group.rb,
lib/rclrb/guard_condition.rb,
lib/rclrb/common.rb
Defined Under Namespace
Modules: CApi, Fields, Interfaces, QosDurabilityPolicy, QosHistoryPolicy, QosLivelinessPolicy, QosReliabilityPolicy Classes: CallbackGroupBase, Client, Clock, Error, Executor, Future, GuardCondition, InterruptedClientCall, InvalidMessageTypeError, MutuallyExclusiveCallbackGroup, Node, ParseError, Publisher, QoSProfile, RclError, ReentrantCallbackGroup, Service, ServiceCallFailed, Subscription, Time, Timer, WaitSet
Constant Summary collapse
- QoSProfileSensorData =
Qos profile to be used for sensor data,
QoSProfile.new depth: 5, reliability: QosReliabilityPolicy::BestEffort
- QoSProfileParameters =
Qos profile to be used for parameters.
QoSProfile.new depth: 1000
- QoSProfileDefault =
Default Qos profile for topics.
QoSProfile.new depth: 10
- QoSProfileServicesDefault =
Default Qos profile for services.
QoSProfile.new depth: 10
- QoSProfileParameterEvents =
Default Qos profile for events.
QoSProfile.new depth: 1000
- QoSProfileSystemDefault =
Default Qos profile using system default (RMW implementation specific).
QoSProfile.new depth: 5, history: QosHistoryPolicy::SystemDefault, reliability: QosReliabilityPolicy::SystemDefault, durability: QosDurabilityPolicy::SystemDefault, liveliness: QosLivelinessPolicy::SystemDefault
- RosClock =
Represent a clock with Ros time (either system or simulated time)
Clock.new(:RCL_ROS_TIME)
- SystemClock =
Represent a clock that is always set to system time
Clock.new(:RCL_SYSTEM_TIME)
- VERSION =
"1.2.0"
Class Method Summary collapse
-
.camelize(str) ⇒ Object
Camelize a string, for instance transform “this_is_an_example” to “ThisIsAnExample”.
-
.init(arguments: []) ⇒ Object
Initialise Rclrb with the given arguments.
- .rcl_allocate(size) ⇒ Object
- .rcl_allocator ⇒ Object
- .rcl_context ⇒ Object
- .rcl_deallocate(ptr) ⇒ Object
- .rcl_shutdown_requested? ⇒ Boolean
- .rcl_signal_guard_condition ⇒ Object
- .setup_signal ⇒ Object
-
.shutdown ⇒ Object
Terminate Rclrb.
-
.spin(*nodes) ⇒ Object
Spin the given nodes using Executor.
-
.uncamelize(str) ⇒ Object
Uncamelize a string, for instance transform “ThisIsAnExample” to “this_is_an_example”.
Class Method Details
.camelize(str) ⇒ Object
Camelize a string, for instance transform “this_is_an_example” to “ThisIsAnExample”
13 14 15 |
# File 'lib/rclrb/internal.rb', line 13 def Rclrb.camelize str return str.split("_").map(&:capitalize).join end |
.init(arguments: []) ⇒ Object
Initialise Rclrb with the given arguments
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rclrb/init.rb', line 5 def Rclrb.init(arguments: []) @@initOptions = CApi.() @@context = CApi.rcl_get_zero_initialized_context() @@allocator = CApi.rcutils_get_default_allocator CApi.handle_result(CApi.(@@initOptions, @@allocator)) # Prepare arguments p_values = nil if arguments.length > 0 strings = arguments.map { |k| FFI::MemoryPointer.from_string(k.to_s) } p_values = FFI::MemoryPointer.new(:pointer, arguments.size + 1) p_values.write_array_of_pointer(strings) end # Call init CApi.handle_result(CApi.rcl_init(arguments.length, p_values, @@initOptions, @@context)) # Remove from arguments the ros arguments idx = 0 removing = false while idx < arguments.length if removing if arguments[idx] == "--" arguments.delete_at idx break end arguments.delete_at idx elsif arguments[idx] == "--ros-args" removing = true else idx += 1 end end # Guard condition to shutdown execution when shutdown is called @@signal_guard_condition = GuardCondition.new @@shutdown_requested = false # Setup signal to catch ctr+c Rclrb.setup_signal end |
.rcl_allocate(size) ⇒ Object
70 71 72 |
# File 'lib/rclrb/init.rb', line 70 def Rclrb.rcl_allocate(size) return @@allocator[:allocate].call size, @@allocator[:state] end |
.rcl_allocator ⇒ Object
67 68 69 |
# File 'lib/rclrb/init.rb', line 67 def Rclrb.rcl_allocator return @@allocator end |
.rcl_context ⇒ Object
58 59 60 |
# File 'lib/rclrb/init.rb', line 58 def Rclrb.rcl_context() return @@context end |
.rcl_deallocate(ptr) ⇒ Object
73 74 75 |
# File 'lib/rclrb/init.rb', line 73 def Rclrb.rcl_deallocate(ptr) @@allocator[:deallocate].call ptr, @@allocator[:state] end |
.rcl_shutdown_requested? ⇒ Boolean
64 65 66 |
# File 'lib/rclrb/init.rb', line 64 def Rclrb.rcl_shutdown_requested? return @@shutdown_requested end |
.rcl_signal_guard_condition ⇒ Object
61 62 63 |
# File 'lib/rclrb/init.rb', line 61 def Rclrb.rcl_signal_guard_condition return @@signal_guard_condition end |
.setup_signal ⇒ Object
46 47 48 49 50 51 |
# File 'lib/rclrb/init.rb', line 46 def Rclrb.setup_signal Signal.trap("INT") { puts "Interrupts called..." Rclrb.shutdown() } end |
.shutdown ⇒ Object
Terminate Rclrb
54 55 56 57 |
# File 'lib/rclrb/init.rb', line 54 def Rclrb.shutdown @@shutdown_requested = true @@signal_guard_condition.trigger end |
.spin(*nodes) ⇒ Object
Spin the given nodes using Executor
38 39 40 41 |
# File 'lib/rclrb/executor.rb', line 38 def Rclrb.spin(*nodes) e = Executor.new *nodes return e.spin end |
.uncamelize(str) ⇒ Object
Uncamelize a string, for instance transform “ThisIsAnExample” to “this_is_an_example”
4 5 6 7 8 9 10 |
# File 'lib/rclrb/internal.rb', line 4 def Rclrb.uncamelize str return str.gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2') .gsub(/([a-z\d])([A-Z])/,'\1_\2') .tr("-", "_") .downcase end |