You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at//// http://www.apache.org/licenses/LICENSE-2.0//// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License./*! * @file GlobalPosition.h * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool microxrceddsgen. */#ifndef_GlobalPosition_H_#define_GlobalPosition_H_#ifdef__cplusplusextern"C"
{
#endif#include<stdint.h>#include<stdbool.h>#include"geometry_msgs/msg/Twist.h"#include"std_msgs/msg/Header.h"#defineFRAME_GLOBAL_INT 5
#defineFRAME_GLOBAL_REL_ALT 6
#defineFRAME_GLOBAL_TERRAIN_ALT 11
#defineIGNORE_LATITUDE 1
#defineIGNORE_LONGITUDE 2
#defineIGNORE_ALTITUDE 4
#defineIGNORE_VX 8
#defineIGNORE_VY 16
#defineIGNORE_VZ 32
#defineIGNORE_AFX 64
#defineIGNORE_AFY 128
#defineIGNORE_AFZ 256
#defineFORCE 512
#defineIGNORE_YAW 1024
#defineIGNORE_YAW_RATE 2048
typedefstructardupilot_msgs_msg_GlobalPosition
{
std_msgs_msg_Headerheader;
uint8_tcoordinate_frame;
uint16_ttype_mask;
doublelatitude;
doublelongitude;
floataltitude;
geometry_msgs_msg_Twistvelocity;
geometry_msgs_msg_Twistacceleration_or_force;
floatyaw;
} ardupilot_msgs_msg_GlobalPosition;
structucdrBuffer;
boolardupilot_msgs_msg_GlobalPosition_serialize_topic(structucdrBuffer*writer, constardupilot_msgs_msg_GlobalPosition*topic);
boolardupilot_msgs_msg_GlobalPosition_deserialize_topic(structucdrBuffer*reader, ardupilot_msgs_msg_GlobalPosition*topic);
uint32_tardupilot_msgs_msg_GlobalPosition_size_of_topic(constardupilot_msgs_msg_GlobalPosition*topic, uint32_tsize);
#ifdef__cplusplus
}
#endif#endif// _GlobalPosition_H_
AND
GlobalPosition.c
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at//// http://www.apache.org/licenses/LICENSE-2.0//// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License./*! * @file GlobalPosition.h * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool microxrceddsgen. */#include"GlobalPosition.h"#include<ucdr/microcdr.h>#include<string.h>boolardupilot_msgs_msg_GlobalPosition_serialize_topic(ucdrBuffer*writer, constardupilot_msgs_msg_GlobalPosition*topic)
{
boolsuccess= true;
success &= std_msgs_msg_Header_serialize_topic(writer, &topic->header);
success &= ucdr_serialize_uint8_t(writer, topic->coordinate_frame);
success &= ucdr_serialize_uint16_t(writer, topic->type_mask);
success &= ucdr_serialize_double(writer, topic->latitude);
success &= ucdr_serialize_double(writer, topic->longitude);
success &= ucdr_serialize_float(writer, topic->altitude);
success &= geometry_msgs_msg_Twist_serialize_topic(writer, &topic->velocity);
success &= geometry_msgs_msg_Twist_serialize_topic(writer, &topic->acceleration_or_force);
success &= ucdr_serialize_float(writer, topic->yaw);
returnsuccess&& !writer->error;
}
boolardupilot_msgs_msg_GlobalPosition_deserialize_topic(ucdrBuffer*reader, ardupilot_msgs_msg_GlobalPosition*topic)
{
boolsuccess= true;
success &= std_msgs_msg_Header_deserialize_topic(reader, &topic->header);
success &= ucdr_deserialize_uint8_t(reader, &topic->coordinate_frame);
success &= ucdr_deserialize_uint16_t(reader, &topic->type_mask);
success &= ucdr_deserialize_double(reader, &topic->latitude);
success &= ucdr_deserialize_double(reader, &topic->longitude);
success &= ucdr_deserialize_float(reader, &topic->altitude);
success &= geometry_msgs_msg_Twist_deserialize_topic(reader, &topic->velocity);
success &= geometry_msgs_msg_Twist_deserialize_topic(reader, &topic->acceleration_or_force);
success &= ucdr_deserialize_float(reader, &topic->yaw);
returnsuccess&& !reader->error;
}
uint32_tardupilot_msgs_msg_GlobalPosition_size_of_topic(constardupilot_msgs_msg_GlobalPosition*topic, uint32_tsize)
{
uint32_tpreviousSize=size;
size+=std_msgs_msg_Header_size_of_topic(&topic->header, size);
size+=ucdr_alignment(size, 1) +1;
size+=ucdr_alignment(size, 2) +2;
size+=ucdr_alignment(size, 8) +8;
size+=ucdr_alignment(size, 8) +8;
size+=ucdr_alignment(size, 4) +4;
size+=geometry_msgs_msg_Twist_size_of_topic(&topic->velocity, size);
size+=geometry_msgs_msg_Twist_size_of_topic(&topic->acceleration_or_force, size);
size+=ucdr_alignment(size, 4) +4;
returnsize-previousSize;
}
The defines in header then conflict with an enum field in another library:
Are there any other alternatives to global defines for these constants that could be adopted?
In ArduPilot, we can use C++, so we can use static constexpr and wrap things in namespace declarations. Any ideas? On a large codebase, the usage of defines for constants that are normally scoped to the namespace of the message is not feasible.
The text was updated successfully, but these errors were encountered:
Hello,
I am looking to see if there an alternative to message constants that aren't global defines.
Sample Message from ROS REP-147:
This generates GlobalPosition.h
AND
GlobalPosition.c
The defines in header then conflict with an enum field in another library:
https://github.com/ArduPilot/ardupilot/blob/eaf20db6ea635eabfc1a8b85d5dca63399a174e6/libraries/AP_Servo_Telem/AP_Servo_Telem.h#L45
Are there any other alternatives to global defines for these constants that could be adopted?
In ArduPilot, we can use C++, so we can use
static constexpr
and wrap things innamespace
declarations. Any ideas? On a large codebase, the usage of defines for constants that are normally scoped to the namespace of the message is not feasible.The text was updated successfully, but these errors were encountered: