package builds with custom message definitions

This commit is contained in:
Sem van der Hoeven
2023-04-19 12:16:49 +00:00
parent 35e28ca6d4
commit 3405c36e47
205 changed files with 34137 additions and 25114 deletions

View File

@@ -0,0 +1 @@
from beacon_positioning.msg._tracker_position import TrackerPosition # noqa: F401

View File

@@ -0,0 +1,231 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from beacon_positioning:msg/TrackerPosition.idl
# generated code does not contain a copyright notice
# Import statements for member types
# Member 'anchor_distances'
import numpy # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_TrackerPosition(type):
"""Metaclass of message 'TrackerPosition'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('beacon_positioning')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'beacon_positioning.msg.TrackerPosition')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._CREATE_ROS_MESSAGE = module.create_ros_message_msg__msg__tracker_position
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__tracker_position
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__tracker_position
cls._TYPE_SUPPORT = module.type_support_msg__msg__tracker_position
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__tracker_position
@classmethod
def __prepare__(cls, name, bases, **kwargs):
# list constant names here so that they appear in the help text of
# the message class under "Data and other attributes defined here:"
# as well as populate each message instance
return {
}
class TrackerPosition(metaclass=Metaclass_TrackerPosition):
"""Message class 'TrackerPosition'."""
__slots__ = [
'_id',
'_x_pos',
'_y_pos',
'_z_pos',
'_anchor_distances',
]
_fields_and_field_types = {
'id': 'int32',
'x_pos': 'int64',
'y_pos': 'int64',
'z_pos': 'int64',
'anchor_distances': 'int64[4]',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('int32'), # noqa: E501
rosidl_parser.definition.BasicType('int64'), # noqa: E501
rosidl_parser.definition.BasicType('int64'), # noqa: E501
rosidl_parser.definition.BasicType('int64'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('int64'), 4), # noqa: E501
)
def __init__(self, **kwargs):
assert all('_' + key in self.__slots__ for key in kwargs.keys()), \
'Invalid arguments passed to constructor: %s' % \
', '.join(sorted(k for k in kwargs.keys() if '_' + k not in self.__slots__))
self.id = kwargs.get('id', int())
self.x_pos = kwargs.get('x_pos', int())
self.y_pos = kwargs.get('y_pos', int())
self.z_pos = kwargs.get('z_pos', int())
if 'anchor_distances' not in kwargs:
self.anchor_distances = numpy.zeros(4, dtype=numpy.int64)
else:
self.anchor_distances = numpy.array(kwargs.get('anchor_distances'), dtype=numpy.int64)
assert self.anchor_distances.shape == (4, )
def __repr__(self):
typename = self.__class__.__module__.split('.')
typename.pop()
typename.append(self.__class__.__name__)
args = []
for s, t in zip(self.__slots__, self.SLOT_TYPES):
field = getattr(self, s)
fieldstr = repr(field)
# We use Python array type for fields that can be directly stored
# in them, and "normal" sequences for everything else. If it is
# a type that we store in an array, strip off the 'array' portion.
if (
isinstance(t, rosidl_parser.definition.AbstractSequence) and
isinstance(t.value_type, rosidl_parser.definition.BasicType) and
t.value_type.typename in ['float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64']
):
if len(field) == 0:
fieldstr = '[]'
else:
assert fieldstr.startswith('array(')
prefix = "array('X', "
suffix = ')'
fieldstr = fieldstr[len(prefix):-len(suffix)]
args.append(s[1:] + '=' + fieldstr)
return '%s(%s)' % ('.'.join(typename), ', '.join(args))
def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
if self.id != other.id:
return False
if self.x_pos != other.x_pos:
return False
if self.y_pos != other.y_pos:
return False
if self.z_pos != other.z_pos:
return False
if all(self.anchor_distances != other.anchor_distances):
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property # noqa: A003
def id(self): # noqa: A003
"""Message field 'id'."""
return self._id
@id.setter # noqa: A003
def id(self, value): # noqa: A003
if __debug__:
assert \
isinstance(value, int), \
"The 'id' field must be of type 'int'"
assert value >= -2147483648 and value < 2147483648, \
"The 'id' field must be an integer in [-2147483648, 2147483647]"
self._id = value
@property
def x_pos(self):
"""Message field 'x_pos'."""
return self._x_pos
@x_pos.setter
def x_pos(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'x_pos' field must be of type 'int'"
assert value >= -9223372036854775808 and value < 9223372036854775808, \
"The 'x_pos' field must be an integer in [-9223372036854775808, 9223372036854775807]"
self._x_pos = value
@property
def y_pos(self):
"""Message field 'y_pos'."""
return self._y_pos
@y_pos.setter
def y_pos(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'y_pos' field must be of type 'int'"
assert value >= -9223372036854775808 and value < 9223372036854775808, \
"The 'y_pos' field must be an integer in [-9223372036854775808, 9223372036854775807]"
self._y_pos = value
@property
def z_pos(self):
"""Message field 'z_pos'."""
return self._z_pos
@z_pos.setter
def z_pos(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'z_pos' field must be of type 'int'"
assert value >= -9223372036854775808 and value < 9223372036854775808, \
"The 'z_pos' field must be an integer in [-9223372036854775808, 9223372036854775807]"
self._z_pos = value
@property
def anchor_distances(self):
"""Message field 'anchor_distances'."""
return self._anchor_distances
@anchor_distances.setter
def anchor_distances(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.int64, \
"The 'anchor_distances' numpy.ndarray() must have the dtype of 'numpy.int64'"
assert value.size == 4, \
"The 'anchor_distances' numpy.ndarray() must have a size of 4"
self._anchor_distances = value
return
if __debug__:
from collections.abc import Sequence
from collections.abc import Set
from collections import UserList
from collections import UserString
assert \
((isinstance(value, Sequence) or
isinstance(value, Set) or
isinstance(value, UserList)) and
not isinstance(value, str) and
not isinstance(value, UserString) and
len(value) == 4 and
all(isinstance(v, int) for v in value) and
all(val >= -9223372036854775808 and val < 9223372036854775808 for val in value)), \
"The 'anchor_distances' field must be a set or sequence with length 4 and each value of type 'int' and each integer in [-9223372036854775808, 9223372036854775807]"
self._anchor_distances = numpy.array(value, dtype=numpy.int64)

View File

@@ -0,0 +1,203 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from beacon_positioning:msg/TrackerPosition.idl
// generated code does not contain a copyright notice
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <Python.h>
#include <stdbool.h>
#ifndef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-function"
#endif
#include "numpy/ndarrayobject.h"
#ifndef _WIN32
# pragma GCC diagnostic pop
#endif
#include "rosidl_runtime_c/visibility_control.h"
#include "beacon_positioning/msg/detail/tracker_position__struct.h"
#include "beacon_positioning/msg/detail/tracker_position__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool beacon_positioning__msg__tracker_position__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[57];
{
char * class_name = NULL;
char * module_name = NULL;
{
PyObject * class_attr = PyObject_GetAttrString(_pymsg, "__class__");
if (class_attr) {
PyObject * name_attr = PyObject_GetAttrString(class_attr, "__name__");
if (name_attr) {
class_name = (char *)PyUnicode_1BYTE_DATA(name_attr);
Py_DECREF(name_attr);
}
PyObject * module_attr = PyObject_GetAttrString(class_attr, "__module__");
if (module_attr) {
module_name = (char *)PyUnicode_1BYTE_DATA(module_attr);
Py_DECREF(module_attr);
}
Py_DECREF(class_attr);
}
}
if (!class_name || !module_name) {
return false;
}
snprintf(full_classname_dest, sizeof(full_classname_dest), "%s.%s", module_name, class_name);
}
assert(strncmp("beacon_positioning.msg._tracker_position.TrackerPosition", full_classname_dest, 56) == 0);
}
beacon_positioning__msg__TrackerPosition * ros_message = _ros_message;
{ // id
PyObject * field = PyObject_GetAttrString(_pymsg, "id");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->id = (int32_t)PyLong_AsLong(field);
Py_DECREF(field);
}
{ // x_pos
PyObject * field = PyObject_GetAttrString(_pymsg, "x_pos");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->x_pos = PyLong_AsLongLong(field);
Py_DECREF(field);
}
{ // y_pos
PyObject * field = PyObject_GetAttrString(_pymsg, "y_pos");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->y_pos = PyLong_AsLongLong(field);
Py_DECREF(field);
}
{ // z_pos
PyObject * field = PyObject_GetAttrString(_pymsg, "z_pos");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->z_pos = PyLong_AsLongLong(field);
Py_DECREF(field);
}
{ // anchor_distances
PyObject * field = PyObject_GetAttrString(_pymsg, "anchor_distances");
if (!field) {
return false;
}
{
// TODO(dirk-thomas) use a better way to check the type before casting
assert(field->ob_type != NULL);
assert(field->ob_type->tp_name != NULL);
assert(strcmp(field->ob_type->tp_name, "numpy.ndarray") == 0);
PyArrayObject * seq_field = (PyArrayObject *)field;
Py_INCREF(seq_field);
assert(PyArray_NDIM(seq_field) == 1);
assert(PyArray_TYPE(seq_field) == NPY_INT64);
Py_ssize_t size = 4;
int64_t * dest = ros_message->anchor_distances;
for (Py_ssize_t i = 0; i < size; ++i) {
int64_t tmp = *(npy_int64 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(int64_t));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * beacon_positioning__msg__tracker_position__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of TrackerPosition */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("beacon_positioning.msg._tracker_position");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "TrackerPosition");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
beacon_positioning__msg__TrackerPosition * ros_message = (beacon_positioning__msg__TrackerPosition *)raw_ros_message;
{ // id
PyObject * field = NULL;
field = PyLong_FromLong(ros_message->id);
{
int rc = PyObject_SetAttrString(_pymessage, "id", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // x_pos
PyObject * field = NULL;
field = PyLong_FromLongLong(ros_message->x_pos);
{
int rc = PyObject_SetAttrString(_pymessage, "x_pos", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // y_pos
PyObject * field = NULL;
field = PyLong_FromLongLong(ros_message->y_pos);
{
int rc = PyObject_SetAttrString(_pymessage, "y_pos", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // z_pos
PyObject * field = NULL;
field = PyLong_FromLongLong(ros_message->z_pos);
{
int rc = PyObject_SetAttrString(_pymessage, "z_pos", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // anchor_distances
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "anchor_distances");
if (!field) {
return NULL;
}
assert(field->ob_type != NULL);
assert(field->ob_type->tp_name != NULL);
assert(strcmp(field->ob_type->tp_name, "numpy.ndarray") == 0);
PyArrayObject * seq_field = (PyArrayObject *)field;
assert(PyArray_NDIM(seq_field) == 1);
assert(PyArray_TYPE(seq_field) == NPY_INT64);
assert(sizeof(npy_int64) == sizeof(int64_t));
npy_int64 * dst = (npy_int64 *)PyArray_GETPTR1(seq_field, 0);
int64_t * src = &(ros_message->anchor_distances[0]);
memcpy(dst, src, 4 * sizeof(int64_t));
Py_DECREF(field);
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}