AP_DDS: use TopicIndex enum to index topics table

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
This commit is contained in:
Rhys Mainwaring 2023-09-06 23:13:49 +01:00 committed by Peter Barker
parent 221628c396
commit d82f3e9591
1 changed files with 8 additions and 8 deletions

View File

@ -770,7 +770,7 @@ void AP_DDS_Client::write_time_topic()
if (connected) {
ucdrBuffer ub {};
const uint32_t topic_size = builtin_interfaces_msg_Time_size_of_topic(&time_topic, 0);
uxr_prepare_output_stream(&session,reliable_out,topics[0].dw_id,&ub,topic_size);
uxr_prepare_output_stream(&session, reliable_out, topics[to_underlying(TopicIndex::TIME_PUB)].dw_id, &ub, topic_size);
const bool success = builtin_interfaces_msg_Time_serialize_topic(&ub, &time_topic);
if (!success) {
// TODO sometimes serialization fails on bootup. Determine why.
@ -785,7 +785,7 @@ void AP_DDS_Client::write_nav_sat_fix_topic()
if (connected) {
ucdrBuffer ub {};
const uint32_t topic_size = sensor_msgs_msg_NavSatFix_size_of_topic(&nav_sat_fix_topic, 0);
uxr_prepare_output_stream(&session,reliable_out,topics[1].dw_id,&ub,topic_size);
uxr_prepare_output_stream(&session, reliable_out, topics[to_underlying(TopicIndex::NAV_SAT_FIX_PUB)].dw_id, &ub, topic_size);
const bool success = sensor_msgs_msg_NavSatFix_serialize_topic(&ub, &nav_sat_fix_topic);
if (!success) {
// TODO sometimes serialization fails on bootup. Determine why.
@ -800,7 +800,7 @@ void AP_DDS_Client::write_static_transforms()
if (connected) {
ucdrBuffer ub {};
const uint32_t topic_size = tf2_msgs_msg_TFMessage_size_of_topic(&tx_static_transforms_topic, 0);
uxr_prepare_output_stream(&session,reliable_out,topics[2].dw_id,&ub,topic_size);
uxr_prepare_output_stream(&session, reliable_out, topics[to_underlying(TopicIndex::STATIC_TRANSFORMS_PUB)].dw_id, &ub, topic_size);
const bool success = tf2_msgs_msg_TFMessage_serialize_topic(&ub, &tx_static_transforms_topic);
if (!success) {
// TODO sometimes serialization fails on bootup. Determine why.
@ -815,7 +815,7 @@ void AP_DDS_Client::write_battery_state_topic()
if (connected) {
ucdrBuffer ub {};
const uint32_t topic_size = sensor_msgs_msg_BatteryState_size_of_topic(&battery_state_topic, 0);
uxr_prepare_output_stream(&session,reliable_out,topics[3].dw_id,&ub,topic_size);
uxr_prepare_output_stream(&session, reliable_out, topics[to_underlying(TopicIndex::BATTERY_STATE_PUB)].dw_id, &ub, topic_size);
const bool success = sensor_msgs_msg_BatteryState_serialize_topic(&ub, &battery_state_topic);
if (!success) {
// TODO sometimes serialization fails on bootup. Determine why.
@ -830,7 +830,7 @@ void AP_DDS_Client::write_local_pose_topic()
if (connected) {
ucdrBuffer ub {};
const uint32_t topic_size = geometry_msgs_msg_PoseStamped_size_of_topic(&local_pose_topic, 0);
uxr_prepare_output_stream(&session,reliable_out,topics[4].dw_id,&ub,topic_size);
uxr_prepare_output_stream(&session, reliable_out, topics[to_underlying(TopicIndex::LOCAL_POSE_PUB)].dw_id, &ub, topic_size);
const bool success = geometry_msgs_msg_PoseStamped_serialize_topic(&ub, &local_pose_topic);
if (!success) {
// TODO sometimes serialization fails on bootup. Determine why.
@ -845,7 +845,7 @@ void AP_DDS_Client::write_tx_local_velocity_topic()
if (connected) {
ucdrBuffer ub {};
const uint32_t topic_size = geometry_msgs_msg_TwistStamped_size_of_topic(&tx_local_velocity_topic, 0);
uxr_prepare_output_stream(&session,reliable_out,topics[5].dw_id,&ub,topic_size);
uxr_prepare_output_stream(&session, reliable_out, topics[to_underlying(TopicIndex::LOCAL_VELOCITY_PUB)].dw_id, &ub, topic_size);
const bool success = geometry_msgs_msg_TwistStamped_serialize_topic(&ub, &tx_local_velocity_topic);
if (!success) {
// TODO sometimes serialization fails on bootup. Determine why.
@ -860,7 +860,7 @@ void AP_DDS_Client::write_geo_pose_topic()
if (connected) {
ucdrBuffer ub {};
const uint32_t topic_size = geographic_msgs_msg_GeoPoseStamped_size_of_topic(&geo_pose_topic, 0);
uxr_prepare_output_stream(&session,reliable_out,topics[6].dw_id,&ub,topic_size);
uxr_prepare_output_stream(&session, reliable_out, topics[to_underlying(TopicIndex::GEOPOSE_PUB)].dw_id, &ub, topic_size);
const bool success = geographic_msgs_msg_GeoPoseStamped_serialize_topic(&ub, &geo_pose_topic);
if (!success) {
// TODO sometimes serialization fails on bootup. Determine why.
@ -875,7 +875,7 @@ void AP_DDS_Client::write_clock_topic()
if (connected) {
ucdrBuffer ub {};
const uint32_t topic_size = rosgraph_msgs_msg_Clock_size_of_topic(&clock_topic, 0);
uxr_prepare_output_stream(&session,reliable_out,topics[7].dw_id,&ub,topic_size);
uxr_prepare_output_stream(&session, reliable_out, topics[to_underlying(TopicIndex::CLOCK_PUB)].dw_id, &ub, topic_size);
const bool success = rosgraph_msgs_msg_Clock_serialize_topic(&ub, &clock_topic);
if (!success) {
// TODO sometimes serialization fails on bootup. Determine why.