Skip to content

Commit e1a1d52

Browse files
Update Bin entity creation API (#213) (#214)
* Update Bin entity creation API Signed-off-by: Pablo Garrido <pablogs9@gmail.com> * Fix Signed-off-by: Pablo Garrido <pablogs9@gmail.com> * Fix Signed-off-by: Pablo Garrido <pablogs9@gmail.com> * Fix Signed-off-by: Pablo Garrido <pablogs9@gmail.com> * Update .github/workflows/ci.yml * Update .github/workflows/ci.yml (cherry picked from commit d5985d6) Co-authored-by: Pablo Garrido <pablogs9@gmail.com>
1 parent f35e200 commit e1a1d52

6 files changed

Lines changed: 55 additions & 42 deletions

File tree

rmw_microxrcedds_c/src/rmw_client.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ rmw_create_client(
140140
res_type_name,
141141
req_topic_name,
142142
res_topic_name,
143+
convert_qos_profile(qos_policies),
143144
UXR_REPLACE | UXR_REUSE);
144145
#endif /* ifdef RMW_UXRCE_USE_XML */
145146

rmw_microxrcedds_c/src/rmw_microros_internal/utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ bool run_xrce_session(
2525
uint16_t requests,
2626
int timeout);
2727

28+
uxrQoS_t convert_qos_profile(const rmw_qos_profile_t * rmw_qos);
29+
2830
int generate_name(
2931
const uxrObjectId * id,
3032
char name[],

rmw_microxrcedds_c/src/rmw_publisher.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -198,33 +198,13 @@ rmw_create_publisher(
198198
custom_publisher->datawriter_id,
199199
custom_publisher->publisher_id, rmw_uxrce_entity_naming_buffer, UXR_REPLACE | UXR_REUSE);
200200
#else
201-
bool reliability = qos_policies->reliability == RMW_QOS_POLICY_RELIABILITY_RELIABLE ||
202-
qos_policies->reliability == RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT;
203-
bool history = qos_policies->history == RMW_QOS_POLICY_HISTORY_KEEP_LAST;
204-
205-
uxrQoSDurability durability;
206-
switch (qos_policies->durability) {
207-
case RMW_QOS_POLICY_DURABILITY_VOLATILE:
208-
durability = UXR_DURABILITY_VOLATILE;
209-
break;
210-
case RMW_QOS_POLICY_DURABILITY_UNKNOWN:
211-
case RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT:
212-
case RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL:
213-
default:
214-
durability = UXR_DURABILITY_TRANSIENT_LOCAL;
215-
break;
216-
}
217-
218201
datawriter_req = uxr_buffer_create_datawriter_bin(
219202
&custom_publisher->owner_node->context->session,
220203
*custom_node->context->creation_stream,
221204
custom_publisher->datawriter_id,
222205
custom_publisher->publisher_id,
223206
custom_publisher->topic->topic_id,
224-
reliability,
225-
history,
226-
qos_policies->depth,
227-
durability,
207+
convert_qos_profile(qos_policies),
228208
UXR_REPLACE | UXR_REUSE);
229209
#endif /* ifdef RMW_UXRCE_USE_REFS */
230210

rmw_microxrcedds_c/src/rmw_service.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ rmw_create_service(
137137
res_type_name,
138138
req_topic_name,
139139
res_topic_name,
140+
convert_qos_profile(qos_policies),
140141
UXR_REPLACE | UXR_REUSE);
141142
#endif /* ifdef RMW_UXRCE_USE_XML */
142143

rmw_microxrcedds_c/src/rmw_subscription.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -183,33 +183,13 @@ rmw_create_subscription(
183183
*custom_node->context->creation_stream, custom_subscription->datareader_id,
184184
custom_subscription->subscriber_id, rmw_uxrce_entity_naming_buffer, UXR_REPLACE | UXR_REUSE);
185185
#else
186-
bool reliability = qos_policies->reliability == RMW_QOS_POLICY_RELIABILITY_RELIABLE ||
187-
qos_policies->reliability == RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT;
188-
bool history = qos_policies->history == RMW_QOS_POLICY_HISTORY_KEEP_LAST;
189-
190-
uxrQoSDurability durability;
191-
switch (qos_policies->durability) {
192-
case RMW_QOS_POLICY_DURABILITY_VOLATILE:
193-
durability = UXR_DURABILITY_VOLATILE;
194-
break;
195-
case RMW_QOS_POLICY_DURABILITY_UNKNOWN:
196-
case RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT:
197-
case RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL:
198-
default:
199-
durability = UXR_DURABILITY_TRANSIENT_LOCAL;
200-
break;
201-
}
202-
203186
datareader_req = uxr_buffer_create_datareader_bin(
204187
&custom_node->context->session,
205188
*custom_node->context->creation_stream,
206189
custom_subscription->datareader_id,
207190
custom_subscription->subscriber_id,
208191
custom_subscription->topic->topic_id,
209-
reliability,
210-
history,
211-
qos_policies->depth,
212-
durability,
192+
convert_qos_profile(qos_policies),
213193
UXR_REPLACE | UXR_REUSE);
214194
#endif /* ifdef RMW_UXRCE_USE_XML */
215195

rmw_microxrcedds_c/src/utils.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,55 @@ bool run_xrce_session(
4949
return true;
5050
}
5151

52+
uxrQoS_t convert_qos_profile(const rmw_qos_profile_t * rmw_qos)
53+
{
54+
uxrQoSDurability durability;
55+
switch (rmw_qos->durability) {
56+
case RMW_QOS_POLICY_DURABILITY_VOLATILE:
57+
durability = UXR_DURABILITY_VOLATILE;
58+
break;
59+
case RMW_QOS_POLICY_DURABILITY_UNKNOWN:
60+
case RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT:
61+
case RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL:
62+
default:
63+
durability = UXR_DURABILITY_TRANSIENT_LOCAL;
64+
break;
65+
}
66+
67+
uxrQoSReliability reliability;
68+
switch (rmw_qos->reliability) {
69+
case RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT:
70+
reliability = UXR_RELIABILITY_BEST_EFFORT;
71+
break;
72+
case RMW_QOS_POLICY_RELIABILITY_RELIABLE:
73+
case RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT:
74+
default:
75+
reliability = UXR_RELIABILITY_RELIABLE;
76+
break;
77+
}
78+
79+
uxrQoSHistory history;
80+
switch (rmw_qos->history) {
81+
case RMW_QOS_POLICY_HISTORY_KEEP_ALL:
82+
history = UXR_HISTORY_KEEP_ALL;
83+
break;
84+
case RMW_QOS_POLICY_HISTORY_KEEP_LAST:
85+
default:
86+
history = UXR_HISTORY_KEEP_LAST;
87+
break;
88+
}
89+
90+
uxrQoS_t qos = {
91+
.durability = durability,
92+
.reliability = reliability,
93+
.history = history,
94+
.depth = rmw_qos->depth,
95+
};
96+
97+
return qos;
98+
}
99+
100+
52101
int build_participant_xml(
53102
size_t domain_id,
54103
const char * participant_name,

0 commit comments

Comments
 (0)