Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DDS XTypes creation #445

Open
wants to merge 33 commits into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b666007
update with latest cyclonedds
Splinter1984 Mar 10, 2023
f8f58cb
init commit for dynamic_type support
Splinter1984 Mar 20, 2023
e893350
Merge pull request #1 from ros2/rolling
Splinter1984 Mar 20, 2023
0c8072d
add dynamic_type creation func
Splinter1984 Mar 22, 2023
28b3493
add array convertion
Splinter1984 Mar 27, 2023
a0b74a7
Merge branch 'ros2:rolling' into dynamic-type
Splinter1984 Mar 28, 2023
e0488c0
make create_dds_dynamic_type from untyped_members
Splinter1984 Mar 28, 2023
f19c4d4
remove test method
Splinter1984 Mar 28, 2023
1ac423a
Merge branch 'dynamic-type' of github.com:Splinter1984/rmw_cyclonedds…
Splinter1984 Mar 28, 2023
3afab74
cleanup
Splinter1984 Mar 28, 2023
a40600f
remove debug log
Splinter1984 Mar 28, 2023
67bf321
Merge branch 'rolling' into dynamic-type
Splinter1984 Mar 28, 2023
410d68e
Merge branch 'ros2:rolling' into rolling
Splinter1984 Mar 28, 2023
17c4347
Merge branch 'rolling' into dynamic-type
Splinter1984 Mar 28, 2023
37139ce
implement service client dynamic_type
Splinter1984 Apr 4, 2023
74e95ba
Merge branch 'ros2:rolling' into rolling
Splinter1984 Apr 12, 2023
d410b86
move descriptor to CddsTypeSupport
Splinter1984 Apr 12, 2023
cae501e
move type_register to create_sertype func
Splinter1984 Apr 12, 2023
1837624
Merge branch 'ros2:rolling' into rolling
Splinter1984 Apr 13, 2023
f84a51e
Merge branch 'rolling' into dynamic-type
Splinter1984 Apr 13, 2023
754867d
resolve qos problem
Splinter1984 Apr 17, 2023
82604ae
cleanup
Splinter1984 Apr 17, 2023
46950b8
remove unused policy
Splinter1984 May 8, 2023
8570d85
switch back to xcdr1
Splinter1984 May 10, 2023
251a238
fix warnings
Splinter1984 May 22, 2023
c638859
cleanup
Splinter1984 May 26, 2023
70e67d4
resolve suggestions
Splinter1984 May 28, 2023
a85d27d
compatible with older version
Splinter1984 May 29, 2023
4701e47
remove unused return
Splinter1984 May 29, 2023
863e834
hide whole functions
Splinter1984 May 30, 2023
5bd8041
hide whole unused functions depend on cdds version
Splinter1984 May 30, 2023
ee0f77b
Merge branch 'ros2:rolling' into rolling
Splinter1984 Jun 19, 2023
c2cd4a1
Merge branch 'rolling' into dynamic-type
Splinter1984 Jun 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 46 additions & 15 deletions rmw_cyclonedds_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,6 @@ static bool check_create_domain(dds_domainid_t did, rmw_discovery_options_t * di
}
config += "</Peers>";
}

/* NOTE: Empty configuration fragments are ignored, so it is safe to
unconditionally append a comma. */
config += "</Discovery></Domain></CycloneDDS>,";
Expand Down Expand Up @@ -2316,6 +2315,7 @@ static rmw_qos_policy_kind_t dds_qos_policy_to_rmw_qos_policy(dds_qos_policy_id_
case DDS_LIFESPAN_QOS_POLICY_ID:
return RMW_QOS_POLICY_LIFESPAN;
default:
RCUTILS_LOG_ERROR_NAMED("rmw_cyclonedds_cpp", "%d", policy_id);
return RMW_QOS_POLICY_INVALID;
}
}
Expand Down Expand Up @@ -2478,10 +2478,14 @@ static CddsPublisher * create_cdds_publisher(
std::string fqtopic_name = make_fqtopic(ROS_TOPIC_PREFIX, topic_name, "", qos_policies);
bool is_fixed_type = is_type_self_contained(type_support);
uint32_t sample_size = static_cast<uint32_t>(rmw_cyclonedds_cpp::get_message_size(type_support));

auto sertype = create_sertype(
type_support->typesupport_identifier,
create_message_type_support(type_support->data, type_support->typesupport_identifier), false,
rmw_cyclonedds_cpp::make_message_value_type(type_supports), sample_size, is_fixed_type);
create_message_type_support(type_support->data, type_support->typesupport_identifier),
false,
rmw_cyclonedds_cpp::make_message_value_type(type_supports),
sample_size, is_fixed_type);
create_msg_dds_dynamic_type(type_support->typesupport_identifier, type_support->data, dds_ppant, sertype);
struct ddsi_sertype * stact = nullptr;
topic = create_topic(dds_ppant, fqtopic_name.c_str(), sertype, &stact);

Expand All @@ -2506,6 +2510,7 @@ static CddsPublisher * create_cdds_publisher(
RMW_SET_ERROR_MSG("failed to get instance handle for writer");
goto fail_instance_handle;
}

