Compiler Explorer - C++
// GCC 13 has false positive warnings around stringop-overflow and array-bounds. // The layout of a BoundedVector triggers these warnings. Suppress them // until this is fixed in upstream gcc. See // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114758 for more details. #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" #pragma GCC diagnostic ignored "-Warray-bounds" #endif namespace rosidl_runtime_cpp { /// A container based on std::vector but with an upper bound. /** * Meets the same requirements as std::vector. * * \param Tp Type of element * \param UpperBound The upper bound for the number of elements * \param Alloc Allocator type, defaults to std::allocator */ template> class BoundedVector : protected std::vector { using Base = std::vector; public: using typename Base::value_type; using typename Base::pointer; using typename Base::const_pointer; using typename Base::reference; using typename Base::const_reference; using typename Base::iterator; using typename Base::const_iterator; using typename Base::const_reverse_iterator; using typename Base::reverse_iterator; using typename Base::size_type; using typename Base::difference_type; using typename Base::allocator_type; /// Create a %BoundedVector with no elements. BoundedVector() noexcept (std::is_nothrow_default_constructible::value) : Base() {} /// Creates a %BoundedVector with no elements. /** * \param a An allocator object */ explicit BoundedVector( const typename Base::allocator_type & a) noexcept : Base(a) {} /// Create a %BoundedVector with default constructed elements. /** * This constructor fills the %BoundedVector with @a n default * constructed elements. * * \param n The number of elements to initially create * \param a An allocator */ explicit BoundedVector( typename Base::size_type n, const typename Base::allocator_type & a = allocator_type()) : Base(n, a) { if (n > UpperBound) { throw std::length_error("Exceeded upper bound"); } } /// Create a %BoundedVector with copies of an exemplar element. /** * This constructor fills the %BoundedVector with @a n copies of @a value. * * \param n The number of elements to initially create * \param value An element to copy * \param a An allocator */ BoundedVector( typename Base::size_type n, const typename Base::value_type & value, const typename Base::allocator_type & a = allocator_type()) : Base(n, value, a) { if (n > UpperBound) { throw std::length_error("Exceeded upper bound"); } } /// %BoundedVector copy constructor. /** * The newly-created %BoundedVector uses a copy of the allocation * object used by @a x. * All the elements of @a x are copied, but any extra memory in * @a x (for fast expansion) will not be copied. * * \param x A %BoundedVector of identical element and allocator types */ BoundedVector( const BoundedVector & x) : Base(x) {} /// %BoundedVector move constructor. /** * The newly-created %BoundedVector contains the exact contents of @a x. * The contents of @a x are a valid, but unspecified %BoundedVector. * * \param x A %BoundedVector of identical element and allocator types */ BoundedVector(BoundedVector && x) noexcept : Base(std::move(x)) {} /// Copy constructor with alternative allocator BoundedVector(const BoundedVector & x, const typename Base::allocator_type & a) : Base(x, a) {} /// Build a %BoundedVector from an initializer list. /** * Create a %BoundedVector consisting of copies of the elements in the * initializer_list @a l. * * This will call the element type's copy constructor N times * (where N is @a l.size()) and do no memory reallocation. * * \param l An initializer_list * \param a An allocator */ BoundedVector( std::initializer_list l, const typename Base::allocator_type & a = typename Base::allocator_type()) : Base(l, a) { if (l.size() > UpperBound) { throw std::length_error("Exceeded upper bound"); } } /// Build a %BoundedVector from a range. /** * Create a %BoundedVector consisting of copies of the elements from * [first,last). * * If the iterators are forward, bidirectional, or random-access, then * this will call the elements' copy constructor N times (where N is * distance(first,last)) and do no memory reallocation. * But if only input iterators are used, then this will do at most 2N * calls to the copy constructor, and logN memory reallocations. * * \param first An input iterator * \param last An input iterator * \param a An allocator */ template< typename InputIterator > BoundedVector( InputIterator first, InputIterator last, const typename Base::allocator_type & a = allocator_type()) : Base(first, last, a) { if (size() > UpperBound) { throw std::length_error("Exceeded upper bound"); } } /// The dtor only erases the elements. /** * Note that if the elements themselves are pointers, the pointed-to * memory is not touched in any way. * Managing the pointer is the user's responsibility. */ ~BoundedVector() noexcept {} /// %BoundedVector assignment operator. /** * All the elements of @a x are copied, but any extra memory in * @a x (for fast expansion) will not be copied. * Unlike the copy constructor, the allocator object is not copied. * * \param x A %BoundedVector of identical element and allocator types */ BoundedVector & operator=(const BoundedVector & x) { (void)Base::operator=(x); return *this; } /// %BoundedVector move assignment operator /** * \param x A %BoundedVector of identical element and allocator types. */ BoundedVector & operator=(BoundedVector && x) { (void)Base::operator=(std::move(x)); return *this; } /// %BoundedVector list assignment operator. /** * This function fills a %BoundedVector with copies of the elements in * the initializer list @a l. * * Note that the assignment completely changes the %BoundedVector and * that the resulting %BoundedVector's size is the same as the number * of elements assigned. * Old data may be lost. * * \param l An initializer_list */ BoundedVector & operator=(std::initializer_list l) { if (l.size() > UpperBound) { throw std::length_error("Exceeded upper bound"); } Base::operator=(l); return *this; } /// Assign a given value to a %BoundedVector. /** * This function fills a %BoundedVector with @a n copies of the * given value. * Note that the assignment completely changes the %BoundedVector and * that the resulting %BoundedVector's size is the same as the number * of elements assigned. * Old data may be lost. * * \param n Number of elements to be assigned * \param val Value to be assigned */ void assign( typename Base::size_type n, const typename Base::value_type & val) { if (n > UpperBound) { throw std::length_error("Exceeded upper bound"); } Base::assign(n, val); } /// Assign a range to a %BoundedVector. /** * This function fills a %BoundedVector with copies of the elements in * the range [first,last). * * Note that the assignment completely changes the %BoundedVector and * that the resulting %BoundedVector's size is the same as the number * of elements assigned. * Old data may be lost. * * \param first An input iterator * \param last An input iterator */ template< typename InputIterator > void assign(InputIterator first, InputIterator last) { using cat = typename std::iterator_traits::iterator_category; do_assign(first, last, cat()); } /// Assign an initializer list to a %BoundedVector. /** * This function fills a %BoundedVector with copies of the elements in * the initializer list @a l. * * Note that the assignment completely changes the %BoundedVector and * that the resulting %BoundedVector's size is the same as the number * of elements assigned. * Old data may be lost. * * \param l An initializer_list */ void assign(std::initializer_list l) { if (l.size() > UpperBound) { throw std::length_error("Exceeded upper bound"); } Base::assign(l); } using Base::begin; using Base::end; using Base::rbegin; using Base::rend; using Base::cbegin; using Base::cend; using Base::crbegin; using Base::crend; using Base::size; /** Returns the size() of the largest possible %BoundedVector. */ typename Base::size_type max_size() const noexcept { return std::min(UpperBound, Base::max_size()); } /// Resize the %BoundedVector to the specified number of elements. /** * This function will %resize the %BoundedVector to the specified * number of elements. * If the number is smaller than the %BoundedVector's current size the * %BoundedVector is truncated, otherwise default constructed elements * are appended. * * \param new_size Number of elements the %BoundedVector should contain */ void resize(typename Base::size_type new_size) { if (new_size > UpperBound) { throw std::length_error("Exceeded upper bound"); } Base::resize(new_size); } /// Resize the %BoundedVector to the specified number of elements. /** * This function will %resize the %BoundedVector to the specified * number of elements. * If the number is smaller than the %BoundedVector's current size the * %BoundedVector is truncated, otherwise the %BoundedVector is * extended and new elements are populated with given data. * * \param new_size Number of elements the %BoundedVector should contain * \param x Data with which new elements should be populated */ void resize( typename Base::size_type new_size, const typename Base::value_type & x) { if (new_size > UpperBound) { throw std::length_error("Exceeded upper bound"); } Base::resize(new_size, x); } using Base::shrink_to_fit; using Base::capacity; using Base::empty; /// Attempt to preallocate enough memory for specified number of elements. /** * This function attempts to reserve enough memory for the * %BoundedVector to hold the specified number of elements. * If the number requested is more than max_size(), length_error is * thrown. * * The advantage of this function is that if optimal code is a * necessity and the user can determine the number of elements that * will be required, the user can reserve the memory in %advance, and * thus prevent a possible reallocation of memory and copying of * %BoundedVector data. * * \param n Number of elements required * @throw std::length_error If @a n exceeds @c max_size() */ void reserve(typename Base::size_type n) { if (n > UpperBound) { throw std::length_error("Exceeded upper bound"); } Base::reserve(n); } using Base::operator[]; using Base::at; using Base::front; using Base::back; /// Return a pointer such that [data(), data() + size()) is a valid range. /** * For a non-empty %BoundedVector, data() == &front;(). */ template< typename T, typename std::enable_if< !std::is_same::value && !std::is_same::value >::type * = nullptr > T * data() noexcept { return Base::data(); } template< typename T, typename std::enable_if< !std::is_same::value && !std::is_same::value >::type * = nullptr > const T * data() const noexcept { return Base::data(); } /// Add data to the end of the %BoundedVector. /** * This is a typical stack operation. * The function creates an element at the end of the %BoundedVector * and assigns the given data to it. * Due to the nature of a %BoundedVector this operation can be done in * constant time if the %BoundedVector has preallocated space * available. * * \param x Data to be added */ void push_back(const typename Base::value_type & x) { if (size() >= UpperBound) { throw std::length_error("Exceeded upper bound"); } Base::push_back(x); } void push_back(typename Base::value_type && x) { if (size() >= UpperBound) { throw std::length_error("Exceeded upper bound"); } Base::push_back(x); } /// Add data to the end of the %BoundedVector. /** * This is a typical stack operation. * The function creates an element at the end of the %BoundedVector * and assigns the given data to it. * Due to the nature of a %BoundedVector this operation can be done in * constant time if the %BoundedVector has preallocated space * available. * * \param args Arguments to be forwarded to the constructor of Tp */ template typename Base::reference emplace_back(Args && ... args) { if (size() >= UpperBound) { throw std::length_error("Exceeded upper bound"); } return Base::emplace_back(std::forward(args)...); } /// Insert an object in %BoundedVector before specified iterator. /** * This function will insert an object of type T constructed with * T(std::forward(args)...) before the specified location. * Note that this kind of operation could be expensive for a * %BoundedVector and if it is frequently used the user should * consider using std::list. * * \param position A const_iterator into the %BoundedVector * \param args Arguments * \return An iterator that points to the inserted data */ template typename Base::iterator emplace( typename Base::const_iterator position, Args && ... args) { if (size() >= UpperBound) { throw std::length_error("Exceeded upper bound"); } return Base::emplace(position, std::forward(args) ...); } /// Insert given value into %BoundedVector before specified iterator. /** * This function will insert a copy of the given value before the * specified location. * Note that this kind of operation could be expensive for a * %BoundedVector and if it is frequently used the user should * consider using std::list. * * \param position A const_iterator into the %BoundedVector * \param x Data to be inserted * \return An iterator that points to the inserted data */ typename Base::iterator insert( typename Base::const_iterator position, const typename Base::value_type & x) { if (size() >= UpperBound) { throw std::length_error("Exceeded upper bound"); } return Base::insert(position, x); } /// Insert given rvalue into %BoundedVector before specified iterator. /** * This function will insert a copy of the given rvalue before the * specified location. * Note that this kind of operation could be expensive for a * %BoundedVector and if it is frequently used the user should * consider using std::list. * * \param position A const_iterator into the %BoundedVector * \param x Data to be inserted * \return An iterator that points to the inserted data */ typename Base::iterator insert( typename Base::const_iterator position, typename Base::value_type && x) { if (size() >= UpperBound) { throw std::length_error("Exceeded upper bound"); } return Base::insert(position, x); } /// Insert an initializer_list into the %BoundedVector. /** * This function will insert copies of the data in the * initializer_list @a l into the %BoundedVector before the location * specified by @a position. * * Note that this kind of operation could be expensive for a * %BoundedVector and if it is frequently used the user should * consider using std::list. * * \param position An iterator into the %BoundedVector * \param l An initializer_list */ typename Base::iterator insert( typename Base::const_iterator position, std::initializer_list l) { if (size() + l.size() > UpperBound) { throw std::length_error("Exceeded upper bound"); } return Base::insert(position, l); } /// Insert a number of copies of given data into the %BoundedVector. /** * This function will insert a specified number of copies of the given * data before the location specified by @a position. * * Note that this kind of operation could be expensive for a * %BoundedVector and if it is frequently used the user should * consider using std::list. * * \param position A const_iterator into the %BoundedVector * \param n Number of elements to be inserted * \param x Data to be inserted * \return An iterator that points to the inserted data */ typename Base::iterator insert( typename Base::const_iterator position, typename Base::size_type n, const typename Base::value_type & x) { if (size() + n > UpperBound) { throw std::length_error("Exceeded upper bound"); } return Base::insert(position, n, x); } /// Insert a range into the %BoundedVector. /** * This function will insert copies of the data in the range * [first,last) into the %BoundedVector before the location * specified by @a pos. * * Note that this kind of operation could be expensive for a * %BoundedVector and if it is frequently used the user should * consider using std::list. * * \param position A const_iterator into the %BoundedVector * \param first An input iterator * \param last An input iterator * \return An iterator that points to the inserted data */ template< typename InputIterator > typename Base::iterator insert( typename Base::const_iterator position, InputIterator first, InputIterator last) { using cat = typename std::iterator_traits::iterator_category; return do_insert(position, first, last, cat()); } using Base::erase; using Base::pop_back; using Base::clear; private: /// Assign elements from an input range. template< typename InputIterator > void do_assign(InputIterator first, InputIterator last, std::input_iterator_tag) { BoundedVector(first, last).swap(*this); } /// Assign elements from a forward range. template< typename FwdIterator > void do_assign(FwdIterator first, FwdIterator last, std::forward_iterator_tag) { if (static_cast(std::distance(first, last)) > UpperBound) { throw std::length_error("Exceeded upper bound"); } Base::assign(first, last); } // Insert each value at the end and then rotate them to the desired position. // If the bound is exceeded, the inserted elements are removed again. template< typename InputIterator > typename Base::iterator do_insert( typename Base::const_iterator position, InputIterator first, InputIterator last, std::input_iterator_tag) { const auto orig_size = size(); const auto idx = position - cbegin(); try { while (first != last) { push_back(*first++); } } catch (const std::length_error &) { Base::resize(orig_size); throw; } auto pos = begin() + idx; std::rotate(pos, begin() + orig_size, end()); return begin() + idx; } template< typename FwdIterator > typename Base::iterator do_insert( typename Base::const_iterator position, FwdIterator first, FwdIterator last, std::forward_iterator_tag) { auto dist = std::distance(first, last); if ((dist < 0) || (size() + static_cast(dist) > UpperBound)) { throw std::length_error("Exceeded upper bound"); } return Base::insert(position, first, last); } /// Vector equality comparison. /** * This is an equivalence relation. * It is linear in the size of the vectors. * Vectors are considered equivalent if their sizes are equal, and if * corresponding elements compare equal. * * \param x A %BoundedVector * \param y A %BoundedVector of the same type as @a x * \return True if the size and elements of the vectors are equal */ friend bool operator==( const BoundedVector & x, const BoundedVector & y) { return static_cast(x) == static_cast(y); } /// Vector ordering relation. /** * This is a total ordering relation. * It is linear in the size of the vectors. * The elements must be comparable with @c <. * * See std::lexicographical_compare() for how the determination is made. * * \param x A %BoundedVector * \param y A %BoundedVector of the same type as @a x * @return True if @a x is lexicographically less than @a y */ friend bool operator<( const BoundedVector & x, const BoundedVector & y) { return static_cast(x) < static_cast(y); } /// Based on operator== friend bool operator!=( const BoundedVector & x, const BoundedVector & y) { return static_cast(x) != static_cast(y); } /// Based on operator< friend bool operator>( const BoundedVector & x, const BoundedVector & y) { return static_cast(x) > static_cast(y); } /// Based on operator< friend bool operator<=( const BoundedVector & x, const BoundedVector & y) { return static_cast(x) <= static_cast(y); } /// Based on operator< friend bool operator>=( const BoundedVector & x, const BoundedVector & y) { return static_cast(x) >= static_cast(y); } }; /// See rosidl_runtime_cpp::BoundedVector::swap(). template inline void swap(BoundedVector & x, BoundedVector & y) { x.swap(y); } } // namespace rosidl_runtime_cpp #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop #endif enum rosidl_runtime_c__message_initialization { // Initialize all fields of the message, either with the default value // (if the field has one), or with an empty value (generally 0 or an // empty string). ROSIDL_RUNTIME_C_MSG_INIT_ALL, // Skip initialization of all fields of the message. It is up to the user to // ensure that all fields are initialized before use. ROSIDL_RUNTIME_C_MSG_INIT_SKIP, // Initialize all fields of the message to an empty value (generally 0 or an // empty string). ROSIDL_RUNTIME_C_MSG_INIT_ZERO, // Initialize all fields of the message that have defaults; all other fields // are left untouched. ROSIDL_RUNTIME_C_MSG_INIT_DEFAULTS_ONLY, }; namespace rosidl_runtime_cpp { /// Enum utilized in rosidl generated sources for describing how members are initialized. /** * See the documentation for the `rosidl_runtime_c__message_initialization` enum for more information. */ enum class MessageInitialization { ALL = ROSIDL_RUNTIME_C_MSG_INIT_ALL, SKIP = ROSIDL_RUNTIME_C_MSG_INIT_SKIP, ZERO = ROSIDL_RUNTIME_C_MSG_INIT_ZERO, DEFAULTS_ONLY = ROSIDL_RUNTIME_C_MSG_INIT_DEFAULTS_ONLY, }; } // namespace rosidl_runtime_cpp // Include directives for member types // Member 'header' // Include directives for member types // Member 'stamp' #ifndef _WIN32 # define DEPRECATED__builtin_interfaces__msg__Time __attribute__((deprecated)) #else # define DEPRECATED__builtin_interfaces__msg__Time __declspec(deprecated) #endif namespace builtin_interfaces { namespace msg { // message struct template struct Time_ { using Type = Time_; explicit Time_(rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL) { if (rosidl_runtime_cpp::MessageInitialization::ALL == _init || rosidl_runtime_cpp::MessageInitialization::ZERO == _init) { this->sec = 0l; this->nanosec = 0ul; } } explicit Time_(const ContainerAllocator & _alloc, rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL) { (void)_alloc; if (rosidl_runtime_cpp::MessageInitialization::ALL == _init || rosidl_runtime_cpp::MessageInitialization::ZERO == _init) { this->sec = 0l; this->nanosec = 0ul; } } // field types and members using _sec_type = int32_t; _sec_type sec; using _nanosec_type = uint32_t; _nanosec_type nanosec; // setters for named parameter idiom Type & set__sec( const int32_t & _arg) { this->sec = _arg; return *this; } Type & set__nanosec( const uint32_t & _arg) { this->nanosec = _arg; return *this; } // constant declarations // pointer types using RawPtr = builtin_interfaces::msg::Time_ *; using ConstRawPtr = const builtin_interfaces::msg::Time_ *; using SharedPtr = std::shared_ptr>; using ConstSharedPtr = std::shared_ptr const>; template>> using UniquePtrWithDeleter = std::unique_ptr, Deleter>; using UniquePtr = UniquePtrWithDeleter<>; template>> using ConstUniquePtrWithDeleter = std::unique_ptr const, Deleter>; using ConstUniquePtr = ConstUniquePtrWithDeleter<>; using WeakPtr = std::weak_ptr>; using ConstWeakPtr = std::weak_ptr const>; // pointer types similar to ROS 1, use SharedPtr / ConstSharedPtr instead // NOTE: Can't use 'using' here because GNU C++ can't parse attributes properly typedef DEPRECATED__builtin_interfaces__msg__Time std::shared_ptr> Ptr; typedef DEPRECATED__builtin_interfaces__msg__Time std::shared_ptr const> ConstPtr; // comparison operators bool operator==(const Time_ & other) const { if (this->sec != other.sec) { return false; } if (this->nanosec != other.nanosec) { return false; } return true; } bool operator!=(const Time_ & other) const { return !this->operator==(other); } }; // struct Time_ // alias to use template instance with default allocator using Time = builtin_interfaces::msg::Time_>; // constant definitions } // namespace msg } // namespace builtin_interfaces #ifndef _WIN32 # define DEPRECATED__std_msgs__msg__Header __attribute__((deprecated)) #else # define DEPRECATED__std_msgs__msg__Header __declspec(deprecated) #endif namespace std_msgs { namespace msg { // message struct template struct Header_ { using Type = Header_; explicit Header_(rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL) : stamp(_init) { if (rosidl_runtime_cpp::MessageInitialization::ALL == _init || rosidl_runtime_cpp::MessageInitialization::ZERO == _init) { this->frame_id = ""; } } explicit Header_(const ContainerAllocator & _alloc, rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL) : stamp(_alloc, _init), frame_id(_alloc) { if (rosidl_runtime_cpp::MessageInitialization::ALL == _init || rosidl_runtime_cpp::MessageInitialization::ZERO == _init) { this->frame_id = ""; } } // field types and members using _stamp_type = builtin_interfaces::msg::Time_; _stamp_type stamp; using _frame_id_type = std::basic_string, typename std::allocator_traits::template rebind_alloc>; _frame_id_type frame_id; // setters for named parameter idiom Type & set__stamp( const builtin_interfaces::msg::Time_ & _arg) { this->stamp = _arg; return *this; } Type & set__frame_id( const std::basic_string, typename std::allocator_traits::template rebind_alloc> & _arg) { this->frame_id = _arg; return *this; } // constant declarations // pointer types using RawPtr = std_msgs::msg::Header_ *; using ConstRawPtr = const std_msgs::msg::Header_ *; using SharedPtr = std::shared_ptr>; using ConstSharedPtr = std::shared_ptr const>; template>> using UniquePtrWithDeleter = std::unique_ptr, Deleter>; using UniquePtr = UniquePtrWithDeleter<>; template>> using ConstUniquePtrWithDeleter = std::unique_ptr const, Deleter>; using ConstUniquePtr = ConstUniquePtrWithDeleter<>; using WeakPtr = std::weak_ptr>; using ConstWeakPtr = std::weak_ptr const>; // pointer types similar to ROS 1, use SharedPtr / ConstSharedPtr instead // NOTE: Can't use 'using' here because GNU C++ can't parse attributes properly typedef DEPRECATED__std_msgs__msg__Header std::shared_ptr> Ptr; typedef DEPRECATED__std_msgs__msg__Header std::shared_ptr const> ConstPtr; // comparison operators bool operator==(const Header_ & other) const { if (this->stamp != other.stamp) { return false; } if (this->frame_id != other.frame_id) { return false; } return true; } bool operator!=(const Header_ & other) const { return !this->operator==(other); } }; // struct Header_ // alias to use template instance with default allocator using Header = std_msgs::msg::Header_>; // constant definitions } // namespace msg } // namespace std_msgs // Member 'pose' // Include directives for member types // Member 'position' #ifndef _WIN32 # define DEPRECATED__geometry_msgs__msg__Point __attribute__((deprecated)) #else # define DEPRECATED__geometry_msgs__msg__Point __declspec(deprecated) #endif namespace geometry_msgs { namespace msg { // message struct template struct Point_ { using Type = Point_; explicit Point_(rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL) { if (rosidl_runtime_cpp::MessageInitialization::ALL == _init || rosidl_runtime_cpp::MessageInitialization::ZERO == _init) { this->x = 0.0; this->y = 0.0; this->z = 0.0; } } explicit Point_(const ContainerAllocator & _alloc, rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL) { (void)_alloc; if (rosidl_runtime_cpp::MessageInitialization::ALL == _init || rosidl_runtime_cpp::MessageInitialization::ZERO == _init) { this->x = 0.0; this->y = 0.0; this->z = 0.0; } } // field types and members using _x_type = double; _x_type x; using _y_type = double; _y_type y; using _z_type = double; _z_type z; // setters for named parameter idiom Type & set__x( const double & _arg) { this->x = _arg; return *this; } Type & set__y( const double & _arg) { this->y = _arg; return *this; } Type & set__z( const double & _arg) { this->z = _arg; return *this; } // constant declarations // pointer types using RawPtr = geometry_msgs::msg::Point_ *; using ConstRawPtr = const geometry_msgs::msg::Point_ *; using SharedPtr = std::shared_ptr>; using ConstSharedPtr = std::shared_ptr const>; template>> using UniquePtrWithDeleter = std::unique_ptr, Deleter>; using UniquePtr = UniquePtrWithDeleter<>; template>> using ConstUniquePtrWithDeleter = std::unique_ptr const, Deleter>; using ConstUniquePtr = ConstUniquePtrWithDeleter<>; using WeakPtr = std::weak_ptr>; using ConstWeakPtr = std::weak_ptr const>; // pointer types similar to ROS 1, use SharedPtr / ConstSharedPtr instead // NOTE: Can't use 'using' here because GNU C++ can't parse attributes properly typedef DEPRECATED__geometry_msgs__msg__Point std::shared_ptr> Ptr; typedef DEPRECATED__geometry_msgs__msg__Point std::shared_ptr const> ConstPtr; // comparison operators bool operator==(const Point_ & other) const { if (this->x != other.x) { return false; } if (this->y != other.y) { return false; } if (this->z != other.z) { return false; } return true; } bool operator!=(const Point_ & other) const { return !this->operator==(other); } }; // struct Point_ // alias to use template instance with default allocator using Point = geometry_msgs::msg::Point_>; // constant definitions } // namespace msg } // namespace geometry_msgs // Member 'orientation' #ifndef _WIN32 # define DEPRECATED__geometry_msgs__msg__Quaternion __attribute__((deprecated)) #else # define DEPRECATED__geometry_msgs__msg__Quaternion __declspec(deprecated) #endif namespace geometry_msgs { namespace msg { // message struct template struct Quaternion_ { using Type = Quaternion_; explicit Quaternion_(rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL) { if (rosidl_runtime_cpp::MessageInitialization::ALL == _init || rosidl_runtime_cpp::MessageInitialization::DEFAULTS_ONLY == _init) { this->x = 0.0; this->y = 0.0; this->z = 0.0; this->w = 1.0; } else if (rosidl_runtime_cpp::MessageInitialization::ZERO == _init) { this->x = 0.0; this->y = 0.0; this->z = 0.0; this->w = 0.0; } } explicit Quaternion_(const ContainerAllocator & _alloc, rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL) { (void)_alloc; if (rosidl_runtime_cpp::MessageInitialization::ALL == _init || rosidl_runtime_cpp::MessageInitialization::DEFAULTS_ONLY == _init) { this->x = 0.0; this->y = 0.0; this->z = 0.0; this->w = 1.0; } else if (rosidl_runtime_cpp::MessageInitialization::ZERO == _init) { this->x = 0.0; this->y = 0.0; this->z = 0.0; this->w = 0.0; } } // field types and members using _x_type = double; _x_type x; using _y_type = double; _y_type y; using _z_type = double; _z_type z; using _w_type = double; _w_type w; // setters for named parameter idiom Type & set__x( const double & _arg) { this->x = _arg; return *this; } Type & set__y( const double & _arg) { this->y = _arg; return *this; } Type & set__z( const double & _arg) { this->z = _arg; return *this; } Type & set__w( const double & _arg) { this->w = _arg; return *this; } // constant declarations // pointer types using RawPtr = geometry_msgs::msg::Quaternion_ *; using ConstRawPtr = const geometry_msgs::msg::Quaternion_ *; using SharedPtr = std::shared_ptr>; using ConstSharedPtr = std::shared_ptr const>; template>> using UniquePtrWithDeleter = std::unique_ptr, Deleter>; using UniquePtr = UniquePtrWithDeleter<>; template>> using ConstUniquePtrWithDeleter = std::unique_ptr const, Deleter>; using ConstUniquePtr = ConstUniquePtrWithDeleter<>; using WeakPtr = std::weak_ptr>; using ConstWeakPtr = std::weak_ptr const>; // pointer types similar to ROS 1, use SharedPtr / ConstSharedPtr instead // NOTE: Can't use 'using' here because GNU C++ can't parse attributes properly typedef DEPRECATED__geometry_msgs__msg__Quaternion std::shared_ptr> Ptr; typedef DEPRECATED__geometry_msgs__msg__Quaternion std::shared_ptr const> ConstPtr; // comparison operators bool operator==(const Quaternion_ & other) const { if (this->x != other.x) { return false; } if (this->y != other.y) { return false; } if (this->z != other.z) { return false; } if (this->w != other.w) { return false; } return true; } bool operator!=(const Quaternion_ & other) const { return !this->operator==(other); } }; // struct Quaternion_ // alias to use template instance with default allocator using Quaternion = geometry_msgs::msg::Quaternion_>; // constant definitions } // namespace msg } // namespace geometry_msgs #ifndef _WIN32 # define DEPRECATED__geometry_msgs__msg__Pose __attribute__((deprecated)) #else # define DEPRECATED__geometry_msgs__msg__Pose __declspec(deprecated) #endif namespace geometry_msgs { namespace msg { // message struct template struct Pose_ { using Type = Pose_; explicit Pose_(rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL) : position(_init), orientation(_init) { (void)_init; } explicit Pose_(const ContainerAllocator & _alloc, rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL) : position(_alloc, _init), orientation(_alloc, _init) { (void)_init; } // field types and members using _position_type = geometry_msgs::msg::Point_; _position_type position; using _orientation_type = geometry_msgs::msg::Quaternion_; _orientation_type orientation; // setters for named parameter idiom Type & set__position( const geometry_msgs::msg::Point_ & _arg) { this->position = _arg; return *this; } Type & set__orientation( const geometry_msgs::msg::Quaternion_ & _arg) { this->orientation = _arg; return *this; } // constant declarations // pointer types using RawPtr = geometry_msgs::msg::Pose_ *; using ConstRawPtr = const geometry_msgs::msg::Pose_ *; using SharedPtr = std::shared_ptr>; using ConstSharedPtr = std::shared_ptr const>; template>> using UniquePtrWithDeleter = std::unique_ptr, Deleter>; using UniquePtr = UniquePtrWithDeleter<>; template>> using ConstUniquePtrWithDeleter = std::unique_ptr const, Deleter>; using ConstUniquePtr = ConstUniquePtrWithDeleter<>; using WeakPtr = std::weak_ptr>; using ConstWeakPtr = std::weak_ptr const>; // pointer types similar to ROS 1, use SharedPtr / ConstSharedPtr instead // NOTE: Can't use 'using' here because GNU C++ can't parse attributes properly typedef DEPRECATED__geometry_msgs__msg__Pose std::shared_ptr> Ptr; typedef DEPRECATED__geometry_msgs__msg__Pose std::shared_ptr const> ConstPtr; // comparison operators bool operator==(const Pose_ & other) const { if (this->position != other.position) { return false; } if (this->orientation != other.orientation) { return false; } return true; } bool operator!=(const Pose_ & other) const { return !this->operator==(other); } }; // struct Pose_ // alias to use template instance with default allocator using Pose = geometry_msgs::msg::Pose_>; // constant definitions } // namespace msg } // namespace geometry_msgs #ifndef _WIN32 # define DEPRECATED__geometry_msgs__msg__PoseStamped __attribute__((deprecated)) #else # define DEPRECATED__geometry_msgs__msg__PoseStamped __declspec(deprecated) #endif namespace geometry_msgs { namespace msg { // message struct template struct PoseStamped_ { using Type = PoseStamped_; explicit PoseStamped_(rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL) : header(_init), pose(_init) { (void)_init; } explicit PoseStamped_(const ContainerAllocator & _alloc, rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL) : header(_alloc, _init), pose(_alloc, _init) { (void)_init; } // field types and members using _header_type = std_msgs::msg::Header_; _header_type header; using _pose_type = geometry_msgs::msg::Pose_; _pose_type pose; // setters for named parameter idiom Type & set__header( const std_msgs::msg::Header_ & _arg) { this->header = _arg; return *this; } Type & set__pose( const geometry_msgs::msg::Pose_ & _arg) { this->pose = _arg; return *this; } // constant declarations // pointer types using RawPtr = geometry_msgs::msg::PoseStamped_ *; using ConstRawPtr = const geometry_msgs::msg::PoseStamped_ *; using SharedPtr = std::shared_ptr>; using ConstSharedPtr = std::shared_ptr const>; template>> using UniquePtrWithDeleter = std::unique_ptr, Deleter>; using UniquePtr = UniquePtrWithDeleter<>; template>> using ConstUniquePtrWithDeleter = std::unique_ptr const, Deleter>; using ConstUniquePtr = ConstUniquePtrWithDeleter<>; using WeakPtr = std::weak_ptr>; using ConstWeakPtr = std::weak_ptr const>; // pointer types similar to ROS 1, use SharedPtr / ConstSharedPtr instead // NOTE: Can't use 'using' here because GNU C++ can't parse attributes properly typedef DEPRECATED__geometry_msgs__msg__PoseStamped std::shared_ptr> Ptr; typedef DEPRECATED__geometry_msgs__msg__PoseStamped std::shared_ptr const> ConstPtr; // comparison operators bool operator==(const PoseStamped_ & other) const { if (this->header != other.header) { return false; } if (this->pose != other.pose) { return false; } return true; } bool operator!=(const PoseStamped_ & other) const { return !this->operator==(other); } }; // struct PoseStamped_ // alias to use template instance with default allocator using PoseStamped = geometry_msgs::msg::PoseStamped_>; // constant definitions } // namespace msg } // namespace geometry_msgs namespace geometry_msgs { namespace msg { namespace builder { class Init_PoseStamped_pose { public: explicit Init_PoseStamped_pose(::geometry_msgs::msg::PoseStamped & msg) : msg_(msg) {} [[clang::always_inline]] ::geometry_msgs::msg::PoseStamped pose(::geometry_msgs::msg::PoseStamped::_pose_type arg) { msg_.pose = std::move(arg); return std::move(msg_); } private: ::geometry_msgs::msg::PoseStamped msg_; }; class Init_PoseStamped_header { public: Init_PoseStamped_header() : msg_(::rosidl_runtime_cpp::MessageInitialization::SKIP) {} [[clang::always_inline]] Init_PoseStamped_pose header(::geometry_msgs::msg::PoseStamped::_header_type arg) { msg_.header = std::move(arg); return Init_PoseStamped_pose(msg_); } private: ::geometry_msgs::msg::PoseStamped msg_; }; } // namespace builder } // namespace msg template auto build(); template<> [[clang::always_inline]] inline auto build<::geometry_msgs::msg::PoseStamped>() { return geometry_msgs::msg::builder::Init_PoseStamped_header(); } } // namespace geometry_msgs namespace builtin_interfaces { namespace msg { namespace builder { class Init_Time_nanosec { public: explicit Init_Time_nanosec(::builtin_interfaces::msg::Time & msg) : msg_(msg) {} [[clang::always_inline]] ::builtin_interfaces::msg::Time nanosec(::builtin_interfaces::msg::Time::_nanosec_type arg) { msg_.nanosec = std::move(arg); return std::move(msg_); } private: ::builtin_interfaces::msg::Time msg_; }; class Init_Time_sec { public: Init_Time_sec() : msg_(::rosidl_runtime_cpp::MessageInitialization::SKIP) {} [[clang::always_inline]] Init_Time_nanosec sec(::builtin_interfaces::msg::Time::_sec_type arg) { msg_.sec = std::move(arg); return Init_Time_nanosec(msg_); } private: ::builtin_interfaces::msg::Time msg_; }; } // namespace builder } // namespace msg template auto build(); template<> [[clang::always_inline]] inline auto build<::builtin_interfaces::msg::Time>() { return builtin_interfaces::msg::builder::Init_Time_sec(); } } // namespace builtin_interfaces namespace std_msgs { namespace msg { namespace builder { class Init_Header_frame_id { public: explicit Init_Header_frame_id(::std_msgs::msg::Header & msg) : msg_(msg) {} [[clang::always_inline]] ::std_msgs::msg::Header frame_id(::std_msgs::msg::Header::_frame_id_type arg) { msg_.frame_id = std::move(arg); return std::move(msg_); } private: ::std_msgs::msg::Header msg_; }; class Init_Header_stamp { public: Init_Header_stamp() : msg_(::rosidl_runtime_cpp::MessageInitialization::SKIP) {} [[clang::always_inline]] Init_Header_frame_id stamp(::std_msgs::msg::Header::_stamp_type arg) { msg_.stamp = std::move(arg); return Init_Header_frame_id(msg_); } private: ::std_msgs::msg::Header msg_; }; } // namespace builder } // namespace msg template auto build(); template<> [[clang::always_inline]] inline auto build<::std_msgs::msg::Header>() { return std_msgs::msg::builder::Init_Header_stamp(); } } // namespace std_msgs namespace geometry_msgs { namespace msg { namespace builder { class Init_Point_z { public: explicit Init_Point_z(::geometry_msgs::msg::Point & msg) : msg_(msg) {} [[clang::always_inline]] ::geometry_msgs::msg::Point z(::geometry_msgs::msg::Point::_z_type arg) { msg_.z = std::move(arg); return std::move(msg_); } private: ::geometry_msgs::msg::Point msg_; }; class Init_Point_y { public: explicit Init_Point_y(::geometry_msgs::msg::Point & msg) : msg_(msg) {} [[clang::always_inline]] Init_Point_z y(::geometry_msgs::msg::Point::_y_type arg) { msg_.y = std::move(arg); return Init_Point_z(msg_); } private: ::geometry_msgs::msg::Point msg_; }; class Init_Point_x { public: Init_Point_x() : msg_(::rosidl_runtime_cpp::MessageInitialization::SKIP) {} [[clang::always_inline]] Init_Point_y x(::geometry_msgs::msg::Point::_x_type arg) { msg_.x = std::move(arg); return Init_Point_y(msg_); } private: ::geometry_msgs::msg::Point msg_; }; } // namespace builder } // namespace msg template auto build(); template<> [[clang::always_inline]] inline auto build<::geometry_msgs::msg::Point>() { return geometry_msgs::msg::builder::Init_Point_x(); } } // namespace geometry_msgs namespace geometry_msgs { namespace msg { namespace builder { class Init_Quaternion_w { public: explicit Init_Quaternion_w(::geometry_msgs::msg::Quaternion & msg) : msg_(msg) {} ::geometry_msgs::msg::Quaternion w(::geometry_msgs::msg::Quaternion::_w_type arg) { msg_.w = std::move(arg); return std::move(msg_); } private: ::geometry_msgs::msg::Quaternion msg_; }; class Init_Quaternion_z { public: explicit Init_Quaternion_z(::geometry_msgs::msg::Quaternion & msg) : msg_(msg) {} Init_Quaternion_w z(::geometry_msgs::msg::Quaternion::_z_type arg) { msg_.z = std::move(arg); return Init_Quaternion_w(msg_); } private: ::geometry_msgs::msg::Quaternion msg_; }; class Init_Quaternion_y { public: explicit Init_Quaternion_y(::geometry_msgs::msg::Quaternion & msg) : msg_(msg) {} Init_Quaternion_z y(::geometry_msgs::msg::Quaternion::_y_type arg) { msg_.y = std::move(arg); return Init_Quaternion_z(msg_); } private: ::geometry_msgs::msg::Quaternion msg_; }; class Init_Quaternion_x { public: Init_Quaternion_x() : msg_(::rosidl_runtime_cpp::MessageInitialization::SKIP) {} Init_Quaternion_y x(::geometry_msgs::msg::Quaternion::_x_type arg) { msg_.x = std::move(arg); return Init_Quaternion_y(msg_); } private: ::geometry_msgs::msg::Quaternion msg_; }; } // namespace builder } // namespace msg template auto build(); template<> inline auto build<::geometry_msgs::msg::Quaternion>() { return geometry_msgs::msg::builder::Init_Quaternion_x(); } } // namespace geometry_msgs namespace geometry_msgs { namespace msg { namespace builder { class Init_Pose_orientation { public: explicit Init_Pose_orientation(::geometry_msgs::msg::Pose & msg) : msg_(msg) {} [[clang::always_inline]] ::geometry_msgs::msg::Pose orientation(::geometry_msgs::msg::Pose::_orientation_type arg) { msg_.orientation = std::move(arg); return std::move(msg_); } private: ::geometry_msgs::msg::Pose msg_; }; class Init_Pose_position { public: Init_Pose_position() : msg_(::rosidl_runtime_cpp::MessageInitialization::SKIP) {} [[clang::always_inline]] Init_Pose_orientation position(::geometry_msgs::msg::Pose::_position_type arg) { msg_.position = std::move(arg); return Init_Pose_orientation(msg_); } private: ::geometry_msgs::msg::Pose msg_; }; } // namespace builder } // namespace msg template auto build(); template<> [[clang::always_inline]] inline auto build<::geometry_msgs::msg::Pose>() { return geometry_msgs::msg::builder::Init_Pose_position(); } } // namespace geometry_msgs // IGNORE EVERYTHING ABOVE HERE using geometry_msgs::msg::PoseStamped; using builtin_interfaces::msg::Time; using std_msgs::msg::Header; using geometry_msgs::msg::Point; using geometry_msgs::msg::Quaternion; using geometry_msgs::msg::Pose; PoseStamped test1() { const auto stamp = builtin_interfaces::build() .sec(1337) .nanosec(1234); const auto header = std_msgs::build() .stamp(stamp) .frame_id("test_frame"); const auto point = geometry_msgs::build().x(1).y(2).z(3); const auto quat = geometry_msgs::build().x(1).y(2).z(3).w(4); const auto pose = geometry_msgs::build() .position(point) .orientation(quat); const auto pose_stamped = geometry_msgs::build() .header(header) .pose(pose); return pose_stamped; } PoseStamped test2() { Time time; time.sec = 1337; time.nanosec = 1234; Header header; header.stamp = time; header.frame_id = "test_frame"; Point point; point.x = 1; point.y = 2; point.z = 3; Quaternion quat; quat.x = 1; quat.y = 2; quat.z = 3; quat.w = 4; Pose pose; pose.position = point; pose.orientation = quat; PoseStamped pose_stamped; pose_stamped.header = header; pose_stamped.pose = pose; return pose_stamped; } PoseStamped test3() { PoseStamped pose_stamped; pose_stamped.header.stamp.sec = 1337; pose_stamped.header.stamp.nanosec = 1234; pose_stamped.header.frame_id = "test_frame"; pose_stamped.pose.position.x = 1; pose_stamped.pose.position.y = 2; pose_stamped.pose.position.z = 3; pose_stamped.pose.orientation.x = 1; pose_stamped.pose.orientation.y = 2; pose_stamped.pose.orientation.z = 3; pose_stamped.pose.orientation.w = 4; return pose_stamped; }