rclrb 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rclrb/client.rb +1 -0
- data/lib/rclrb/executor.rb +9 -1
- data/lib/rclrb/fields.rb +33 -9
- data/lib/rclrb/init.rb +17 -0
- data/lib/rclrb/interfaces.rb +10 -1
- data/lib/rclrb/service.rb +1 -0
- data/lib/rclrb/subscription.rb +1 -0
- data/lib/rclrb/timer.rb +1 -0
- data/lib/rclrb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dc5c6fa67dfa18627ec77be2ee941d9793d6f0e66897e018444029f1318d036
|
4
|
+
data.tar.gz: 1e9422a5b7bad284ef7bc6c8a14b2b0f53bb6ab5331f83ce100bbe2f9601c3c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e00c7559faeb4389105ecef789be4e54acdd2dd472ef8cd6d2105e1e77e7c096d4310c13ac434549c6aaf63e728e4c735e28f4ccd005f905f2cf2b55b408d7c
|
7
|
+
data.tar.gz: 726f02ca7a4b692922428322e7e39527427c7832398d2c7ff3fcb3fa01265ef53c42abc55e335c8bce520d1eecf20d3712f5135a3a02cdc0fc596030e0c4bc61
|
data/lib/rclrb/client.rb
CHANGED
@@ -15,6 +15,7 @@ module Rclrb
|
|
15
15
|
client_ops = CApi.rcl_client_get_default_options()
|
16
16
|
client_ops[:qos] = QoSProfile.get_profile(qos_profile).ros_profile
|
17
17
|
CApi.handle_result CApi.rcl_client_init(@client_handle, node_handle, srv_type.type_support(), @srv_name, client_ops)
|
18
|
+
Rclrb.rcl_signal_guard_condition.trigger
|
18
19
|
end
|
19
20
|
|
20
21
|
rclrb_finalize_with :@client_handle, :@node_handle do |client_handle, node_handle|
|
data/lib/rclrb/executor.rb
CHANGED
@@ -7,6 +7,8 @@ module Rclrb
|
|
7
7
|
def initialize(*nodes)
|
8
8
|
@nodes = nodes
|
9
9
|
@groups = nodes.map { |x| x.default_callback_group }
|
10
|
+
@running = true
|
11
|
+
@exitcode = 0
|
10
12
|
end
|
11
13
|
##
|
12
14
|
# Add a node to the executor
|
@@ -14,15 +16,21 @@ module Rclrb
|
|
14
16
|
@nodes.append node
|
15
17
|
@groups.append node.default_callback_group
|
16
18
|
end
|
19
|
+
def shutdown(exitcode)
|
20
|
+
@exitcode = exitcode
|
21
|
+
@running = false
|
22
|
+
Rclrb.rcl_signal_guard_condition.trigger
|
23
|
+
end
|
17
24
|
##
|
18
25
|
# Spin continuously untill shutdown was requested
|
19
26
|
def spin()
|
20
|
-
|
27
|
+
while @running and not Rclrb.rcl_shutdown_requested?
|
21
28
|
wait_set = WaitSet.new
|
22
29
|
threads = @groups.map { |g| g.spin wait_set }
|
23
30
|
threads.each { |t| t.join }
|
24
31
|
wait_set.wait
|
25
32
|
end
|
33
|
+
return @exitcode
|
26
34
|
end
|
27
35
|
end
|
28
36
|
##
|
data/lib/rclrb/fields.rb
CHANGED
@@ -31,6 +31,9 @@ module Rclrb
|
|
31
31
|
@array_reader = array_reader
|
32
32
|
@array_writter = array_writter
|
33
33
|
end
|
34
|
+
def create_from_dict v
|
35
|
+
return v
|
36
|
+
end
|
34
37
|
def array_field()
|
35
38
|
@array_field = ArrayField.new(self) unless defined?(@array_field)
|
36
39
|
return @array_field
|
@@ -71,6 +74,9 @@ module Rclrb
|
|
71
74
|
def StringField.field_name()
|
72
75
|
return "Rclrb::Fields::StringField"
|
73
76
|
end
|
77
|
+
def StringField.create_from_dict v
|
78
|
+
return v
|
79
|
+
end
|
74
80
|
def StringField.parse_ros_message(data)
|
75
81
|
length = data[:length]
|
76
82
|
return data[:string].get_string(0, length)
|
@@ -78,14 +84,19 @@ module Rclrb
|
|
78
84
|
def StringField.parse_ros_message_array(data, length)
|
79
85
|
return Fields.__generic_parse_array(data, length, StringField.ffi_size) { |ptr| StringField.parse_ros_message FFIType.new(ptr) }
|
80
86
|
end
|
81
|
-
def StringField.
|
82
|
-
st = data[index]
|
87
|
+
def StringField.__fill_ros_message(ffi_struct, value)
|
83
88
|
str_pointer = Rclrb.rcl_allocate value.length + 1
|
84
|
-
|
89
|
+
ffi_struct[:string] = str_pointer
|
85
90
|
str_pointer.put_string(0, value)
|
86
91
|
str_pointer.put_uint8(value.length, 0)
|
87
|
-
|
88
|
-
|
92
|
+
ffi_struct[:length] = value.length
|
93
|
+
ffi_struct[:capacity] = value.length + 1
|
94
|
+
end
|
95
|
+
def StringField.fill_ros_message(data, index, value)
|
96
|
+
StringField.__fill_ros_message(data[index], value)
|
97
|
+
end
|
98
|
+
def StringField.fill_ros_message_array(array_pointer, value)
|
99
|
+
Fields.__generic_fill_ros_message_array(array_pointer, value, StringField.ffi_size) { |ptr, value| StringField.__fill_ros_message(ffi_type.new(ptr), value) }
|
89
100
|
end
|
90
101
|
def StringField.destroy_ros_message(data)
|
91
102
|
if data.kind_of? FFIType
|
@@ -118,15 +129,24 @@ module Rclrb
|
|
118
129
|
def TimeField.field_name()
|
119
130
|
return "Rclrb::Fields::TimeField"
|
120
131
|
end
|
132
|
+
def TimeField.create_from_dict v
|
133
|
+
return Time.from_sec_nsec v['sec'], v['nsec']
|
134
|
+
end
|
121
135
|
def TimeField.parse_ros_message(data)
|
122
136
|
return Time.from_sec_nsec data[:sec], data[:nsec]
|
123
137
|
end
|
124
|
-
def TimeField.
|
125
|
-
st = data[index]
|
138
|
+
def TimeField.__fill_ros_message(ffi_struct, value)
|
126
139
|
s, ns = value.to_sec_nsec
|
127
|
-
|
128
|
-
|
140
|
+
ffi_struct[:sec] = s
|
141
|
+
ffi_struct[:nsec] = ns
|
142
|
+
end
|
143
|
+
def TimeField.fill_ros_message(data, index, value)
|
144
|
+
TimeField.__fill_ros_message(data[index], value)
|
129
145
|
end
|
146
|
+
def TimeField.fill_ros_message_array(array_pointer, value)
|
147
|
+
Fields.__generic_fill_ros_message_array(array_pointer, value, TimeField.ffi_size) { |ptr, value| TimeField.__fill_ros_message(ffi_type.new(ptr), value) }
|
148
|
+
end
|
149
|
+
|
130
150
|
def TimeField.destroy_ros_message(data)
|
131
151
|
end
|
132
152
|
def TimeField.array_field()
|
@@ -156,6 +176,10 @@ module Rclrb
|
|
156
176
|
def field_name()
|
157
177
|
return "#{@field.field_name}.array_field()"
|
158
178
|
end
|
179
|
+
def create_from_dict v
|
180
|
+
raise RclError.new "Expected Array got '#{v}' of type '#{v.class}'" unless v.is_a? Array
|
181
|
+
return v.map { |x| @field.create_from_dict x }
|
182
|
+
end
|
159
183
|
def parse_ros_message(data)
|
160
184
|
return @field.parse_ros_message_array data[:array], data[:length]
|
161
185
|
end
|
data/lib/rclrb/init.rb
CHANGED
@@ -19,6 +19,23 @@ module Rclrb
|
|
19
19
|
# Call init
|
20
20
|
CApi.handle_result(CApi.rcl_init(arguments.length, p_values, @@initOptions, @@context))
|
21
21
|
|
22
|
+
# Remove from arguments the ros arguments
|
23
|
+
idx = 0
|
24
|
+
removing = false
|
25
|
+
while idx < arguments.length
|
26
|
+
if removing
|
27
|
+
if arguments[idx] == "--"
|
28
|
+
arguments.delete_at idx
|
29
|
+
break
|
30
|
+
end
|
31
|
+
arguments.delete_at idx
|
32
|
+
elsif arguments[idx] == "--ros-args"
|
33
|
+
removing = true
|
34
|
+
else
|
35
|
+
idx += 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
22
39
|
# Guard condition to shutdown execution when shutdown is called
|
23
40
|
@@signal_guard_condition = GuardCondition.new
|
24
41
|
@@shutdown_requested = false
|
data/lib/rclrb/interfaces.rb
CHANGED
@@ -112,8 +112,17 @@ module Rclrb
|
|
112
112
|
@<%= field[:name] %> = <%= field[:field_init_value] %>
|
113
113
|
<% end %>
|
114
114
|
end
|
115
|
+
def #{klass_name}.create_from_dict(dict)
|
116
|
+
v = #{klass_name}.new
|
117
|
+
<% mdef[:fields][#{index}].each do |field| %>
|
118
|
+
if dict.include? '<%= field[:name] %>'
|
119
|
+
v.<%= field[:name] %> = <%= field[:field_def_name] %>.create_from_dict(dict['<%= field[:name] %>'])
|
120
|
+
end
|
121
|
+
<% end %>
|
122
|
+
return v
|
123
|
+
end
|
115
124
|
class FFIType < FFI::Struct
|
116
|
-
layout <%= mdef[:fields][#{index}].map { |f| ":" + f[:name] + ", " + f[:field_def_name] + ".ffi_type" }.join(" ,") %>
|
125
|
+
layout <%= mdef[:fields][#{index}].map { |f| ":" + f[:name] + ", " + f[:field_def_name] + ".ffi_type" }.join(" ,") %><% if(mdef[:fields][#{index}].empty?) %> :__dummy__, :int <% end %>
|
117
126
|
end
|
118
127
|
|
119
128
|
def #{klass_name}.get_ffi_struct(data)
|
data/lib/rclrb/service.rb
CHANGED
@@ -16,6 +16,7 @@ module Rclrb
|
|
16
16
|
service_ops = CApi.rcl_service_get_default_options()
|
17
17
|
service_ops[:qos] = QoSProfile.get_profile(qos_profile).ros_profile
|
18
18
|
CApi.handle_result CApi.rcl_service_init(@service_handle, node_handle, srv_type.type_support(), @srv_name, service_ops)
|
19
|
+
Rclrb.rcl_signal_guard_condition.trigger
|
19
20
|
end
|
20
21
|
|
21
22
|
rclrb_finalize_with :@service_handle, :@node_handle do |service_handle, node_handle|
|
data/lib/rclrb/subscription.rb
CHANGED
@@ -17,6 +17,7 @@ module Rclrb
|
|
17
17
|
subscription_ops = CApi.rcl_subscription_get_default_options()
|
18
18
|
subscription_ops[:qos] = QoSProfile.get_profile(qos_profile).ros_profile
|
19
19
|
CApi.handle_result CApi.rcl_subscription_init(@subscription_handle, node_handle, msg_type.type_support(), @topic, subscription_ops)
|
20
|
+
Rclrb.rcl_signal_guard_condition.trigger
|
20
21
|
end
|
21
22
|
rclrb_finalize_with :@subscription_handle, :@node_handle do |subscription_handle, node_handle|
|
22
23
|
CApi.handle_result CApi.rcl_subscription_fini(subscription_handle, node_handle)
|
data/lib/rclrb/timer.rb
CHANGED
@@ -13,6 +13,7 @@ module Rclrb
|
|
13
13
|
callback_group.add self
|
14
14
|
|
15
15
|
CApi.handle_result(CApi.rcl_timer_init(handle, clock.handle, Rclrb.rcl_context, timer_period_sec*1e9, @callback_proc, Rclrb.rcl_allocator))
|
16
|
+
Rclrb.rcl_signal_guard_condition.trigger
|
16
17
|
end
|
17
18
|
|
18
19
|
rclrb_finalize_with :@timer_handle, :@node_handle do |timer_handle, node_handle|
|
data/lib/rclrb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rclrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyrille Berger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|