get_entity_gid(pub->enth, pub->gid);
pub->sertype = stact;
dds_delete_listener(listener);
Expand All @@ -2514,6 +2519,7 @@ static CddsPublisher * create_cdds_publisher(
pub->sample_size = sample_size;
dds_delete_qos(qos);
dds_delete(topic);

return pub;

fail_instance_handle:
Expand Down Expand Up @@ -3011,10 +3017,14 @@ static CddsSubscription * create_cdds_subscription(
std::string fqtopic_name = make_fqtopic(ROS_TOPIC_PREFIX, topic_name, "", qos_policies);
bool is_fixed_type = is_type_self_contained(type_support);
uint32_t sample_size = static_cast<uint32_t>(rmw_cyclonedds_cpp::get_message_size(type_support));

auto sertype = create_sertype(
type_support->typesupport_identifier,
create_message_type_support(type_support->data, type_support->typesupport_identifier), false,
rmw_cyclonedds_cpp::make_message_value_type(type_supports), sample_size, is_fixed_type);
create_message_type_support(type_support->data, type_support->typesupport_identifier),
false,
rmw_cyclonedds_cpp::make_message_value_type(type_supports),
sample_size, is_fixed_type);
create_msg_dds_dynamic_type(type_support->typesupport_identifier, type_support->data, dds_ppant, sertype);
topic = create_topic(dds_ppant, fqtopic_name.c_str(), sertype);

dds_listener_t * listener = dds_create_listener(&sub->user_callback_data);
Expand Down Expand Up @@ -3047,6 +3057,7 @@ static CddsSubscription * create_cdds_subscription(
sub->is_loaning_available = is_fixed_type && dds_is_loan_available(sub->enth);
dds_delete_qos(qos);
dds_delete(topic);

return sub;
fail_readcond:
if (dds_delete(sub->enth) < 0) {
Expand Down Expand Up @@ -4958,6 +4969,9 @@ static rmw_ret_t rmw_init_cs(

dds_listener_t * listener = dds_create_listener(cb_data);
dds_lset_data_available_arg(listener, dds_listener_callback, cb_data, false);


struct sertype_rmw * pub_st, * sub_st;

if (is_service) {
std::tie(sub_msg_ts, pub_msg_ts) =
Expand All @@ -4974,6 +4988,18 @@ static rmw_ret_t rmw_init_cs(
subtopic_name =
make_fqtopic(ROS_SERVICE_REQUESTER_PREFIX, service_name, "Request", qos_policies);
pubtopic_name = make_fqtopic(ROS_SERVICE_RESPONSE_PREFIX, service_name, "Reply", qos_policies);

pub_st = create_sertype(
type_support->typesupport_identifier, pub_type_support, true,
std::move(pub_msg_ts), 0U, false
);
create_res_dds_dynamic_type(type_support->typesupport_identifier, type_support->data, node->context->impl->ppant, pub_st);
sub_st = create_sertype(
type_support->typesupport_identifier, sub_type_support, true,
std::move(sub_msg_ts), 0U, false
);
create_req_dds_dynamic_type(type_support->typesupport_identifier, type_support->data, node->context->impl->ppant, sub_st);

} else {
std::tie(pub_msg_ts, sub_msg_ts) =
rmw_cyclonedds_cpp::make_request_response_value_types(type_supports);
Expand All @@ -4989,6 +5015,18 @@ static rmw_ret_t rmw_init_cs(
pubtopic_name =
make_fqtopic(ROS_SERVICE_REQUESTER_PREFIX, service_name, "Request", qos_policies);
subtopic_name = make_fqtopic(ROS_SERVICE_RESPONSE_PREFIX, service_name, "Reply", qos_policies);

pub_st = create_sertype(
type_support->typesupport_identifier, pub_type_support, true,
std::move(pub_msg_ts), 0U, false
);
create_req_dds_dynamic_type(type_support->typesupport_identifier, type_support->data, node->context->impl->ppant, pub_st);
sub_st = create_sertype(
type_support->typesupport_identifier, sub_type_support, true,
std::move(sub_msg_ts), 0U, false
);
create_res_dds_dynamic_type(type_support->typesupport_identifier, type_support->data, node->context->impl->ppant, sub_st);

}

RCUTILS_LOG_DEBUG_NAMED(
Expand All @@ -4999,21 +5037,14 @@ static rmw_ret_t rmw_init_cs(
RCUTILS_LOG_DEBUG_NAMED("rmw_cyclonedds_cpp", "***********");

dds_entity_t pubtopic, subtopic;
struct sertype_rmw * pub_st, * sub_st;

pub_st = create_sertype(
type_support->typesupport_identifier, pub_type_support, true,
std::move(pub_msg_ts));

struct ddsi_sertype * pub_stact;
pubtopic = create_topic(node->context->impl->ppant, pubtopic_name.c_str(), pub_st, &pub_stact);
if (pubtopic < 0) {
set_error_message_from_create_topic(pubtopic, pubtopic_name);
goto fail_pubtopic;
}

sub_st = create_sertype(
type_support->typesupport_identifier, sub_type_support, true,
std::move(sub_msg_ts));

subtopic = create_topic(node->context->impl->ppant, subtopic_name.c_str(), sub_st);
if (subtopic < 0) {
set_error_message_from_create_topic(subtopic, subtopic_name);
Expand Down Expand Up @@ -5060,8 +5091,8 @@ static rmw_ret_t rmw_init_cs(
dds_delete_listener(listener);
dds_delete_qos(pub_qos);
dds_delete_qos(sub_qos);
dds_delete(subtopic);
dds_delete(pubtopic);
dds_delete(subtopic);

cs->pub = std::move(pub);
cs->sub = std::move(sub);
Expand Down
Loading