AS: adding first phase of orientation

This commit is contained in:
Alexander Schaefer
2025-01-29 09:58:44 +00:00
parent 79001dc331
commit 45650caa1b
5106 changed files with 582827 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
Metadata-Version: 2.1
Name: turtlesim
Version: 1.4.2
Summary: UNKNOWN
Home-page: UNKNOWN
License: UNKNOWN
Platform: UNKNOWN
UNKNOWN

View File

@@ -0,0 +1,6 @@
setup.py
turtlesim/__init__.py
turtlesim.egg-info/PKG-INFO
turtlesim.egg-info/SOURCES.txt
turtlesim.egg-info/dependency_links.txt
turtlesim.egg-info/top_level.txt

View File

@@ -0,0 +1 @@
from turtlesim.action._rotate_absolute import RotateAbsolute # noqa: F401

View File

@@ -0,0 +1,900 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from turtlesim:action/RotateAbsolute.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 "turtlesim/action/detail/rotate_absolute__struct.h"
#include "turtlesim/action/detail/rotate_absolute__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__action__rotate_absolute__goal__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[54];
{
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("turtlesim.action._rotate_absolute.RotateAbsolute_Goal", full_classname_dest, 53) == 0);
}
turtlesim__action__RotateAbsolute_Goal * ros_message = _ros_message;
{ // theta
PyObject * field = PyObject_GetAttrString(_pymsg, "theta");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->theta = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__action__rotate_absolute__goal__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of RotateAbsolute_Goal */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.action._rotate_absolute");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "RotateAbsolute_Goal");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__action__RotateAbsolute_Goal * ros_message = (turtlesim__action__RotateAbsolute_Goal *)raw_ros_message;
{ // theta
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->theta);
{
int rc = PyObject_SetAttrString(_pymessage, "theta", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
// already included above
// #include <Python.h>
// already included above
// #include <stdbool.h>
// already included above
// #include "numpy/ndarrayobject.h"
// already included above
// #include "rosidl_runtime_c/visibility_control.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__struct.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__action__rotate_absolute__result__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[56];
{
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("turtlesim.action._rotate_absolute.RotateAbsolute_Result", full_classname_dest, 55) == 0);
}
turtlesim__action__RotateAbsolute_Result * ros_message = _ros_message;
{ // delta
PyObject * field = PyObject_GetAttrString(_pymsg, "delta");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->delta = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__action__rotate_absolute__result__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of RotateAbsolute_Result */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.action._rotate_absolute");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "RotateAbsolute_Result");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__action__RotateAbsolute_Result * ros_message = (turtlesim__action__RotateAbsolute_Result *)raw_ros_message;
{ // delta
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->delta);
{
int rc = PyObject_SetAttrString(_pymessage, "delta", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
// already included above
// #include <Python.h>
// already included above
// #include <stdbool.h>
// already included above
// #include "numpy/ndarrayobject.h"
// already included above
// #include "rosidl_runtime_c/visibility_control.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__struct.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__action__rotate_absolute__feedback__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[58];
{
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("turtlesim.action._rotate_absolute.RotateAbsolute_Feedback", full_classname_dest, 57) == 0);
}
turtlesim__action__RotateAbsolute_Feedback * ros_message = _ros_message;
{ // remaining
PyObject * field = PyObject_GetAttrString(_pymsg, "remaining");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->remaining = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__action__rotate_absolute__feedback__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of RotateAbsolute_Feedback */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.action._rotate_absolute");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "RotateAbsolute_Feedback");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__action__RotateAbsolute_Feedback * ros_message = (turtlesim__action__RotateAbsolute_Feedback *)raw_ros_message;
{ // remaining
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->remaining);
{
int rc = PyObject_SetAttrString(_pymessage, "remaining", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
// already included above
// #include <Python.h>
// already included above
// #include <stdbool.h>
// already included above
// #include "numpy/ndarrayobject.h"
// already included above
// #include "rosidl_runtime_c/visibility_control.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__struct.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__functions.h"
ROSIDL_GENERATOR_C_IMPORT
bool unique_identifier_msgs__msg__uuid__convert_from_py(PyObject * _pymsg, void * _ros_message);
ROSIDL_GENERATOR_C_IMPORT
PyObject * unique_identifier_msgs__msg__uuid__convert_to_py(void * raw_ros_message);
bool turtlesim__action__rotate_absolute__goal__convert_from_py(PyObject * _pymsg, void * _ros_message);
PyObject * turtlesim__action__rotate_absolute__goal__convert_to_py(void * raw_ros_message);
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__action__rotate_absolute__send_goal__request__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[66];
{
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("turtlesim.action._rotate_absolute.RotateAbsolute_SendGoal_Request", full_classname_dest, 65) == 0);
}
turtlesim__action__RotateAbsolute_SendGoal_Request * ros_message = _ros_message;
{ // goal_id
PyObject * field = PyObject_GetAttrString(_pymsg, "goal_id");
if (!field) {
return false;
}
if (!unique_identifier_msgs__msg__uuid__convert_from_py(field, &ros_message->goal_id)) {
Py_DECREF(field);
return false;
}
Py_DECREF(field);
}
{ // goal
PyObject * field = PyObject_GetAttrString(_pymsg, "goal");
if (!field) {
return false;
}
if (!turtlesim__action__rotate_absolute__goal__convert_from_py(field, &ros_message->goal)) {
Py_DECREF(field);
return false;
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__action__rotate_absolute__send_goal__request__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of RotateAbsolute_SendGoal_Request */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.action._rotate_absolute");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "RotateAbsolute_SendGoal_Request");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__action__RotateAbsolute_SendGoal_Request * ros_message = (turtlesim__action__RotateAbsolute_SendGoal_Request *)raw_ros_message;
{ // goal_id
PyObject * field = NULL;
field = unique_identifier_msgs__msg__uuid__convert_to_py(&ros_message->goal_id);
if (!field) {
return NULL;
}
{
int rc = PyObject_SetAttrString(_pymessage, "goal_id", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // goal
PyObject * field = NULL;
field = turtlesim__action__rotate_absolute__goal__convert_to_py(&ros_message->goal);
if (!field) {
return NULL;
}
{
int rc = PyObject_SetAttrString(_pymessage, "goal", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
// already included above
// #include <Python.h>
// already included above
// #include <stdbool.h>
// already included above
// #include "numpy/ndarrayobject.h"
// already included above
// #include "rosidl_runtime_c/visibility_control.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__struct.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__functions.h"
ROSIDL_GENERATOR_C_IMPORT
bool builtin_interfaces__msg__time__convert_from_py(PyObject * _pymsg, void * _ros_message);
ROSIDL_GENERATOR_C_IMPORT
PyObject * builtin_interfaces__msg__time__convert_to_py(void * raw_ros_message);
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__action__rotate_absolute__send_goal__response__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[67];
{
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("turtlesim.action._rotate_absolute.RotateAbsolute_SendGoal_Response", full_classname_dest, 66) == 0);
}
turtlesim__action__RotateAbsolute_SendGoal_Response * ros_message = _ros_message;
{ // accepted
PyObject * field = PyObject_GetAttrString(_pymsg, "accepted");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->accepted = (Py_True == field);
Py_DECREF(field);
}
{ // stamp
PyObject * field = PyObject_GetAttrString(_pymsg, "stamp");
if (!field) {
return false;
}
if (!builtin_interfaces__msg__time__convert_from_py(field, &ros_message->stamp)) {
Py_DECREF(field);
return false;
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__action__rotate_absolute__send_goal__response__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of RotateAbsolute_SendGoal_Response */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.action._rotate_absolute");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "RotateAbsolute_SendGoal_Response");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__action__RotateAbsolute_SendGoal_Response * ros_message = (turtlesim__action__RotateAbsolute_SendGoal_Response *)raw_ros_message;
{ // accepted
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->accepted ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "accepted", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // stamp
PyObject * field = NULL;
field = builtin_interfaces__msg__time__convert_to_py(&ros_message->stamp);
if (!field) {
return NULL;
}
{
int rc = PyObject_SetAttrString(_pymessage, "stamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
// already included above
// #include <Python.h>
// already included above
// #include <stdbool.h>
// already included above
// #include "numpy/ndarrayobject.h"
// already included above
// #include "rosidl_runtime_c/visibility_control.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__struct.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__functions.h"
ROSIDL_GENERATOR_C_IMPORT
bool unique_identifier_msgs__msg__uuid__convert_from_py(PyObject * _pymsg, void * _ros_message);
ROSIDL_GENERATOR_C_IMPORT
PyObject * unique_identifier_msgs__msg__uuid__convert_to_py(void * raw_ros_message);
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__action__rotate_absolute__get_result__request__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[67];
{
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("turtlesim.action._rotate_absolute.RotateAbsolute_GetResult_Request", full_classname_dest, 66) == 0);
}
turtlesim__action__RotateAbsolute_GetResult_Request * ros_message = _ros_message;
{ // goal_id
PyObject * field = PyObject_GetAttrString(_pymsg, "goal_id");
if (!field) {
return false;
}
if (!unique_identifier_msgs__msg__uuid__convert_from_py(field, &ros_message->goal_id)) {
Py_DECREF(field);
return false;
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__action__rotate_absolute__get_result__request__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of RotateAbsolute_GetResult_Request */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.action._rotate_absolute");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "RotateAbsolute_GetResult_Request");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__action__RotateAbsolute_GetResult_Request * ros_message = (turtlesim__action__RotateAbsolute_GetResult_Request *)raw_ros_message;
{ // goal_id
PyObject * field = NULL;
field = unique_identifier_msgs__msg__uuid__convert_to_py(&ros_message->goal_id);
if (!field) {
return NULL;
}
{
int rc = PyObject_SetAttrString(_pymessage, "goal_id", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
// already included above
// #include <Python.h>
// already included above
// #include <stdbool.h>
// already included above
// #include "numpy/ndarrayobject.h"
// already included above
// #include "rosidl_runtime_c/visibility_control.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__struct.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__functions.h"
bool turtlesim__action__rotate_absolute__result__convert_from_py(PyObject * _pymsg, void * _ros_message);
PyObject * turtlesim__action__rotate_absolute__result__convert_to_py(void * raw_ros_message);
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__action__rotate_absolute__get_result__response__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[68];
{
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("turtlesim.action._rotate_absolute.RotateAbsolute_GetResult_Response", full_classname_dest, 67) == 0);
}
turtlesim__action__RotateAbsolute_GetResult_Response * ros_message = _ros_message;
{ // status
PyObject * field = PyObject_GetAttrString(_pymsg, "status");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->status = (int8_t)PyLong_AsLong(field);
Py_DECREF(field);
}
{ // result
PyObject * field = PyObject_GetAttrString(_pymsg, "result");
if (!field) {
return false;
}
if (!turtlesim__action__rotate_absolute__result__convert_from_py(field, &ros_message->result)) {
Py_DECREF(field);
return false;
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__action__rotate_absolute__get_result__response__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of RotateAbsolute_GetResult_Response */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.action._rotate_absolute");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "RotateAbsolute_GetResult_Response");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__action__RotateAbsolute_GetResult_Response * ros_message = (turtlesim__action__RotateAbsolute_GetResult_Response *)raw_ros_message;
{ // status
PyObject * field = NULL;
field = PyLong_FromLong(ros_message->status);
{
int rc = PyObject_SetAttrString(_pymessage, "status", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // result
PyObject * field = NULL;
field = turtlesim__action__rotate_absolute__result__convert_to_py(&ros_message->result);
if (!field) {
return NULL;
}
{
int rc = PyObject_SetAttrString(_pymessage, "result", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
// already included above
// #include <Python.h>
// already included above
// #include <stdbool.h>
// already included above
// #include "numpy/ndarrayobject.h"
// already included above
// #include "rosidl_runtime_c/visibility_control.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__struct.h"
// already included above
// #include "turtlesim/action/detail/rotate_absolute__functions.h"
ROSIDL_GENERATOR_C_IMPORT
bool unique_identifier_msgs__msg__uuid__convert_from_py(PyObject * _pymsg, void * _ros_message);
ROSIDL_GENERATOR_C_IMPORT
PyObject * unique_identifier_msgs__msg__uuid__convert_to_py(void * raw_ros_message);
bool turtlesim__action__rotate_absolute__feedback__convert_from_py(PyObject * _pymsg, void * _ros_message);
PyObject * turtlesim__action__rotate_absolute__feedback__convert_to_py(void * raw_ros_message);
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__action__rotate_absolute__feedback_message__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[65];
{
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("turtlesim.action._rotate_absolute.RotateAbsolute_FeedbackMessage", full_classname_dest, 64) == 0);
}
turtlesim__action__RotateAbsolute_FeedbackMessage * ros_message = _ros_message;
{ // goal_id
PyObject * field = PyObject_GetAttrString(_pymsg, "goal_id");
if (!field) {
return false;
}
if (!unique_identifier_msgs__msg__uuid__convert_from_py(field, &ros_message->goal_id)) {
Py_DECREF(field);
return false;
}
Py_DECREF(field);
}
{ // feedback
PyObject * field = PyObject_GetAttrString(_pymsg, "feedback");
if (!field) {
return false;
}
if (!turtlesim__action__rotate_absolute__feedback__convert_from_py(field, &ros_message->feedback)) {
Py_DECREF(field);
return false;
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__action__rotate_absolute__feedback_message__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of RotateAbsolute_FeedbackMessage */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.action._rotate_absolute");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "RotateAbsolute_FeedbackMessage");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__action__RotateAbsolute_FeedbackMessage * ros_message = (turtlesim__action__RotateAbsolute_FeedbackMessage *)raw_ros_message;
{ // goal_id
PyObject * field = NULL;
field = unique_identifier_msgs__msg__uuid__convert_to_py(&ros_message->goal_id);
if (!field) {
return NULL;
}
{
int rc = PyObject_SetAttrString(_pymessage, "goal_id", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // feedback
PyObject * field = NULL;
field = turtlesim__action__rotate_absolute__feedback__convert_to_py(&ros_message->feedback);
if (!field) {
return NULL;
}
{
int rc = PyObject_SetAttrString(_pymessage, "feedback", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -0,0 +1,2 @@
from turtlesim.msg._color import Color # noqa: F401
from turtlesim.msg._pose import Pose # noqa: F401

View File

@@ -0,0 +1,168 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from turtlesim:msg/Color.idl
# generated code does not contain a copyright notice
# Import statements for member types
import builtins # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_Color(type):
"""Metaclass of message 'Color'."""
_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('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.msg.Color')
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__color
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__color
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__color
cls._TYPE_SUPPORT = module.type_support_msg__msg__color
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__color
@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 Color(metaclass=Metaclass_Color):
"""Message class 'Color'."""
__slots__ = [
'_r',
'_g',
'_b',
]
_fields_and_field_types = {
'r': 'uint8',
'g': 'uint8',
'b': 'uint8',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # 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.r = kwargs.get('r', int())
self.g = kwargs.get('g', int())
self.b = kwargs.get('b', int())
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.r != other.r:
return False
if self.g != other.g:
return False
if self.b != other.b:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@builtins.property
def r(self):
"""Message field 'r'."""
return self._r
@r.setter
def r(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'r' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'r' field must be an unsigned integer in [0, 255]"
self._r = value
@builtins.property
def g(self):
"""Message field 'g'."""
return self._g
@g.setter
def g(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'g' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'g' field must be an unsigned integer in [0, 255]"
self._g = value
@builtins.property
def b(self):
"""Message field 'b'."""
return self._b
@b.setter
def b(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'b' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'b' field must be an unsigned integer in [0, 255]"
self._b = value

View File

@@ -0,0 +1,138 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from turtlesim:msg/Color.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 "turtlesim/msg/detail/color__struct.h"
#include "turtlesim/msg/detail/color__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__msg__color__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[27];
{
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("turtlesim.msg._color.Color", full_classname_dest, 26) == 0);
}
turtlesim__msg__Color * ros_message = _ros_message;
{ // r
PyObject * field = PyObject_GetAttrString(_pymsg, "r");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->r = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // g
PyObject * field = PyObject_GetAttrString(_pymsg, "g");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->g = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // b
PyObject * field = PyObject_GetAttrString(_pymsg, "b");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->b = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__msg__color__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of Color */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.msg._color");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "Color");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__msg__Color * ros_message = (turtlesim__msg__Color *)raw_ros_message;
{ // r
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->r);
{
int rc = PyObject_SetAttrString(_pymessage, "r", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // g
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->g);
{
int rc = PyObject_SetAttrString(_pymessage, "g", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // b
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->b);
{
int rc = PyObject_SetAttrString(_pymessage, "b", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -0,0 +1,212 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from turtlesim:msg/Pose.idl
# generated code does not contain a copyright notice
# Import statements for member types
import builtins # noqa: E402, I100
import math # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_Pose(type):
"""Metaclass of message 'Pose'."""
_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('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.msg.Pose')
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__pose
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__pose
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__pose
cls._TYPE_SUPPORT = module.type_support_msg__msg__pose
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__pose
@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 Pose(metaclass=Metaclass_Pose):
"""Message class 'Pose'."""
__slots__ = [
'_x',
'_y',
'_theta',
'_linear_velocity',
'_angular_velocity',
]
_fields_and_field_types = {
'x': 'float',
'y': 'float',
'theta': 'float',
'linear_velocity': 'float',
'angular_velocity': 'float',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # 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.x = kwargs.get('x', float())
self.y = kwargs.get('y', float())
self.theta = kwargs.get('theta', float())
self.linear_velocity = kwargs.get('linear_velocity', float())
self.angular_velocity = kwargs.get('angular_velocity', float())
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.x != other.x:
return False
if self.y != other.y:
return False
if self.theta != other.theta:
return False
if self.linear_velocity != other.linear_velocity:
return False
if self.angular_velocity != other.angular_velocity:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@builtins.property
def x(self):
"""Message field 'x'."""
return self._x
@x.setter
def x(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'x' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'x' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._x = value
@builtins.property
def y(self):
"""Message field 'y'."""
return self._y
@y.setter
def y(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'y' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'y' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._y = value
@builtins.property
def theta(self):
"""Message field 'theta'."""
return self._theta
@theta.setter
def theta(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'theta' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'theta' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._theta = value
@builtins.property
def linear_velocity(self):
"""Message field 'linear_velocity'."""
return self._linear_velocity
@linear_velocity.setter
def linear_velocity(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'linear_velocity' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'linear_velocity' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._linear_velocity = value
@builtins.property
def angular_velocity(self):
"""Message field 'angular_velocity'."""
return self._angular_velocity
@angular_velocity.setter
def angular_velocity(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'angular_velocity' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'angular_velocity' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._angular_velocity = value

View File

@@ -0,0 +1,178 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from turtlesim:msg/Pose.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 "turtlesim/msg/detail/pose__struct.h"
#include "turtlesim/msg/detail/pose__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__msg__pose__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[25];
{
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("turtlesim.msg._pose.Pose", full_classname_dest, 24) == 0);
}
turtlesim__msg__Pose * ros_message = _ros_message;
{ // x
PyObject * field = PyObject_GetAttrString(_pymsg, "x");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->x = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // y
PyObject * field = PyObject_GetAttrString(_pymsg, "y");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->y = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // theta
PyObject * field = PyObject_GetAttrString(_pymsg, "theta");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->theta = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // linear_velocity
PyObject * field = PyObject_GetAttrString(_pymsg, "linear_velocity");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->linear_velocity = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // angular_velocity
PyObject * field = PyObject_GetAttrString(_pymsg, "angular_velocity");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->angular_velocity = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__msg__pose__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of Pose */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.msg._pose");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "Pose");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__msg__Pose * ros_message = (turtlesim__msg__Pose *)raw_ros_message;
{ // x
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->x);
{
int rc = PyObject_SetAttrString(_pymessage, "x", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // y
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->y);
{
int rc = PyObject_SetAttrString(_pymessage, "y", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // theta
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->theta);
{
int rc = PyObject_SetAttrString(_pymessage, "theta", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // linear_velocity
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->linear_velocity);
{
int rc = PyObject_SetAttrString(_pymessage, "linear_velocity", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // angular_velocity
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->angular_velocity);
{
int rc = PyObject_SetAttrString(_pymessage, "angular_velocity", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -0,0 +1,5 @@
from turtlesim.srv._kill import Kill # noqa: F401
from turtlesim.srv._set_pen import SetPen # noqa: F401
from turtlesim.srv._spawn import Spawn # noqa: F401
from turtlesim.srv._teleport_absolute import TeleportAbsolute # noqa: F401
from turtlesim.srv._teleport_relative import TeleportRelative # noqa: F401

View File

@@ -0,0 +1,261 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from turtlesim:srv/Kill.idl
# generated code does not contain a copyright notice
# Import statements for member types
import builtins # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_Kill_Request(type):
"""Metaclass of message 'Kill_Request'."""
_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('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.Kill_Request')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._CREATE_ROS_MESSAGE = module.create_ros_message_msg__srv__kill__request
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__kill__request
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__kill__request
cls._TYPE_SUPPORT = module.type_support_msg__srv__kill__request
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__kill__request
@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 Kill_Request(metaclass=Metaclass_Kill_Request):
"""Message class 'Kill_Request'."""
__slots__ = [
'_name',
]
_fields_and_field_types = {
'name': 'string',
}
SLOT_TYPES = (
rosidl_parser.definition.UnboundedString(), # 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.name = kwargs.get('name', str())
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.name != other.name:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@builtins.property
def name(self):
"""Message field 'name'."""
return self._name
@name.setter
def name(self, value):
if __debug__:
assert \
isinstance(value, str), \
"The 'name' field must be of type 'str'"
self._name = value
# Import statements for member types
# already imported above
# import rosidl_parser.definition
class Metaclass_Kill_Response(type):
"""Metaclass of message 'Kill_Response'."""
_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('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.Kill_Response')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._CREATE_ROS_MESSAGE = module.create_ros_message_msg__srv__kill__response
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__kill__response
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__kill__response
cls._TYPE_SUPPORT = module.type_support_msg__srv__kill__response
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__kill__response
@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 Kill_Response(metaclass=Metaclass_Kill_Response):
"""Message class 'Kill_Response'."""
__slots__ = [
]
_fields_and_field_types = {
}
SLOT_TYPES = (
)
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__))
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
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
class Metaclass_Kill(type):
"""Metaclass of service 'Kill'."""
_TYPE_SUPPORT = None
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.Kill')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._TYPE_SUPPORT = module.type_support_srv__srv__kill
from turtlesim.srv import _kill
if _kill.Metaclass_Kill_Request._TYPE_SUPPORT is None:
_kill.Metaclass_Kill_Request.__import_type_support__()
if _kill.Metaclass_Kill_Response._TYPE_SUPPORT is None:
_kill.Metaclass_Kill_Response.__import_type_support__()
class Kill(metaclass=Metaclass_Kill):
from turtlesim.srv._kill import Kill_Request as Request
from turtlesim.srv._kill import Kill_Response as Response
def __init__(self):
raise NotImplementedError('Service classes can not be instantiated')

View File

@@ -0,0 +1,189 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from turtlesim:srv/Kill.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 "turtlesim/srv/detail/kill__struct.h"
#include "turtlesim/srv/detail/kill__functions.h"
#include "rosidl_runtime_c/string.h"
#include "rosidl_runtime_c/string_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__srv__kill__request__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[33];
{
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("turtlesim.srv._kill.Kill_Request", full_classname_dest, 32) == 0);
}
turtlesim__srv__Kill_Request * ros_message = _ros_message;
{ // name
PyObject * field = PyObject_GetAttrString(_pymsg, "name");
if (!field) {
return false;
}
assert(PyUnicode_Check(field));
PyObject * encoded_field = PyUnicode_AsUTF8String(field);
if (!encoded_field) {
Py_DECREF(field);
return false;
}
rosidl_runtime_c__String__assign(&ros_message->name, PyBytes_AS_STRING(encoded_field));
Py_DECREF(encoded_field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__srv__kill__request__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of Kill_Request */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.srv._kill");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "Kill_Request");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__srv__Kill_Request * ros_message = (turtlesim__srv__Kill_Request *)raw_ros_message;
{ // name
PyObject * field = NULL;
field = PyUnicode_DecodeUTF8(
ros_message->name.data,
strlen(ros_message->name.data),
"replace");
if (!field) {
return NULL;
}
{
int rc = PyObject_SetAttrString(_pymessage, "name", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
// already included above
// #include <Python.h>
// already included above
// #include <stdbool.h>
// already included above
// #include "numpy/ndarrayobject.h"
// already included above
// #include "rosidl_runtime_c/visibility_control.h"
// already included above
// #include "turtlesim/srv/detail/kill__struct.h"
// already included above
// #include "turtlesim/srv/detail/kill__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__srv__kill__response__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[34];
{
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("turtlesim.srv._kill.Kill_Response", full_classname_dest, 33) == 0);
}
turtlesim__srv__Kill_Response * ros_message = _ros_message;
ros_message->structure_needs_at_least_one_member = 0;
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__srv__kill__response__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of Kill_Response */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.srv._kill");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "Kill_Response");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
(void)raw_ros_message;
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -0,0 +1,347 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from turtlesim:srv/SetPen.idl
# generated code does not contain a copyright notice
# Import statements for member types
import builtins # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_SetPen_Request(type):
"""Metaclass of message 'SetPen_Request'."""
_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('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.SetPen_Request')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._CREATE_ROS_MESSAGE = module.create_ros_message_msg__srv__set_pen__request
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__set_pen__request
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__set_pen__request
cls._TYPE_SUPPORT = module.type_support_msg__srv__set_pen__request
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__set_pen__request
@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 SetPen_Request(metaclass=Metaclass_SetPen_Request):
"""Message class 'SetPen_Request'."""
__slots__ = [
'_r',
'_g',
'_b',
'_width',
'_off',
]
_fields_and_field_types = {
'r': 'uint8',
'g': 'uint8',
'b': 'uint8',
'width': 'uint8',
'off': 'uint8',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # 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.r = kwargs.get('r', int())
self.g = kwargs.get('g', int())
self.b = kwargs.get('b', int())
self.width = kwargs.get('width', int())
self.off = kwargs.get('off', int())
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.r != other.r:
return False
if self.g != other.g:
return False
if self.b != other.b:
return False
if self.width != other.width:
return False
if self.off != other.off:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@builtins.property
def r(self):
"""Message field 'r'."""
return self._r
@r.setter
def r(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'r' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'r' field must be an unsigned integer in [0, 255]"
self._r = value
@builtins.property
def g(self):
"""Message field 'g'."""
return self._g
@g.setter
def g(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'g' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'g' field must be an unsigned integer in [0, 255]"
self._g = value
@builtins.property
def b(self):
"""Message field 'b'."""
return self._b
@b.setter
def b(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'b' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'b' field must be an unsigned integer in [0, 255]"
self._b = value
@builtins.property
def width(self):
"""Message field 'width'."""
return self._width
@width.setter
def width(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'width' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'width' field must be an unsigned integer in [0, 255]"
self._width = value
@builtins.property
def off(self):
"""Message field 'off'."""
return self._off
@off.setter
def off(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'off' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'off' field must be an unsigned integer in [0, 255]"
self._off = value
# Import statements for member types
# already imported above
# import rosidl_parser.definition
class Metaclass_SetPen_Response(type):
"""Metaclass of message 'SetPen_Response'."""
_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('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.SetPen_Response')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._CREATE_ROS_MESSAGE = module.create_ros_message_msg__srv__set_pen__response
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__set_pen__response
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__set_pen__response
cls._TYPE_SUPPORT = module.type_support_msg__srv__set_pen__response
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__set_pen__response
@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 SetPen_Response(metaclass=Metaclass_SetPen_Response):
"""Message class 'SetPen_Response'."""
__slots__ = [
]
_fields_and_field_types = {
}
SLOT_TYPES = (
)
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__))
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
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
class Metaclass_SetPen(type):
"""Metaclass of service 'SetPen'."""
_TYPE_SUPPORT = None
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.SetPen')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._TYPE_SUPPORT = module.type_support_srv__srv__set_pen
from turtlesim.srv import _set_pen
if _set_pen.Metaclass_SetPen_Request._TYPE_SUPPORT is None:
_set_pen.Metaclass_SetPen_Request.__import_type_support__()
if _set_pen.Metaclass_SetPen_Response._TYPE_SUPPORT is None:
_set_pen.Metaclass_SetPen_Response.__import_type_support__()
class SetPen(metaclass=Metaclass_SetPen):
from turtlesim.srv._set_pen import SetPen_Request as Request
from turtlesim.srv._set_pen import SetPen_Response as Response
def __init__(self):
raise NotImplementedError('Service classes can not be instantiated')

View File

@@ -0,0 +1,254 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from turtlesim:srv/SetPen.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 "turtlesim/srv/detail/set_pen__struct.h"
#include "turtlesim/srv/detail/set_pen__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__srv__set_pen__request__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[38];
{
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("turtlesim.srv._set_pen.SetPen_Request", full_classname_dest, 37) == 0);
}
turtlesim__srv__SetPen_Request * ros_message = _ros_message;
{ // r
PyObject * field = PyObject_GetAttrString(_pymsg, "r");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->r = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // g
PyObject * field = PyObject_GetAttrString(_pymsg, "g");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->g = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // b
PyObject * field = PyObject_GetAttrString(_pymsg, "b");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->b = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // width
PyObject * field = PyObject_GetAttrString(_pymsg, "width");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->width = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // off
PyObject * field = PyObject_GetAttrString(_pymsg, "off");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->off = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__srv__set_pen__request__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of SetPen_Request */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.srv._set_pen");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "SetPen_Request");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__srv__SetPen_Request * ros_message = (turtlesim__srv__SetPen_Request *)raw_ros_message;
{ // r
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->r);
{
int rc = PyObject_SetAttrString(_pymessage, "r", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // g
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->g);
{
int rc = PyObject_SetAttrString(_pymessage, "g", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // b
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->b);
{
int rc = PyObject_SetAttrString(_pymessage, "b", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // width
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->width);
{
int rc = PyObject_SetAttrString(_pymessage, "width", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // off
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->off);
{
int rc = PyObject_SetAttrString(_pymessage, "off", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
// already included above
// #include <Python.h>
// already included above
// #include <stdbool.h>
// already included above
// #include "numpy/ndarrayobject.h"
// already included above
// #include "rosidl_runtime_c/visibility_control.h"
// already included above
// #include "turtlesim/srv/detail/set_pen__struct.h"
// already included above
// #include "turtlesim/srv/detail/set_pen__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__srv__set_pen__response__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[39];
{
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("turtlesim.srv._set_pen.SetPen_Response", full_classname_dest, 38) == 0);
}
turtlesim__srv__SetPen_Response * ros_message = _ros_message;
ros_message->structure_needs_at_least_one_member = 0;
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__srv__set_pen__response__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of SetPen_Response */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.srv._set_pen");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "SetPen_Response");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
(void)raw_ros_message;
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -0,0 +1,348 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from turtlesim:srv/Spawn.idl
# generated code does not contain a copyright notice
# Import statements for member types
import builtins # noqa: E402, I100
import math # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_Spawn_Request(type):
"""Metaclass of message 'Spawn_Request'."""
_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('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.Spawn_Request')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._CREATE_ROS_MESSAGE = module.create_ros_message_msg__srv__spawn__request
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__spawn__request
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__spawn__request
cls._TYPE_SUPPORT = module.type_support_msg__srv__spawn__request
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__spawn__request
@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 Spawn_Request(metaclass=Metaclass_Spawn_Request):
"""Message class 'Spawn_Request'."""
__slots__ = [
'_x',
'_y',
'_theta',
'_name',
]
_fields_and_field_types = {
'x': 'float',
'y': 'float',
'theta': 'float',
'name': 'string',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.UnboundedString(), # 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.x = kwargs.get('x', float())
self.y = kwargs.get('y', float())
self.theta = kwargs.get('theta', float())
self.name = kwargs.get('name', str())
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.x != other.x:
return False
if self.y != other.y:
return False
if self.theta != other.theta:
return False
if self.name != other.name:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@builtins.property
def x(self):
"""Message field 'x'."""
return self._x
@x.setter
def x(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'x' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'x' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._x = value
@builtins.property
def y(self):
"""Message field 'y'."""
return self._y
@y.setter
def y(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'y' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'y' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._y = value
@builtins.property
def theta(self):
"""Message field 'theta'."""
return self._theta
@theta.setter
def theta(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'theta' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'theta' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._theta = value
@builtins.property
def name(self):
"""Message field 'name'."""
return self._name
@name.setter
def name(self, value):
if __debug__:
assert \
isinstance(value, str), \
"The 'name' field must be of type 'str'"
self._name = value
# Import statements for member types
# already imported above
# import builtins
# already imported above
# import rosidl_parser.definition
class Metaclass_Spawn_Response(type):
"""Metaclass of message 'Spawn_Response'."""
_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('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.Spawn_Response')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._CREATE_ROS_MESSAGE = module.create_ros_message_msg__srv__spawn__response
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__spawn__response
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__spawn__response
cls._TYPE_SUPPORT = module.type_support_msg__srv__spawn__response
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__spawn__response
@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 Spawn_Response(metaclass=Metaclass_Spawn_Response):
"""Message class 'Spawn_Response'."""
__slots__ = [
'_name',
]
_fields_and_field_types = {
'name': 'string',
}
SLOT_TYPES = (
rosidl_parser.definition.UnboundedString(), # 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.name = kwargs.get('name', str())
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.name != other.name:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@builtins.property
def name(self):
"""Message field 'name'."""
return self._name
@name.setter
def name(self, value):
if __debug__:
assert \
isinstance(value, str), \
"The 'name' field must be of type 'str'"
self._name = value
class Metaclass_Spawn(type):
"""Metaclass of service 'Spawn'."""
_TYPE_SUPPORT = None
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.Spawn')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._TYPE_SUPPORT = module.type_support_srv__srv__spawn
from turtlesim.srv import _spawn
if _spawn.Metaclass_Spawn_Request._TYPE_SUPPORT is None:
_spawn.Metaclass_Spawn_Request.__import_type_support__()
if _spawn.Metaclass_Spawn_Response._TYPE_SUPPORT is None:
_spawn.Metaclass_Spawn_Response.__import_type_support__()
class Spawn(metaclass=Metaclass_Spawn):
from turtlesim.srv._spawn import Spawn_Request as Request
from turtlesim.srv._spawn import Spawn_Response as Response
def __init__(self):
raise NotImplementedError('Service classes can not be instantiated')

View File

@@ -0,0 +1,285 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from turtlesim:srv/Spawn.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 "turtlesim/srv/detail/spawn__struct.h"
#include "turtlesim/srv/detail/spawn__functions.h"
#include "rosidl_runtime_c/string.h"
#include "rosidl_runtime_c/string_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__srv__spawn__request__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[35];
{
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("turtlesim.srv._spawn.Spawn_Request", full_classname_dest, 34) == 0);
}
turtlesim__srv__Spawn_Request * ros_message = _ros_message;
{ // x
PyObject * field = PyObject_GetAttrString(_pymsg, "x");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->x = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // y
PyObject * field = PyObject_GetAttrString(_pymsg, "y");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->y = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // theta
PyObject * field = PyObject_GetAttrString(_pymsg, "theta");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->theta = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // name
PyObject * field = PyObject_GetAttrString(_pymsg, "name");
if (!field) {
return false;
}
assert(PyUnicode_Check(field));
PyObject * encoded_field = PyUnicode_AsUTF8String(field);
if (!encoded_field) {
Py_DECREF(field);
return false;
}
rosidl_runtime_c__String__assign(&ros_message->name, PyBytes_AS_STRING(encoded_field));
Py_DECREF(encoded_field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__srv__spawn__request__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of Spawn_Request */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.srv._spawn");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "Spawn_Request");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__srv__Spawn_Request * ros_message = (turtlesim__srv__Spawn_Request *)raw_ros_message;
{ // x
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->x);
{
int rc = PyObject_SetAttrString(_pymessage, "x", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // y
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->y);
{
int rc = PyObject_SetAttrString(_pymessage, "y", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // theta
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->theta);
{
int rc = PyObject_SetAttrString(_pymessage, "theta", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // name
PyObject * field = NULL;
field = PyUnicode_DecodeUTF8(
ros_message->name.data,
strlen(ros_message->name.data),
"replace");
if (!field) {
return NULL;
}
{
int rc = PyObject_SetAttrString(_pymessage, "name", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
// already included above
// #include <Python.h>
// already included above
// #include <stdbool.h>
// already included above
// #include "numpy/ndarrayobject.h"
// already included above
// #include "rosidl_runtime_c/visibility_control.h"
// already included above
// #include "turtlesim/srv/detail/spawn__struct.h"
// already included above
// #include "turtlesim/srv/detail/spawn__functions.h"
// already included above
// #include "rosidl_runtime_c/string.h"
// already included above
// #include "rosidl_runtime_c/string_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__srv__spawn__response__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[36];
{
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("turtlesim.srv._spawn.Spawn_Response", full_classname_dest, 35) == 0);
}
turtlesim__srv__Spawn_Response * ros_message = _ros_message;
{ // name
PyObject * field = PyObject_GetAttrString(_pymsg, "name");
if (!field) {
return false;
}
assert(PyUnicode_Check(field));
PyObject * encoded_field = PyUnicode_AsUTF8String(field);
if (!encoded_field) {
Py_DECREF(field);
return false;
}
rosidl_runtime_c__String__assign(&ros_message->name, PyBytes_AS_STRING(encoded_field));
Py_DECREF(encoded_field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__srv__spawn__response__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of Spawn_Response */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.srv._spawn");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "Spawn_Response");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__srv__Spawn_Response * ros_message = (turtlesim__srv__Spawn_Response *)raw_ros_message;
{ // name
PyObject * field = NULL;
field = PyUnicode_DecodeUTF8(
ros_message->name.data,
strlen(ros_message->name.data),
"replace");
if (!field) {
return NULL;
}
{
int rc = PyObject_SetAttrString(_pymessage, "name", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -0,0 +1,307 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from turtlesim:srv/TeleportAbsolute.idl
# generated code does not contain a copyright notice
# Import statements for member types
import builtins # noqa: E402, I100
import math # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_TeleportAbsolute_Request(type):
"""Metaclass of message 'TeleportAbsolute_Request'."""
_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('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.TeleportAbsolute_Request')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._CREATE_ROS_MESSAGE = module.create_ros_message_msg__srv__teleport_absolute__request
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__teleport_absolute__request
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__teleport_absolute__request
cls._TYPE_SUPPORT = module.type_support_msg__srv__teleport_absolute__request
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__teleport_absolute__request
@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 TeleportAbsolute_Request(metaclass=Metaclass_TeleportAbsolute_Request):
"""Message class 'TeleportAbsolute_Request'."""
__slots__ = [
'_x',
'_y',
'_theta',
]
_fields_and_field_types = {
'x': 'float',
'y': 'float',
'theta': 'float',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # 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.x = kwargs.get('x', float())
self.y = kwargs.get('y', float())
self.theta = kwargs.get('theta', float())
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.x != other.x:
return False
if self.y != other.y:
return False
if self.theta != other.theta:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@builtins.property
def x(self):
"""Message field 'x'."""
return self._x
@x.setter
def x(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'x' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'x' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._x = value
@builtins.property
def y(self):
"""Message field 'y'."""
return self._y
@y.setter
def y(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'y' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'y' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._y = value
@builtins.property
def theta(self):
"""Message field 'theta'."""
return self._theta
@theta.setter
def theta(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'theta' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'theta' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._theta = value
# Import statements for member types
# already imported above
# import rosidl_parser.definition
class Metaclass_TeleportAbsolute_Response(type):
"""Metaclass of message 'TeleportAbsolute_Response'."""
_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('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.TeleportAbsolute_Response')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._CREATE_ROS_MESSAGE = module.create_ros_message_msg__srv__teleport_absolute__response
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__teleport_absolute__response
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__teleport_absolute__response
cls._TYPE_SUPPORT = module.type_support_msg__srv__teleport_absolute__response
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__teleport_absolute__response
@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 TeleportAbsolute_Response(metaclass=Metaclass_TeleportAbsolute_Response):
"""Message class 'TeleportAbsolute_Response'."""
__slots__ = [
]
_fields_and_field_types = {
}
SLOT_TYPES = (
)
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__))
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
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
class Metaclass_TeleportAbsolute(type):
"""Metaclass of service 'TeleportAbsolute'."""
_TYPE_SUPPORT = None
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.TeleportAbsolute')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._TYPE_SUPPORT = module.type_support_srv__srv__teleport_absolute
from turtlesim.srv import _teleport_absolute
if _teleport_absolute.Metaclass_TeleportAbsolute_Request._TYPE_SUPPORT is None:
_teleport_absolute.Metaclass_TeleportAbsolute_Request.__import_type_support__()
if _teleport_absolute.Metaclass_TeleportAbsolute_Response._TYPE_SUPPORT is None:
_teleport_absolute.Metaclass_TeleportAbsolute_Response.__import_type_support__()
class TeleportAbsolute(metaclass=Metaclass_TeleportAbsolute):
from turtlesim.srv._teleport_absolute import TeleportAbsolute_Request as Request
from turtlesim.srv._teleport_absolute import TeleportAbsolute_Response as Response
def __init__(self):
raise NotImplementedError('Service classes can not be instantiated')

View File

@@ -0,0 +1,214 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from turtlesim:srv/TeleportAbsolute.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 "turtlesim/srv/detail/teleport_absolute__struct.h"
#include "turtlesim/srv/detail/teleport_absolute__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__srv__teleport_absolute__request__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[58];
{
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("turtlesim.srv._teleport_absolute.TeleportAbsolute_Request", full_classname_dest, 57) == 0);
}
turtlesim__srv__TeleportAbsolute_Request * ros_message = _ros_message;
{ // x
PyObject * field = PyObject_GetAttrString(_pymsg, "x");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->x = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // y
PyObject * field = PyObject_GetAttrString(_pymsg, "y");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->y = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // theta
PyObject * field = PyObject_GetAttrString(_pymsg, "theta");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->theta = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__srv__teleport_absolute__request__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of TeleportAbsolute_Request */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.srv._teleport_absolute");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "TeleportAbsolute_Request");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__srv__TeleportAbsolute_Request * ros_message = (turtlesim__srv__TeleportAbsolute_Request *)raw_ros_message;
{ // x
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->x);
{
int rc = PyObject_SetAttrString(_pymessage, "x", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // y
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->y);
{
int rc = PyObject_SetAttrString(_pymessage, "y", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // theta
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->theta);
{
int rc = PyObject_SetAttrString(_pymessage, "theta", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
// already included above
// #include <Python.h>
// already included above
// #include <stdbool.h>
// already included above
// #include "numpy/ndarrayobject.h"
// already included above
// #include "rosidl_runtime_c/visibility_control.h"
// already included above
// #include "turtlesim/srv/detail/teleport_absolute__struct.h"
// already included above
// #include "turtlesim/srv/detail/teleport_absolute__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__srv__teleport_absolute__response__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[59];
{
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("turtlesim.srv._teleport_absolute.TeleportAbsolute_Response", full_classname_dest, 58) == 0);
}
turtlesim__srv__TeleportAbsolute_Response * ros_message = _ros_message;
ros_message->structure_needs_at_least_one_member = 0;
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__srv__teleport_absolute__response__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of TeleportAbsolute_Response */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.srv._teleport_absolute");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "TeleportAbsolute_Response");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
(void)raw_ros_message;
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -0,0 +1,286 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from turtlesim:srv/TeleportRelative.idl
# generated code does not contain a copyright notice
# Import statements for member types
import builtins # noqa: E402, I100
import math # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_TeleportRelative_Request(type):
"""Metaclass of message 'TeleportRelative_Request'."""
_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('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.TeleportRelative_Request')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._CREATE_ROS_MESSAGE = module.create_ros_message_msg__srv__teleport_relative__request
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__teleport_relative__request
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__teleport_relative__request
cls._TYPE_SUPPORT = module.type_support_msg__srv__teleport_relative__request
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__teleport_relative__request
@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 TeleportRelative_Request(metaclass=Metaclass_TeleportRelative_Request):
"""Message class 'TeleportRelative_Request'."""
__slots__ = [
'_linear',
'_angular',
]
_fields_and_field_types = {
'linear': 'float',
'angular': 'float',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # 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.linear = kwargs.get('linear', float())
self.angular = kwargs.get('angular', float())
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.linear != other.linear:
return False
if self.angular != other.angular:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@builtins.property
def linear(self):
"""Message field 'linear'."""
return self._linear
@linear.setter
def linear(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'linear' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'linear' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._linear = value
@builtins.property
def angular(self):
"""Message field 'angular'."""
return self._angular
@angular.setter
def angular(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'angular' field must be of type 'float'"
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
"The 'angular' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
self._angular = value
# Import statements for member types
# already imported above
# import rosidl_parser.definition
class Metaclass_TeleportRelative_Response(type):
"""Metaclass of message 'TeleportRelative_Response'."""
_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('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.TeleportRelative_Response')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._CREATE_ROS_MESSAGE = module.create_ros_message_msg__srv__teleport_relative__response
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__teleport_relative__response
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__teleport_relative__response
cls._TYPE_SUPPORT = module.type_support_msg__srv__teleport_relative__response
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__teleport_relative__response
@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 TeleportRelative_Response(metaclass=Metaclass_TeleportRelative_Response):
"""Message class 'TeleportRelative_Response'."""
__slots__ = [
]
_fields_and_field_types = {
}
SLOT_TYPES = (
)
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__))
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
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
class Metaclass_TeleportRelative(type):
"""Metaclass of service 'TeleportRelative'."""
_TYPE_SUPPORT = None
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('turtlesim')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'turtlesim.srv.TeleportRelative')
logger.debug(
'Failed to import needed modules for type support:\n' +
traceback.format_exc())
else:
cls._TYPE_SUPPORT = module.type_support_srv__srv__teleport_relative
from turtlesim.srv import _teleport_relative
if _teleport_relative.Metaclass_TeleportRelative_Request._TYPE_SUPPORT is None:
_teleport_relative.Metaclass_TeleportRelative_Request.__import_type_support__()
if _teleport_relative.Metaclass_TeleportRelative_Response._TYPE_SUPPORT is None:
_teleport_relative.Metaclass_TeleportRelative_Response.__import_type_support__()
class TeleportRelative(metaclass=Metaclass_TeleportRelative):
from turtlesim.srv._teleport_relative import TeleportRelative_Request as Request
from turtlesim.srv._teleport_relative import TeleportRelative_Response as Response
def __init__(self):
raise NotImplementedError('Service classes can not be instantiated')

View File

@@ -0,0 +1,194 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from turtlesim:srv/TeleportRelative.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 "turtlesim/srv/detail/teleport_relative__struct.h"
#include "turtlesim/srv/detail/teleport_relative__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__srv__teleport_relative__request__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[58];
{
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("turtlesim.srv._teleport_relative.TeleportRelative_Request", full_classname_dest, 57) == 0);
}
turtlesim__srv__TeleportRelative_Request * ros_message = _ros_message;
{ // linear
PyObject * field = PyObject_GetAttrString(_pymsg, "linear");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->linear = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // angular
PyObject * field = PyObject_GetAttrString(_pymsg, "angular");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->angular = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__srv__teleport_relative__request__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of TeleportRelative_Request */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.srv._teleport_relative");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "TeleportRelative_Request");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
turtlesim__srv__TeleportRelative_Request * ros_message = (turtlesim__srv__TeleportRelative_Request *)raw_ros_message;
{ // linear
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->linear);
{
int rc = PyObject_SetAttrString(_pymessage, "linear", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // angular
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->angular);
{
int rc = PyObject_SetAttrString(_pymessage, "angular", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
// already included above
// #include <Python.h>
// already included above
// #include <stdbool.h>
// already included above
// #include "numpy/ndarrayobject.h"
// already included above
// #include "rosidl_runtime_c/visibility_control.h"
// already included above
// #include "turtlesim/srv/detail/teleport_relative__struct.h"
// already included above
// #include "turtlesim/srv/detail/teleport_relative__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool turtlesim__srv__teleport_relative__response__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[59];
{
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("turtlesim.srv._teleport_relative.TeleportRelative_Response", full_classname_dest, 58) == 0);
}
turtlesim__srv__TeleportRelative_Response * ros_message = _ros_message;
ros_message->structure_needs_at_least_one_member = 0;
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * turtlesim__srv__teleport_relative__response__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of TeleportRelative_Response */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("turtlesim.srv._teleport_relative");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "TeleportRelative_Response");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
(void)raw_ros_message;
// ownership of _pymessage is transferred to the caller
return _pymessage;
}