RoboStack / ros-galactic

Vinca build files for ROS 2 Galactic Geochelone
https://robostack.github.io
21 stars 14 forks source link

ROS default msgs missing functions #109

Closed b1n-ch1kn closed 1 year ago

b1n-ch1kn commented 1 year ago

After installing a new Robostack env for Galactic, building custom msgs that rely on ROS default msgs (like std_msgs and geometry_msgs) are unable to build correctly.

Errors

(ros_galactic) wsl@Al-Desktop:~/QUTMS_Driverless$ colcon build --packages-select driverless_msgs
Starting >>> driverless_msgs
--- stderr: driverless_msgs
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/cone__functions.c: In function 'driverless_msgs__msg__Cone__are_equal':
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/cone__functions.c:49:8: warning: implicit declaration of function 'geometry_msgs__msg__Point__are_equal'; did you mean 'geometry_msgs__msg__Point__create'? [-Wimplicit-function-declaration]
   49 |   if (!geometry_msgs__msg__Point__are_equal(
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |        geometry_msgs__msg__Point__create
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/cone__functions.c: In function 'driverless_msgs__msg__Cone__copy':
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/cone__functions.c:70:8: warning: implicit declaration of function 'geometry_msgs__msg__Point__copy'; did you mean 'geometry_msgs__msg__Point__fini'? [-Wimplicit-function-declaration]
   70 |   if (!geometry_msgs__msg__Point__copy(
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |        geometry_msgs__msg__Point__fini
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/cone_detection_stamped__functions.c: In function 'driverless_msgs__msg__ConeDetectionStamped__are_equal':
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/cone_detection_stamped__functions.c:65:8: warning: implicit declaration of function 'std_msgs__msg__Header__are_equal'; did you mean 'std_msgs__msg__Header__create'? [-Wimplicit-function-declaration]
   65 |   if (!std_msgs__msg__Header__are_equal(
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |        std_msgs__msg__Header__create
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/cone_detection_stamped__functions.c: In function 'driverless_msgs__msg__ConeDetectionStamped__copy':
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/cone_detection_stamped__functions.c:94:8: warning: implicit declaration of function 'std_msgs__msg__Header__copy'; did you mean 'std_msgs__msg__Header__fini'? [-Wimplicit-function-declaration]
   94 |   if (!std_msgs__msg__Header__copy(
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |        std_msgs__msg__Header__fini
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/path_stamped__functions.c: In function 'driverless_msgs__msg__PathStamped__are_equal':
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/path_stamped__functions.c:56:8: warning: implicit declaration of function 'std_msgs__msg__Header__are_equal'; did you mean 'std_msgs__msg__Header__create'? [-Wimplicit-function-declaration]
   56 |   if (!std_msgs__msg__Header__are_equal(
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |        std_msgs__msg__Header__create
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/path_stamped__functions.c: In function 'driverless_msgs__msg__PathStamped__copy':
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/path_stamped__functions.c:79:8: warning: implicit declaration of function 'std_msgs__msg__Header__copy'; did you mean 'std_msgs__msg__Header__fini'? [-Wimplicit-function-declaration]
   79 |   if (!std_msgs__msg__Header__copy(
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |        std_msgs__msg__Header__fini
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/path_point__functions.c: In function 'driverless_msgs__msg__PathPoint__are_equal':
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/path_point__functions.c:49:8: warning: implicit declaration of function 'geometry_msgs__msg__Point__are_equal'; did you mean 'geometry_msgs__msg__Point__create'? [-Wimplicit-function-declaration]
   49 |   if (!geometry_msgs__msg__Point__are_equal(
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |        geometry_msgs__msg__Point__create
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/path_point__functions.c: In function 'driverless_msgs__msg__PathPoint__copy':
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/path_point__functions.c:70:8: warning: implicit declaration of function 'geometry_msgs__msg__Point__copy'; did you mean 'geometry_msgs__msg__Point__fini'? [-Wimplicit-function-declaration]
   70 |   if (!geometry_msgs__msg__Point__copy(
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |        geometry_msgs__msg__Point__fini
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/track_detection_stamped__functions.c: In function 'driverless_msgs__msg__TrackDetectionStamped__are_equal':
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/track_detection_stamped__functions.c:56:8: warning: implicit declaration of function 'std_msgs__msg__Header__are_equal'; did you mean 'std_msgs__msg__Header__create'? [-Wimplicit-function-declaration]
   56 |   if (!std_msgs__msg__Header__are_equal(
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |        std_msgs__msg__Header__create
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/track_detection_stamped__functions.c: In function 'driverless_msgs__msg__TrackDetectionStamped__copy':
/home/wsl/QUTMS_Driverless/build/driverless_msgs/rosidl_generator_c/driverless_msgs/msg/detail/track_detection_stamped__functions.c:79:8: warning: implicit declaration of function 'std_msgs__msg__Header__copy'; did you mean 'std_msgs__msg__Header__fini'? [-Wimplicit-function-declaration]
   79 |   if (!std_msgs__msg__Header__copy(
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |        std_msgs__msg__Header__fini
---
Finished <<< driverless_msgs [9.23s]

Summary: 1 package finished [9.45s]
  1 package had stderr output: driverless_msgs

It finishes building but then packages that require driverless_msgs will not run, with error rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'driverless_msgs'

Source file

I looked into the source files for the default msgs and the methods that are referenced in the build errors, like std_msgs__msg__Header__copy, are missing from the included files.

include/std_msgs/std_msgs/msg/detail/header__functions.h

// generated from rosidl_generator_c/resource/idl__functions.h.em
// with input from std_msgs:msg/Header.idl
// generated code does not contain a copyright notice

#ifndef STD_MSGS__MSG__DETAIL__HEADER__FUNCTIONS_H_
#define STD_MSGS__MSG__DETAIL__HEADER__FUNCTIONS_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include <stdbool.h>
#include <stdlib.h>

#include "rosidl_runtime_c/visibility_control.h"
#include "std_msgs/msg/rosidl_generator_c__visibility_control.h"

#include "std_msgs/msg/detail/header__struct.h"

/// Initialize msg/Header message.
/**
 * If the init function is called twice for the same message without
 * calling fini inbetween previously allocated memory will be leaked.
 * \param[in,out] msg The previously allocated message pointer.
 * Fields without a default value will not be initialized by this function.
 * You might want to call memset(msg, 0, sizeof(
 * std_msgs__msg__Header
 * )) before or use
 * std_msgs__msg__Header__create()
 * to allocate and initialize the message.
 * \return true if initialization was successful, otherwise false
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
bool
std_msgs__msg__Header__init(std_msgs__msg__Header * msg);

/// Finalize msg/Header message.
/**
 * \param[in,out] msg The allocated message pointer.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
void
std_msgs__msg__Header__fini(std_msgs__msg__Header * msg);

/// Create msg/Header message.
/**
 * It allocates the memory for the message, sets the memory to zero, and
 * calls
 * std_msgs__msg__Header__init().
 * \return The pointer to the initialized message if successful,
 * otherwise NULL
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
std_msgs__msg__Header *
std_msgs__msg__Header__create();

/// Destroy msg/Header message.
/**
 * It calls
 * std_msgs__msg__Header__fini()
 * and frees the memory of the message.
 * \param[in,out] msg The allocated message pointer.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
void
std_msgs__msg__Header__destroy(std_msgs__msg__Header * msg);

/// Initialize array of msg/Header messages.
/**
 * It allocates the memory for the number of elements and calls
 * std_msgs__msg__Header__init()
 * for each element of the array.
 * \param[in,out] array The allocated array pointer.
 * \param[in] size The size / capacity of the array.
 * \return true if initialization was successful, otherwise false
 * If the array pointer is valid and the size is zero it is guaranteed
 # to return true.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
bool
std_msgs__msg__Header__Sequence__init(std_msgs__msg__Header__Sequence * array, size_t size);

/// Finalize array of msg/Header messages.
/**
 * It calls
 * std_msgs__msg__Header__fini()
 * for each element of the array and frees the memory for the number of
 * elements.
 * \param[in,out] array The initialized array pointer.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
void
std_msgs__msg__Header__Sequence__fini(std_msgs__msg__Header__Sequence * array);

/// Create array of msg/Header messages.
/**
 * It allocates the memory for the array and calls
 * std_msgs__msg__Header__Sequence__init().
 * \param[in] size The size / capacity of the array.
 * \return The pointer to the initialized array if successful, otherwise NULL
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
std_msgs__msg__Header__Sequence *
std_msgs__msg__Header__Sequence__create(size_t size);

/// Destroy array of msg/Header messages.
/**
 * It calls
 * std_msgs__msg__Header__Sequence__fini()
 * on the array,
 * and frees the memory of the array.
 * \param[in,out] array The initialized array pointer.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
void
std_msgs__msg__Header__Sequence__destroy(std_msgs__msg__Header__Sequence * array);

#ifdef __cplusplus
}
#endif

#endif  // STD_MSGS__MSG__DETAIL__HEADER__FUNCTIONS_H_

Old source code

On my second machine (a Galactic environment from about 6 months prior), I saw that it contained the missing functions in the default msgs.

// generated from rosidl_generator_c/resource/idl__functions.h.em
// with input from std_msgs:msg/Header.idl
// generated code does not contain a copyright notice

#ifndef STD_MSGS__MSG__DETAIL__HEADER__FUNCTIONS_H_
#define STD_MSGS__MSG__DETAIL__HEADER__FUNCTIONS_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include <stdbool.h>
#include <stdlib.h>

#include "rosidl_runtime_c/visibility_control.h"
#include "std_msgs/msg/rosidl_generator_c__visibility_control.h"

#include "std_msgs/msg/detail/header__struct.h"

/// Initialize msg/Header message.
/**
 * If the init function is called twice for the same message without
 * calling fini inbetween previously allocated memory will be leaked.
 * \param[in,out] msg The previously allocated message pointer.
 * Fields without a default value will not be initialized by this function.
 * You might want to call memset(msg, 0, sizeof(
 * std_msgs__msg__Header
 * )) before or use
 * std_msgs__msg__Header__create()
 * to allocate and initialize the message.
 * \return true if initialization was successful, otherwise false
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
bool
std_msgs__msg__Header__init(std_msgs__msg__Header * msg);

/// Finalize msg/Header message.
/**
 * \param[in,out] msg The allocated message pointer.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
void
std_msgs__msg__Header__fini(std_msgs__msg__Header * msg);

/// Create msg/Header message.
/**
 * It allocates the memory for the message, sets the memory to zero, and
 * calls
 * std_msgs__msg__Header__init().
 * \return The pointer to the initialized message if successful,
 * otherwise NULL
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
std_msgs__msg__Header *
std_msgs__msg__Header__create();

/// Destroy msg/Header message.
/**
 * It calls
 * std_msgs__msg__Header__fini()
 * and frees the memory of the message.
 * \param[in,out] msg The allocated message pointer.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
void
std_msgs__msg__Header__destroy(std_msgs__msg__Header * msg);

/// Check for msg/Header message equality.
/**
 * \param[in] lhs The message on the left hand size of the equality operator.
 * \param[in] rhs The message on the right hand size of the equality operator.
 * \return true if messages are equal, otherwise false.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
bool
std_msgs__msg__Header__are_equal(const std_msgs__msg__Header * lhs, const std_msgs__msg__Header * rhs);

/// Copy a msg/Header message.
/**
 * This functions performs a deep copy, as opposed to the shallow copy that
 * plain assignment yields.
 *
 * \param[in] input The source message pointer.
 * \param[out] output The target message pointer, which must
 *   have been initialized before calling this function.
 * \return true if successful, or false if either pointer is null
 *   or memory allocation fails.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
bool
std_msgs__msg__Header__copy(
  const std_msgs__msg__Header * input,
  std_msgs__msg__Header * output);

/// Initialize array of msg/Header messages.
/**
 * It allocates the memory for the number of elements and calls
 * std_msgs__msg__Header__init()
 * for each element of the array.
 * \param[in,out] array The allocated array pointer.
 * \param[in] size The size / capacity of the array.
 * \return true if initialization was successful, otherwise false
 * If the array pointer is valid and the size is zero it is guaranteed
 # to return true.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
bool
std_msgs__msg__Header__Sequence__init(std_msgs__msg__Header__Sequence * array, size_t size);

/// Finalize array of msg/Header messages.
/**
 * It calls
 * std_msgs__msg__Header__fini()
 * for each element of the array and frees the memory for the number of
 * elements.
 * \param[in,out] array The initialized array pointer.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
void
std_msgs__msg__Header__Sequence__fini(std_msgs__msg__Header__Sequence * array);

/// Create array of msg/Header messages.
/**
 * It allocates the memory for the array and calls
 * std_msgs__msg__Header__Sequence__init().
 * \param[in] size The size / capacity of the array.
 * \return The pointer to the initialized array if successful, otherwise NULL
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
std_msgs__msg__Header__Sequence *
std_msgs__msg__Header__Sequence__create(size_t size);

/// Destroy array of msg/Header messages.
/**
 * It calls
 * std_msgs__msg__Header__Sequence__fini()
 * on the array,
 * and frees the memory of the array.
 * \param[in,out] array The initialized array pointer.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
void
std_msgs__msg__Header__Sequence__destroy(std_msgs__msg__Header__Sequence * array);

/// Check for msg/Header message array equality.
/**
 * \param[in] lhs The message array on the left hand size of the equality operator.
 * \param[in] rhs The message array on the right hand size of the equality operator.
 * \return true if message arrays are equal in size and content, otherwise false.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
bool
std_msgs__msg__Header__Sequence__are_equal(const std_msgs__msg__Header__Sequence * lhs, const std_msgs__msg__Header__Sequence * rhs);

/// Copy an array of msg/Header messages.
/**
 * This functions performs a deep copy, as opposed to the shallow copy that
 * plain assignment yields.
 *
 * \param[in] input The source array pointer.
 * \param[out] output The target array pointer, which must
 *   have been initialized before calling this function.
 * \return true if successful, or false if either pointer
 *   is null or memory allocation fails.
 */
ROSIDL_GENERATOR_C_PUBLIC_std_msgs
bool
std_msgs__msg__Header__Sequence__copy(
  const std_msgs__msg__Header__Sequence * input,
  std_msgs__msg__Header__Sequence * output);

#ifdef __cplusplus
}
#endif

#endif  // STD_MSGS__MSG__DETAIL__HEADER__FUNCTIONS_H_

I looked through commit logs and couldn't work out what would have broken it between that timespan. This has occured on all platforms since I began test installing new Galactic environments about a month ago. It does not occur with new Humble environments however, so for any new environments we've installed Humble running on Ubuntu 20.04 in the interum (no compatibility issues so far). Let me know if you need more info :)

Tobias-Fischer commented 1 year ago

Can you try mamba install ros-galactic-rosidl-generator-c=2.2.1?

b1n-ch1kn commented 1 year ago

Amazing, that worked. Thanks!

Tobias-Fischer commented 1 year ago

Ok. Seems like we need to rebuild the Galactic packages in this case.

@wolfv what do you think about removing the functionality that automatically builds the latest versions of packages? I think it works to our disadvantage as seen in this issue.

Tobias-Fischer commented 1 year ago

I deleted the version 2.2.2 of this package, and we don't generate new versions anymore automatically, so this shouldn't be an issue anymore.