克隆后还缺仿真安装树和两边的编译目录。把 build、build_sim、install_sim 一并放进仓库;仿真入口不再写死本机 conda,build 里指向源码的链接改成相对路径。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3
@@ -0,0 +1,3 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: arm_msgs
|
||||
Version: 0.1.0
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
setup.py
|
||||
arm_msgs/__init__.py
|
||||
arm_msgs.egg-info/PKG-INFO
|
||||
arm_msgs.egg-info/SOURCES.txt
|
||||
arm_msgs.egg-info/dependency_links.txt
|
||||
arm_msgs.egg-info/top_level.txt
|
||||
arm_msgs/action/__init__.py
|
||||
arm_msgs/action/_compliant_descent.py
|
||||
arm_msgs/action/_follow_joint_trajectory.py
|
||||
arm_msgs/action/_move_to_pose.py
|
||||
arm_msgs/msg/__init__.py
|
||||
arm_msgs/msg/_arm_status.py
|
||||
arm_msgs/msg/_gripper_command.py
|
||||
arm_msgs/msg/_gripper_status.py
|
||||
arm_msgs/msg/_hole_detection.py
|
||||
arm_msgs/msg/_hole_detections.py
|
||||
arm_msgs/msg/_joint_command.py
|
||||
arm_msgs/msg/_tactile_status.py
|
||||
arm_msgs/srv/__init__.py
|
||||
arm_msgs/srv/_get_arm_state.py
|
||||
arm_msgs/srv/_gripper_execute.py
|
||||
arm_msgs/srv/_set_named_pose.py
|
||||
arm_msgs/srv/_switch_tool.py
|
||||
+1
@@ -0,0 +1 @@
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
arm_msgs
|
||||
+6202
File diff suppressed because it is too large
Load Diff
+6202
File diff suppressed because it is too large
Load Diff
+6202
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
from arm_msgs.action._compliant_descent import CompliantDescent # noqa: F401
|
||||
from arm_msgs.action._follow_joint_trajectory import FollowJointTrajectory # noqa: F401
|
||||
from arm_msgs.action._move_to_pose import MoveToPose # noqa: F401
|
||||
+1650
File diff suppressed because it is too large
Load Diff
+1338
File diff suppressed because it is too large
Load Diff
+1472
File diff suppressed because it is too large
Load Diff
+1452
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
from arm_msgs.msg._arm_status import ArmStatus # noqa: F401
|
||||
from arm_msgs.msg._gripper_command import GripperCommand # noqa: F401
|
||||
from arm_msgs.msg._gripper_status import GripperStatus # noqa: F401
|
||||
from arm_msgs.msg._hole_detection import HoleDetection # noqa: F401
|
||||
from arm_msgs.msg._hole_detections import HoleDetections # noqa: F401
|
||||
from arm_msgs.msg._joint_command import JointCommand # noqa: F401
|
||||
from arm_msgs.msg._tactile_status import TactileStatus # noqa: F401
|
||||
@@ -0,0 +1,305 @@
|
||||
# generated from rosidl_generator_py/resource/_idl.py.em
|
||||
# with input from arm_msgs:msg/ArmStatus.idl
|
||||
# generated code does not contain a copyright notice
|
||||
|
||||
|
||||
# Import statements for member types
|
||||
|
||||
# Member 'joint_positions'
|
||||
# Member 'joint_velocities'
|
||||
import array # noqa: E402, I100
|
||||
|
||||
import builtins # noqa: E402, I100
|
||||
|
||||
import math # noqa: E402, I100
|
||||
|
||||
import rosidl_parser.definition # noqa: E402, I100
|
||||
|
||||
|
||||
class Metaclass_ArmStatus(type):
|
||||
"""Metaclass of message 'ArmStatus'."""
|
||||
|
||||
_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.msg.ArmStatus')
|
||||
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__arm_status
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__arm_status
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__arm_status
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__msg__arm_status
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__arm_status
|
||||
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
if PoseStamped.__class__._TYPE_SUPPORT is None:
|
||||
PoseStamped.__class__.__import_type_support__()
|
||||
|
||||
from std_msgs.msg import Header
|
||||
if Header.__class__._TYPE_SUPPORT is None:
|
||||
Header.__class__.__import_type_support__()
|
||||
|
||||
@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 ArmStatus(metaclass=Metaclass_ArmStatus):
|
||||
"""Message class 'ArmStatus'."""
|
||||
|
||||
__slots__ = [
|
||||
'_header',
|
||||
'_mode',
|
||||
'_is_moving',
|
||||
'_is_homed',
|
||||
'_joint_positions',
|
||||
'_joint_velocities',
|
||||
'_ee_pose',
|
||||
'_error_message',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'header': 'std_msgs/Header',
|
||||
'mode': 'string',
|
||||
'is_moving': 'boolean',
|
||||
'is_homed': 'boolean',
|
||||
'joint_positions': 'sequence<double>',
|
||||
'joint_velocities': 'sequence<double>',
|
||||
'ee_pose': 'geometry_msgs/PoseStamped',
|
||||
'error_message': 'string',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.NamespacedType(['std_msgs', 'msg'], 'Header'), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedSequence(rosidl_parser.definition.BasicType('double')), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedSequence(rosidl_parser.definition.BasicType('double')), # noqa: E501
|
||||
rosidl_parser.definition.NamespacedType(['geometry_msgs', 'msg'], 'PoseStamped'), # 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__))
|
||||
from std_msgs.msg import Header
|
||||
self.header = kwargs.get('header', Header())
|
||||
self.mode = kwargs.get('mode', str())
|
||||
self.is_moving = kwargs.get('is_moving', bool())
|
||||
self.is_homed = kwargs.get('is_homed', bool())
|
||||
self.joint_positions = array.array('d', kwargs.get('joint_positions', []))
|
||||
self.joint_velocities = array.array('d', kwargs.get('joint_velocities', []))
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
self.ee_pose = kwargs.get('ee_pose', PoseStamped())
|
||||
self.error_message = kwargs.get('error_message', 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.header != other.header:
|
||||
return False
|
||||
if self.mode != other.mode:
|
||||
return False
|
||||
if self.is_moving != other.is_moving:
|
||||
return False
|
||||
if self.is_homed != other.is_homed:
|
||||
return False
|
||||
if self.joint_positions != other.joint_positions:
|
||||
return False
|
||||
if self.joint_velocities != other.joint_velocities:
|
||||
return False
|
||||
if self.ee_pose != other.ee_pose:
|
||||
return False
|
||||
if self.error_message != other.error_message:
|
||||
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 header(self):
|
||||
"""Message field 'header'."""
|
||||
return self._header
|
||||
|
||||
@header.setter
|
||||
def header(self, value):
|
||||
if __debug__:
|
||||
from std_msgs.msg import Header
|
||||
assert \
|
||||
isinstance(value, Header), \
|
||||
"The 'header' field must be a sub message of type 'Header'"
|
||||
self._header = value
|
||||
|
||||
@builtins.property
|
||||
def mode(self):
|
||||
"""Message field 'mode'."""
|
||||
return self._mode
|
||||
|
||||
@mode.setter
|
||||
def mode(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'mode' field must be of type 'str'"
|
||||
self._mode = value
|
||||
|
||||
@builtins.property
|
||||
def is_moving(self):
|
||||
"""Message field 'is_moving'."""
|
||||
return self._is_moving
|
||||
|
||||
@is_moving.setter
|
||||
def is_moving(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'is_moving' field must be of type 'bool'"
|
||||
self._is_moving = value
|
||||
|
||||
@builtins.property
|
||||
def is_homed(self):
|
||||
"""Message field 'is_homed'."""
|
||||
return self._is_homed
|
||||
|
||||
@is_homed.setter
|
||||
def is_homed(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'is_homed' field must be of type 'bool'"
|
||||
self._is_homed = value
|
||||
|
||||
@builtins.property
|
||||
def joint_positions(self):
|
||||
"""Message field 'joint_positions'."""
|
||||
return self._joint_positions
|
||||
|
||||
@joint_positions.setter
|
||||
def joint_positions(self, value):
|
||||
if isinstance(value, array.array):
|
||||
assert value.typecode == 'd', \
|
||||
"The 'joint_positions' array.array() must have the type code of 'd'"
|
||||
self._joint_positions = value
|
||||
return
|
||||
if __debug__:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Set
|
||||
from collections import UserList
|
||||
from collections import UserString
|
||||
assert \
|
||||
((isinstance(value, Sequence) or
|
||||
isinstance(value, Set) or
|
||||
isinstance(value, UserList)) and
|
||||
not isinstance(value, str) and
|
||||
not isinstance(value, UserString) and
|
||||
all(isinstance(v, float) for v in value) and
|
||||
all(not (val < -1.7976931348623157e+308 or val > 1.7976931348623157e+308) or math.isinf(val) for val in value)), \
|
||||
"The 'joint_positions' field must be a set or sequence and each value of type 'float' and each double in [-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]"
|
||||
self._joint_positions = array.array('d', value)
|
||||
|
||||
@builtins.property
|
||||
def joint_velocities(self):
|
||||
"""Message field 'joint_velocities'."""
|
||||
return self._joint_velocities
|
||||
|
||||
@joint_velocities.setter
|
||||
def joint_velocities(self, value):
|
||||
if isinstance(value, array.array):
|
||||
assert value.typecode == 'd', \
|
||||
"The 'joint_velocities' array.array() must have the type code of 'd'"
|
||||
self._joint_velocities = value
|
||||
return
|
||||
if __debug__:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Set
|
||||
from collections import UserList
|
||||
from collections import UserString
|
||||
assert \
|
||||
((isinstance(value, Sequence) or
|
||||
isinstance(value, Set) or
|
||||
isinstance(value, UserList)) and
|
||||
not isinstance(value, str) and
|
||||
not isinstance(value, UserString) and
|
||||
all(isinstance(v, float) for v in value) and
|
||||
all(not (val < -1.7976931348623157e+308 or val > 1.7976931348623157e+308) or math.isinf(val) for val in value)), \
|
||||
"The 'joint_velocities' field must be a set or sequence and each value of type 'float' and each double in [-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]"
|
||||
self._joint_velocities = array.array('d', value)
|
||||
|
||||
@builtins.property
|
||||
def ee_pose(self):
|
||||
"""Message field 'ee_pose'."""
|
||||
return self._ee_pose
|
||||
|
||||
@ee_pose.setter
|
||||
def ee_pose(self, value):
|
||||
if __debug__:
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
assert \
|
||||
isinstance(value, PoseStamped), \
|
||||
"The 'ee_pose' field must be a sub message of type 'PoseStamped'"
|
||||
self._ee_pose = value
|
||||
|
||||
@builtins.property
|
||||
def error_message(self):
|
||||
"""Message field 'error_message'."""
|
||||
return self._error_message
|
||||
|
||||
@error_message.setter
|
||||
def error_message(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'error_message' field must be of type 'str'"
|
||||
self._error_message = value
|
||||
@@ -0,0 +1,484 @@
|
||||
// generated from rosidl_generator_py/resource/_idl_support.c.em
|
||||
// with input from arm_msgs:msg/ArmStatus.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 "arm_msgs/msg/detail/arm_status__struct.h"
|
||||
#include "arm_msgs/msg/detail/arm_status__functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/string.h"
|
||||
#include "rosidl_runtime_c/string_functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/primitives_sequence.h"
|
||||
#include "rosidl_runtime_c/primitives_sequence_functions.h"
|
||||
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
bool std_msgs__msg__header__convert_from_py(PyObject * _pymsg, void * _ros_message);
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
PyObject * std_msgs__msg__header__convert_to_py(void * raw_ros_message);
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
bool geometry_msgs__msg__pose_stamped__convert_from_py(PyObject * _pymsg, void * _ros_message);
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
PyObject * geometry_msgs__msg__pose_stamped__convert_to_py(void * raw_ros_message);
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__msg__arm_status__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("arm_msgs.msg._arm_status.ArmStatus", full_classname_dest, 34) == 0);
|
||||
}
|
||||
arm_msgs__msg__ArmStatus * ros_message = _ros_message;
|
||||
{ // header
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "header");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (!std_msgs__msg__header__convert_from_py(field, &ros_message->header)) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // mode
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "mode");
|
||||
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->mode, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // is_moving
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "is_moving");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->is_moving = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // is_homed
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "is_homed");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->is_homed = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // joint_positions
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "joint_positions");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (PyObject_CheckBuffer(field)) {
|
||||
// Optimization for converting arrays of primitives
|
||||
Py_buffer view;
|
||||
int rc = PyObject_GetBuffer(field, &view, PyBUF_SIMPLE);
|
||||
if (rc < 0) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = view.len / sizeof(double);
|
||||
if (!rosidl_runtime_c__double__Sequence__init(&(ros_message->joint_positions), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create double__Sequence ros_message");
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
double * dest = ros_message->joint_positions.data;
|
||||
rc = PyBuffer_ToContiguous(dest, &view, view.len, 'C');
|
||||
if (rc < 0) {
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
PyBuffer_Release(&view);
|
||||
} else {
|
||||
PyObject * seq_field = PySequence_Fast(field, "expected a sequence in 'joint_positions'");
|
||||
if (!seq_field) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = PySequence_Size(field);
|
||||
if (-1 == size) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
if (!rosidl_runtime_c__double__Sequence__init(&(ros_message->joint_positions), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create double__Sequence ros_message");
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
double * dest = ros_message->joint_positions.data;
|
||||
for (Py_ssize_t i = 0; i < size; ++i) {
|
||||
PyObject * item = PySequence_Fast_GET_ITEM(seq_field, i);
|
||||
if (!item) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(item));
|
||||
double tmp = PyFloat_AS_DOUBLE(item);
|
||||
memcpy(&dest[i], &tmp, sizeof(double));
|
||||
}
|
||||
Py_DECREF(seq_field);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // joint_velocities
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "joint_velocities");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (PyObject_CheckBuffer(field)) {
|
||||
// Optimization for converting arrays of primitives
|
||||
Py_buffer view;
|
||||
int rc = PyObject_GetBuffer(field, &view, PyBUF_SIMPLE);
|
||||
if (rc < 0) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = view.len / sizeof(double);
|
||||
if (!rosidl_runtime_c__double__Sequence__init(&(ros_message->joint_velocities), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create double__Sequence ros_message");
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
double * dest = ros_message->joint_velocities.data;
|
||||
rc = PyBuffer_ToContiguous(dest, &view, view.len, 'C');
|
||||
if (rc < 0) {
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
PyBuffer_Release(&view);
|
||||
} else {
|
||||
PyObject * seq_field = PySequence_Fast(field, "expected a sequence in 'joint_velocities'");
|
||||
if (!seq_field) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = PySequence_Size(field);
|
||||
if (-1 == size) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
if (!rosidl_runtime_c__double__Sequence__init(&(ros_message->joint_velocities), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create double__Sequence ros_message");
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
double * dest = ros_message->joint_velocities.data;
|
||||
for (Py_ssize_t i = 0; i < size; ++i) {
|
||||
PyObject * item = PySequence_Fast_GET_ITEM(seq_field, i);
|
||||
if (!item) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(item));
|
||||
double tmp = PyFloat_AS_DOUBLE(item);
|
||||
memcpy(&dest[i], &tmp, sizeof(double));
|
||||
}
|
||||
Py_DECREF(seq_field);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // ee_pose
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "ee_pose");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (!geometry_msgs__msg__pose_stamped__convert_from_py(field, &ros_message->ee_pose)) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // error_message
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "error_message");
|
||||
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->error_message, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__msg__arm_status__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of ArmStatus */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.msg._arm_status");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "ArmStatus");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__msg__ArmStatus * ros_message = (arm_msgs__msg__ArmStatus *)raw_ros_message;
|
||||
{ // header
|
||||
PyObject * field = NULL;
|
||||
field = std_msgs__msg__header__convert_to_py(&ros_message->header);
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "header", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // mode
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->mode.data,
|
||||
strlen(ros_message->mode.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "mode", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // is_moving
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->is_moving ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "is_moving", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // is_homed
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->is_homed ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "is_homed", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // joint_positions
|
||||
PyObject * field = NULL;
|
||||
field = PyObject_GetAttrString(_pymessage, "joint_positions");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
assert(field->ob_type != NULL);
|
||||
assert(field->ob_type->tp_name != NULL);
|
||||
assert(strcmp(field->ob_type->tp_name, "array.array") == 0);
|
||||
// ensure that itemsize matches the sizeof of the ROS message field
|
||||
PyObject * itemsize_attr = PyObject_GetAttrString(field, "itemsize");
|
||||
assert(itemsize_attr != NULL);
|
||||
size_t itemsize = PyLong_AsSize_t(itemsize_attr);
|
||||
Py_DECREF(itemsize_attr);
|
||||
if (itemsize != sizeof(double)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "itemsize doesn't match expectation");
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
// clear the array, poor approach to remove potential default values
|
||||
Py_ssize_t length = PyObject_Length(field);
|
||||
if (-1 == length) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
if (length > 0) {
|
||||
PyObject * pop = PyObject_GetAttrString(field, "pop");
|
||||
assert(pop != NULL);
|
||||
for (Py_ssize_t i = 0; i < length; ++i) {
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(pop, NULL);
|
||||
if (!ret) {
|
||||
Py_DECREF(pop);
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(pop);
|
||||
}
|
||||
if (ros_message->joint_positions.size > 0) {
|
||||
// populating the array.array using the frombytes method
|
||||
PyObject * frombytes = PyObject_GetAttrString(field, "frombytes");
|
||||
assert(frombytes != NULL);
|
||||
double * src = &(ros_message->joint_positions.data[0]);
|
||||
PyObject * data = PyBytes_FromStringAndSize((const char *)src, ros_message->joint_positions.size * sizeof(double));
|
||||
assert(data != NULL);
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(frombytes, data, NULL);
|
||||
Py_DECREF(data);
|
||||
Py_DECREF(frombytes);
|
||||
if (!ret) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // joint_velocities
|
||||
PyObject * field = NULL;
|
||||
field = PyObject_GetAttrString(_pymessage, "joint_velocities");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
assert(field->ob_type != NULL);
|
||||
assert(field->ob_type->tp_name != NULL);
|
||||
assert(strcmp(field->ob_type->tp_name, "array.array") == 0);
|
||||
// ensure that itemsize matches the sizeof of the ROS message field
|
||||
PyObject * itemsize_attr = PyObject_GetAttrString(field, "itemsize");
|
||||
assert(itemsize_attr != NULL);
|
||||
size_t itemsize = PyLong_AsSize_t(itemsize_attr);
|
||||
Py_DECREF(itemsize_attr);
|
||||
if (itemsize != sizeof(double)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "itemsize doesn't match expectation");
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
// clear the array, poor approach to remove potential default values
|
||||
Py_ssize_t length = PyObject_Length(field);
|
||||
if (-1 == length) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
if (length > 0) {
|
||||
PyObject * pop = PyObject_GetAttrString(field, "pop");
|
||||
assert(pop != NULL);
|
||||
for (Py_ssize_t i = 0; i < length; ++i) {
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(pop, NULL);
|
||||
if (!ret) {
|
||||
Py_DECREF(pop);
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(pop);
|
||||
}
|
||||
if (ros_message->joint_velocities.size > 0) {
|
||||
// populating the array.array using the frombytes method
|
||||
PyObject * frombytes = PyObject_GetAttrString(field, "frombytes");
|
||||
assert(frombytes != NULL);
|
||||
double * src = &(ros_message->joint_velocities.data[0]);
|
||||
PyObject * data = PyBytes_FromStringAndSize((const char *)src, ros_message->joint_velocities.size * sizeof(double));
|
||||
assert(data != NULL);
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(frombytes, data, NULL);
|
||||
Py_DECREF(data);
|
||||
Py_DECREF(frombytes);
|
||||
if (!ret) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // ee_pose
|
||||
PyObject * field = NULL;
|
||||
field = geometry_msgs__msg__pose_stamped__convert_to_py(&ros_message->ee_pose);
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "ee_pose", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // error_message
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->error_message.data,
|
||||
strlen(ros_message->error_message.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "error_message", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ownership of _pymessage is transferred to the caller
|
||||
return _pymessage;
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
# generated from rosidl_generator_py/resource/_idl.py.em
|
||||
# with input from arm_msgs:msg/GripperCommand.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_GripperCommand(type):
|
||||
"""Metaclass of message 'GripperCommand'."""
|
||||
|
||||
_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.msg.GripperCommand')
|
||||
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__gripper_command
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__gripper_command
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__gripper_command
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__msg__gripper_command
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__gripper_command
|
||||
|
||||
from std_msgs.msg import Header
|
||||
if Header.__class__._TYPE_SUPPORT is None:
|
||||
Header.__class__.__import_type_support__()
|
||||
|
||||
@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 GripperCommand(metaclass=Metaclass_GripperCommand):
|
||||
"""Message class 'GripperCommand'."""
|
||||
|
||||
__slots__ = [
|
||||
'_header',
|
||||
'_command',
|
||||
'_position',
|
||||
'_speed',
|
||||
'_force',
|
||||
'_wait_complete',
|
||||
'_timeout',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'header': 'std_msgs/Header',
|
||||
'command': 'string',
|
||||
'position': 'double',
|
||||
'speed': 'double',
|
||||
'force': 'double',
|
||||
'wait_complete': 'boolean',
|
||||
'timeout': 'double',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.NamespacedType(['std_msgs', 'msg'], 'Header'), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # 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__))
|
||||
from std_msgs.msg import Header
|
||||
self.header = kwargs.get('header', Header())
|
||||
self.command = kwargs.get('command', str())
|
||||
self.position = kwargs.get('position', float())
|
||||
self.speed = kwargs.get('speed', float())
|
||||
self.force = kwargs.get('force', float())
|
||||
self.wait_complete = kwargs.get('wait_complete', bool())
|
||||
self.timeout = kwargs.get('timeout', 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.header != other.header:
|
||||
return False
|
||||
if self.command != other.command:
|
||||
return False
|
||||
if self.position != other.position:
|
||||
return False
|
||||
if self.speed != other.speed:
|
||||
return False
|
||||
if self.force != other.force:
|
||||
return False
|
||||
if self.wait_complete != other.wait_complete:
|
||||
return False
|
||||
if self.timeout != other.timeout:
|
||||
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 header(self):
|
||||
"""Message field 'header'."""
|
||||
return self._header
|
||||
|
||||
@header.setter
|
||||
def header(self, value):
|
||||
if __debug__:
|
||||
from std_msgs.msg import Header
|
||||
assert \
|
||||
isinstance(value, Header), \
|
||||
"The 'header' field must be a sub message of type 'Header'"
|
||||
self._header = value
|
||||
|
||||
@builtins.property
|
||||
def command(self):
|
||||
"""Message field 'command'."""
|
||||
return self._command
|
||||
|
||||
@command.setter
|
||||
def command(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'command' field must be of type 'str'"
|
||||
self._command = value
|
||||
|
||||
@builtins.property
|
||||
def position(self):
|
||||
"""Message field 'position'."""
|
||||
return self._position
|
||||
|
||||
@position.setter
|
||||
def position(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'position' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'position' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._position = value
|
||||
|
||||
@builtins.property
|
||||
def speed(self):
|
||||
"""Message field 'speed'."""
|
||||
return self._speed
|
||||
|
||||
@speed.setter
|
||||
def speed(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'speed' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'speed' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._speed = value
|
||||
|
||||
@builtins.property
|
||||
def force(self):
|
||||
"""Message field 'force'."""
|
||||
return self._force
|
||||
|
||||
@force.setter
|
||||
def force(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'force' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'force' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._force = value
|
||||
|
||||
@builtins.property
|
||||
def wait_complete(self):
|
||||
"""Message field 'wait_complete'."""
|
||||
return self._wait_complete
|
||||
|
||||
@wait_complete.setter
|
||||
def wait_complete(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'wait_complete' field must be of type 'bool'"
|
||||
self._wait_complete = value
|
||||
|
||||
@builtins.property
|
||||
def timeout(self):
|
||||
"""Message field 'timeout'."""
|
||||
return self._timeout
|
||||
|
||||
@timeout.setter
|
||||
def timeout(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'timeout' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'timeout' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._timeout = value
|
||||
@@ -0,0 +1,242 @@
|
||||
// generated from rosidl_generator_py/resource/_idl_support.c.em
|
||||
// with input from arm_msgs:msg/GripperCommand.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 "arm_msgs/msg/detail/gripper_command__struct.h"
|
||||
#include "arm_msgs/msg/detail/gripper_command__functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/string.h"
|
||||
#include "rosidl_runtime_c/string_functions.h"
|
||||
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
bool std_msgs__msg__header__convert_from_py(PyObject * _pymsg, void * _ros_message);
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
PyObject * std_msgs__msg__header__convert_to_py(void * raw_ros_message);
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__msg__gripper_command__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[45];
|
||||
{
|
||||
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("arm_msgs.msg._gripper_command.GripperCommand", full_classname_dest, 44) == 0);
|
||||
}
|
||||
arm_msgs__msg__GripperCommand * ros_message = _ros_message;
|
||||
{ // header
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "header");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (!std_msgs__msg__header__convert_from_py(field, &ros_message->header)) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // command
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "command");
|
||||
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->command, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // position
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "position");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->position = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // speed
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "speed");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->speed = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // force
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "force");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->force = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // wait_complete
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "wait_complete");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->wait_complete = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // timeout
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "timeout");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->timeout = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__msg__gripper_command__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of GripperCommand */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.msg._gripper_command");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "GripperCommand");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__msg__GripperCommand * ros_message = (arm_msgs__msg__GripperCommand *)raw_ros_message;
|
||||
{ // header
|
||||
PyObject * field = NULL;
|
||||
field = std_msgs__msg__header__convert_to_py(&ros_message->header);
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "header", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // command
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->command.data,
|
||||
strlen(ros_message->command.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "command", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // position
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->position);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "position", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // speed
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->speed);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "speed", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // force
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->force);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "force", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // wait_complete
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->wait_complete ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "wait_complete", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // timeout
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->timeout);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "timeout", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ownership of _pymessage is transferred to the caller
|
||||
return _pymessage;
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
# generated from rosidl_generator_py/resource/_idl.py.em
|
||||
# with input from arm_msgs:msg/GripperStatus.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_GripperStatus(type):
|
||||
"""Metaclass of message 'GripperStatus'."""
|
||||
|
||||
_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.msg.GripperStatus')
|
||||
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__gripper_status
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__gripper_status
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__gripper_status
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__msg__gripper_status
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__gripper_status
|
||||
|
||||
from std_msgs.msg import Header
|
||||
if Header.__class__._TYPE_SUPPORT is None:
|
||||
Header.__class__.__import_type_support__()
|
||||
|
||||
@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 GripperStatus(metaclass=Metaclass_GripperStatus):
|
||||
"""Message class 'GripperStatus'."""
|
||||
|
||||
__slots__ = [
|
||||
'_header',
|
||||
'_name',
|
||||
'_gripper_type',
|
||||
'_state',
|
||||
'_connected',
|
||||
'_initialized',
|
||||
'_is_moving',
|
||||
'_is_gripped',
|
||||
'_position',
|
||||
'_finger_position_per_mille',
|
||||
'_rotation_deg',
|
||||
'_gripper_state',
|
||||
'_rotation_state',
|
||||
'_velocity',
|
||||
'_force',
|
||||
'_error_msg',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'header': 'std_msgs/Header',
|
||||
'name': 'string',
|
||||
'gripper_type': 'string',
|
||||
'state': 'string',
|
||||
'connected': 'boolean',
|
||||
'initialized': 'boolean',
|
||||
'is_moving': 'boolean',
|
||||
'is_gripped': 'boolean',
|
||||
'position': 'double',
|
||||
'finger_position_per_mille': 'double',
|
||||
'rotation_deg': 'double',
|
||||
'gripper_state': 'int32',
|
||||
'rotation_state': 'int32',
|
||||
'velocity': 'double',
|
||||
'force': 'double',
|
||||
'error_msg': 'string',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.NamespacedType(['std_msgs', 'msg'], 'Header'), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('int32'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('int32'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # 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__))
|
||||
from std_msgs.msg import Header
|
||||
self.header = kwargs.get('header', Header())
|
||||
self.name = kwargs.get('name', str())
|
||||
self.gripper_type = kwargs.get('gripper_type', str())
|
||||
self.state = kwargs.get('state', str())
|
||||
self.connected = kwargs.get('connected', bool())
|
||||
self.initialized = kwargs.get('initialized', bool())
|
||||
self.is_moving = kwargs.get('is_moving', bool())
|
||||
self.is_gripped = kwargs.get('is_gripped', bool())
|
||||
self.position = kwargs.get('position', float())
|
||||
self.finger_position_per_mille = kwargs.get('finger_position_per_mille', float())
|
||||
self.rotation_deg = kwargs.get('rotation_deg', float())
|
||||
self.gripper_state = kwargs.get('gripper_state', int())
|
||||
self.rotation_state = kwargs.get('rotation_state', int())
|
||||
self.velocity = kwargs.get('velocity', float())
|
||||
self.force = kwargs.get('force', float())
|
||||
self.error_msg = kwargs.get('error_msg', 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.header != other.header:
|
||||
return False
|
||||
if self.name != other.name:
|
||||
return False
|
||||
if self.gripper_type != other.gripper_type:
|
||||
return False
|
||||
if self.state != other.state:
|
||||
return False
|
||||
if self.connected != other.connected:
|
||||
return False
|
||||
if self.initialized != other.initialized:
|
||||
return False
|
||||
if self.is_moving != other.is_moving:
|
||||
return False
|
||||
if self.is_gripped != other.is_gripped:
|
||||
return False
|
||||
if self.position != other.position:
|
||||
return False
|
||||
if self.finger_position_per_mille != other.finger_position_per_mille:
|
||||
return False
|
||||
if self.rotation_deg != other.rotation_deg:
|
||||
return False
|
||||
if self.gripper_state != other.gripper_state:
|
||||
return False
|
||||
if self.rotation_state != other.rotation_state:
|
||||
return False
|
||||
if self.velocity != other.velocity:
|
||||
return False
|
||||
if self.force != other.force:
|
||||
return False
|
||||
if self.error_msg != other.error_msg:
|
||||
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 header(self):
|
||||
"""Message field 'header'."""
|
||||
return self._header
|
||||
|
||||
@header.setter
|
||||
def header(self, value):
|
||||
if __debug__:
|
||||
from std_msgs.msg import Header
|
||||
assert \
|
||||
isinstance(value, Header), \
|
||||
"The 'header' field must be a sub message of type 'Header'"
|
||||
self._header = 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
|
||||
|
||||
@builtins.property
|
||||
def gripper_type(self):
|
||||
"""Message field 'gripper_type'."""
|
||||
return self._gripper_type
|
||||
|
||||
@gripper_type.setter
|
||||
def gripper_type(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'gripper_type' field must be of type 'str'"
|
||||
self._gripper_type = value
|
||||
|
||||
@builtins.property
|
||||
def state(self):
|
||||
"""Message field 'state'."""
|
||||
return self._state
|
||||
|
||||
@state.setter
|
||||
def state(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'state' field must be of type 'str'"
|
||||
self._state = value
|
||||
|
||||
@builtins.property
|
||||
def connected(self):
|
||||
"""Message field 'connected'."""
|
||||
return self._connected
|
||||
|
||||
@connected.setter
|
||||
def connected(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'connected' field must be of type 'bool'"
|
||||
self._connected = value
|
||||
|
||||
@builtins.property
|
||||
def initialized(self):
|
||||
"""Message field 'initialized'."""
|
||||
return self._initialized
|
||||
|
||||
@initialized.setter
|
||||
def initialized(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'initialized' field must be of type 'bool'"
|
||||
self._initialized = value
|
||||
|
||||
@builtins.property
|
||||
def is_moving(self):
|
||||
"""Message field 'is_moving'."""
|
||||
return self._is_moving
|
||||
|
||||
@is_moving.setter
|
||||
def is_moving(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'is_moving' field must be of type 'bool'"
|
||||
self._is_moving = value
|
||||
|
||||
@builtins.property
|
||||
def is_gripped(self):
|
||||
"""Message field 'is_gripped'."""
|
||||
return self._is_gripped
|
||||
|
||||
@is_gripped.setter
|
||||
def is_gripped(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'is_gripped' field must be of type 'bool'"
|
||||
self._is_gripped = value
|
||||
|
||||
@builtins.property
|
||||
def position(self):
|
||||
"""Message field 'position'."""
|
||||
return self._position
|
||||
|
||||
@position.setter
|
||||
def position(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'position' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'position' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._position = value
|
||||
|
||||
@builtins.property
|
||||
def finger_position_per_mille(self):
|
||||
"""Message field 'finger_position_per_mille'."""
|
||||
return self._finger_position_per_mille
|
||||
|
||||
@finger_position_per_mille.setter
|
||||
def finger_position_per_mille(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'finger_position_per_mille' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'finger_position_per_mille' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._finger_position_per_mille = value
|
||||
|
||||
@builtins.property
|
||||
def rotation_deg(self):
|
||||
"""Message field 'rotation_deg'."""
|
||||
return self._rotation_deg
|
||||
|
||||
@rotation_deg.setter
|
||||
def rotation_deg(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'rotation_deg' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'rotation_deg' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._rotation_deg = value
|
||||
|
||||
@builtins.property
|
||||
def gripper_state(self):
|
||||
"""Message field 'gripper_state'."""
|
||||
return self._gripper_state
|
||||
|
||||
@gripper_state.setter
|
||||
def gripper_state(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, int), \
|
||||
"The 'gripper_state' field must be of type 'int'"
|
||||
assert value >= -2147483648 and value < 2147483648, \
|
||||
"The 'gripper_state' field must be an integer in [-2147483648, 2147483647]"
|
||||
self._gripper_state = value
|
||||
|
||||
@builtins.property
|
||||
def rotation_state(self):
|
||||
"""Message field 'rotation_state'."""
|
||||
return self._rotation_state
|
||||
|
||||
@rotation_state.setter
|
||||
def rotation_state(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, int), \
|
||||
"The 'rotation_state' field must be of type 'int'"
|
||||
assert value >= -2147483648 and value < 2147483648, \
|
||||
"The 'rotation_state' field must be an integer in [-2147483648, 2147483647]"
|
||||
self._rotation_state = value
|
||||
|
||||
@builtins.property
|
||||
def velocity(self):
|
||||
"""Message field 'velocity'."""
|
||||
return self._velocity
|
||||
|
||||
@velocity.setter
|
||||
def velocity(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'velocity' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'velocity' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._velocity = value
|
||||
|
||||
@builtins.property
|
||||
def force(self):
|
||||
"""Message field 'force'."""
|
||||
return self._force
|
||||
|
||||
@force.setter
|
||||
def force(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'force' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'force' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._force = value
|
||||
|
||||
@builtins.property
|
||||
def error_msg(self):
|
||||
"""Message field 'error_msg'."""
|
||||
return self._error_msg
|
||||
|
||||
@error_msg.setter
|
||||
def error_msg(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'error_msg' field must be of type 'str'"
|
||||
self._error_msg = value
|
||||
@@ -0,0 +1,458 @@
|
||||
// generated from rosidl_generator_py/resource/_idl_support.c.em
|
||||
// with input from arm_msgs:msg/GripperStatus.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 "arm_msgs/msg/detail/gripper_status__struct.h"
|
||||
#include "arm_msgs/msg/detail/gripper_status__functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/string.h"
|
||||
#include "rosidl_runtime_c/string_functions.h"
|
||||
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
bool std_msgs__msg__header__convert_from_py(PyObject * _pymsg, void * _ros_message);
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
PyObject * std_msgs__msg__header__convert_to_py(void * raw_ros_message);
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__msg__gripper_status__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[43];
|
||||
{
|
||||
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("arm_msgs.msg._gripper_status.GripperStatus", full_classname_dest, 42) == 0);
|
||||
}
|
||||
arm_msgs__msg__GripperStatus * ros_message = _ros_message;
|
||||
{ // header
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "header");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (!std_msgs__msg__header__convert_from_py(field, &ros_message->header)) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
}
|
||||
{ // gripper_type
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "gripper_type");
|
||||
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->gripper_type, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // state
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "state");
|
||||
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->state, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // connected
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "connected");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->connected = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // initialized
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "initialized");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->initialized = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // is_moving
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "is_moving");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->is_moving = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // is_gripped
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "is_gripped");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->is_gripped = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // position
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "position");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->position = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // finger_position_per_mille
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "finger_position_per_mille");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->finger_position_per_mille = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // rotation_deg
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "rotation_deg");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->rotation_deg = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // gripper_state
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "gripper_state");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyLong_Check(field));
|
||||
ros_message->gripper_state = (int32_t)PyLong_AsLong(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // rotation_state
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "rotation_state");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyLong_Check(field));
|
||||
ros_message->rotation_state = (int32_t)PyLong_AsLong(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // velocity
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "velocity");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->velocity = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // force
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "force");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->force = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // error_msg
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "error_msg");
|
||||
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->error_msg, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__msg__gripper_status__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of GripperStatus */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.msg._gripper_status");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "GripperStatus");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__msg__GripperStatus * ros_message = (arm_msgs__msg__GripperStatus *)raw_ros_message;
|
||||
{ // header
|
||||
PyObject * field = NULL;
|
||||
field = std_msgs__msg__header__convert_to_py(&ros_message->header);
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "header", 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // gripper_type
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->gripper_type.data,
|
||||
strlen(ros_message->gripper_type.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "gripper_type", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // state
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->state.data,
|
||||
strlen(ros_message->state.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "state", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // connected
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->connected ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "connected", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // initialized
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->initialized ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "initialized", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // is_moving
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->is_moving ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "is_moving", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // is_gripped
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->is_gripped ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "is_gripped", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // position
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->position);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "position", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // finger_position_per_mille
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->finger_position_per_mille);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "finger_position_per_mille", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // rotation_deg
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->rotation_deg);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "rotation_deg", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // gripper_state
|
||||
PyObject * field = NULL;
|
||||
field = PyLong_FromLong(ros_message->gripper_state);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "gripper_state", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // rotation_state
|
||||
PyObject * field = NULL;
|
||||
field = PyLong_FromLong(ros_message->rotation_state);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "rotation_state", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // velocity
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->velocity);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "velocity", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // force
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->force);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "force", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // error_msg
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->error_msg.data,
|
||||
strlen(ros_message->error_msg.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "error_msg", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ownership of _pymessage is transferred to the caller
|
||||
return _pymessage;
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
# generated from rosidl_generator_py/resource/_idl.py.em
|
||||
# with input from arm_msgs:msg/HoleDetection.idl
|
||||
# generated code does not contain a copyright notice
|
||||
|
||||
|
||||
# Import statements for member types
|
||||
|
||||
# Member 'bbox'
|
||||
import array # noqa: E402, I100
|
||||
|
||||
import builtins # noqa: E402, I100
|
||||
|
||||
import math # noqa: E402, I100
|
||||
|
||||
import rosidl_parser.definition # noqa: E402, I100
|
||||
|
||||
|
||||
class Metaclass_HoleDetection(type):
|
||||
"""Metaclass of message 'HoleDetection'."""
|
||||
|
||||
_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.msg.HoleDetection')
|
||||
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__hole_detection
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__hole_detection
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__hole_detection
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__msg__hole_detection
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__hole_detection
|
||||
|
||||
@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 HoleDetection(metaclass=Metaclass_HoleDetection):
|
||||
"""Message class 'HoleDetection'."""
|
||||
|
||||
__slots__ = [
|
||||
'_u',
|
||||
'_v',
|
||||
'_radius_px',
|
||||
'_confidence',
|
||||
'_label',
|
||||
'_bbox',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'u': 'float',
|
||||
'v': 'float',
|
||||
'radius_px': 'float',
|
||||
'confidence': 'float',
|
||||
'label': 'string',
|
||||
'bbox': 'sequence<int32>',
|
||||
}
|
||||
|
||||
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.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedSequence(rosidl_parser.definition.BasicType('int32')), # 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.u = kwargs.get('u', float())
|
||||
self.v = kwargs.get('v', float())
|
||||
self.radius_px = kwargs.get('radius_px', float())
|
||||
self.confidence = kwargs.get('confidence', float())
|
||||
self.label = kwargs.get('label', str())
|
||||
self.bbox = array.array('i', kwargs.get('bbox', []))
|
||||
|
||||
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.u != other.u:
|
||||
return False
|
||||
if self.v != other.v:
|
||||
return False
|
||||
if self.radius_px != other.radius_px:
|
||||
return False
|
||||
if self.confidence != other.confidence:
|
||||
return False
|
||||
if self.label != other.label:
|
||||
return False
|
||||
if self.bbox != other.bbox:
|
||||
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 u(self):
|
||||
"""Message field 'u'."""
|
||||
return self._u
|
||||
|
||||
@u.setter
|
||||
def u(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'u' field must be of type 'float'"
|
||||
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
|
||||
"The 'u' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
|
||||
self._u = value
|
||||
|
||||
@builtins.property
|
||||
def v(self):
|
||||
"""Message field 'v'."""
|
||||
return self._v
|
||||
|
||||
@v.setter
|
||||
def v(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'v' field must be of type 'float'"
|
||||
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
|
||||
"The 'v' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
|
||||
self._v = value
|
||||
|
||||
@builtins.property
|
||||
def radius_px(self):
|
||||
"""Message field 'radius_px'."""
|
||||
return self._radius_px
|
||||
|
||||
@radius_px.setter
|
||||
def radius_px(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'radius_px' field must be of type 'float'"
|
||||
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
|
||||
"The 'radius_px' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
|
||||
self._radius_px = value
|
||||
|
||||
@builtins.property
|
||||
def confidence(self):
|
||||
"""Message field 'confidence'."""
|
||||
return self._confidence
|
||||
|
||||
@confidence.setter
|
||||
def confidence(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'confidence' field must be of type 'float'"
|
||||
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
|
||||
"The 'confidence' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
|
||||
self._confidence = value
|
||||
|
||||
@builtins.property
|
||||
def label(self):
|
||||
"""Message field 'label'."""
|
||||
return self._label
|
||||
|
||||
@label.setter
|
||||
def label(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'label' field must be of type 'str'"
|
||||
self._label = value
|
||||
|
||||
@builtins.property
|
||||
def bbox(self):
|
||||
"""Message field 'bbox'."""
|
||||
return self._bbox
|
||||
|
||||
@bbox.setter
|
||||
def bbox(self, value):
|
||||
if isinstance(value, array.array):
|
||||
assert value.typecode == 'i', \
|
||||
"The 'bbox' array.array() must have the type code of 'i'"
|
||||
self._bbox = value
|
||||
return
|
||||
if __debug__:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Set
|
||||
from collections import UserList
|
||||
from collections import UserString
|
||||
assert \
|
||||
((isinstance(value, Sequence) or
|
||||
isinstance(value, Set) or
|
||||
isinstance(value, UserList)) and
|
||||
not isinstance(value, str) and
|
||||
not isinstance(value, UserString) and
|
||||
all(isinstance(v, int) for v in value) and
|
||||
all(val >= -2147483648 and val < 2147483648 for val in value)), \
|
||||
"The 'bbox' field must be a set or sequence and each value of type 'int' and each integer in [-2147483648, 2147483647]"
|
||||
self._bbox = array.array('i', value)
|
||||
@@ -0,0 +1,315 @@
|
||||
// generated from rosidl_generator_py/resource/_idl_support.c.em
|
||||
// with input from arm_msgs:msg/HoleDetection.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 "arm_msgs/msg/detail/hole_detection__struct.h"
|
||||
#include "arm_msgs/msg/detail/hole_detection__functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/string.h"
|
||||
#include "rosidl_runtime_c/string_functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/primitives_sequence.h"
|
||||
#include "rosidl_runtime_c/primitives_sequence_functions.h"
|
||||
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__msg__hole_detection__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[43];
|
||||
{
|
||||
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("arm_msgs.msg._hole_detection.HoleDetection", full_classname_dest, 42) == 0);
|
||||
}
|
||||
arm_msgs__msg__HoleDetection * ros_message = _ros_message;
|
||||
{ // u
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "u");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->u = (float)PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // v
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "v");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->v = (float)PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // radius_px
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "radius_px");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->radius_px = (float)PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // confidence
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "confidence");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->confidence = (float)PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // label
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "label");
|
||||
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->label, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // bbox
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "bbox");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (PyObject_CheckBuffer(field)) {
|
||||
// Optimization for converting arrays of primitives
|
||||
Py_buffer view;
|
||||
int rc = PyObject_GetBuffer(field, &view, PyBUF_SIMPLE);
|
||||
if (rc < 0) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = view.len / sizeof(int32_t);
|
||||
if (!rosidl_runtime_c__int32__Sequence__init(&(ros_message->bbox), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create int32__Sequence ros_message");
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
int32_t * dest = ros_message->bbox.data;
|
||||
rc = PyBuffer_ToContiguous(dest, &view, view.len, 'C');
|
||||
if (rc < 0) {
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
PyBuffer_Release(&view);
|
||||
} else {
|
||||
PyObject * seq_field = PySequence_Fast(field, "expected a sequence in 'bbox'");
|
||||
if (!seq_field) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = PySequence_Size(field);
|
||||
if (-1 == size) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
if (!rosidl_runtime_c__int32__Sequence__init(&(ros_message->bbox), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create int32__Sequence ros_message");
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
int32_t * dest = ros_message->bbox.data;
|
||||
for (Py_ssize_t i = 0; i < size; ++i) {
|
||||
PyObject * item = PySequence_Fast_GET_ITEM(seq_field, i);
|
||||
if (!item) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
assert(PyLong_Check(item));
|
||||
int32_t tmp = (int32_t)PyLong_AsLong(item);
|
||||
memcpy(&dest[i], &tmp, sizeof(int32_t));
|
||||
}
|
||||
Py_DECREF(seq_field);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__msg__hole_detection__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of HoleDetection */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.msg._hole_detection");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "HoleDetection");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__msg__HoleDetection * ros_message = (arm_msgs__msg__HoleDetection *)raw_ros_message;
|
||||
{ // u
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->u);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "u", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // v
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->v);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "v", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // radius_px
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->radius_px);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "radius_px", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // confidence
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->confidence);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "confidence", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // label
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->label.data,
|
||||
strlen(ros_message->label.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "label", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // bbox
|
||||
PyObject * field = NULL;
|
||||
field = PyObject_GetAttrString(_pymessage, "bbox");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
assert(field->ob_type != NULL);
|
||||
assert(field->ob_type->tp_name != NULL);
|
||||
assert(strcmp(field->ob_type->tp_name, "array.array") == 0);
|
||||
// ensure that itemsize matches the sizeof of the ROS message field
|
||||
PyObject * itemsize_attr = PyObject_GetAttrString(field, "itemsize");
|
||||
assert(itemsize_attr != NULL);
|
||||
size_t itemsize = PyLong_AsSize_t(itemsize_attr);
|
||||
Py_DECREF(itemsize_attr);
|
||||
if (itemsize != sizeof(int32_t)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "itemsize doesn't match expectation");
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
// clear the array, poor approach to remove potential default values
|
||||
Py_ssize_t length = PyObject_Length(field);
|
||||
if (-1 == length) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
if (length > 0) {
|
||||
PyObject * pop = PyObject_GetAttrString(field, "pop");
|
||||
assert(pop != NULL);
|
||||
for (Py_ssize_t i = 0; i < length; ++i) {
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(pop, NULL);
|
||||
if (!ret) {
|
||||
Py_DECREF(pop);
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(pop);
|
||||
}
|
||||
if (ros_message->bbox.size > 0) {
|
||||
// populating the array.array using the frombytes method
|
||||
PyObject * frombytes = PyObject_GetAttrString(field, "frombytes");
|
||||
assert(frombytes != NULL);
|
||||
int32_t * src = &(ros_message->bbox.data[0]);
|
||||
PyObject * data = PyBytes_FromStringAndSize((const char *)src, ros_message->bbox.size * sizeof(int32_t));
|
||||
assert(data != NULL);
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(frombytes, data, NULL);
|
||||
Py_DECREF(data);
|
||||
Py_DECREF(frombytes);
|
||||
if (!ret) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
// ownership of _pymessage is transferred to the caller
|
||||
return _pymessage;
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
# generated from rosidl_generator_py/resource/_idl.py.em
|
||||
# with input from arm_msgs:msg/HoleDetections.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_HoleDetections(type):
|
||||
"""Metaclass of message 'HoleDetections'."""
|
||||
|
||||
_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.msg.HoleDetections')
|
||||
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__hole_detections
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__hole_detections
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__hole_detections
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__msg__hole_detections
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__hole_detections
|
||||
|
||||
from arm_msgs.msg import HoleDetection
|
||||
if HoleDetection.__class__._TYPE_SUPPORT is None:
|
||||
HoleDetection.__class__.__import_type_support__()
|
||||
|
||||
from std_msgs.msg import Header
|
||||
if Header.__class__._TYPE_SUPPORT is None:
|
||||
Header.__class__.__import_type_support__()
|
||||
|
||||
@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 HoleDetections(metaclass=Metaclass_HoleDetections):
|
||||
"""Message class 'HoleDetections'."""
|
||||
|
||||
__slots__ = [
|
||||
'_header',
|
||||
'_ok',
|
||||
'_message',
|
||||
'_holes',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'header': 'std_msgs/Header',
|
||||
'ok': 'boolean',
|
||||
'message': 'string',
|
||||
'holes': 'sequence<arm_msgs/HoleDetection>',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.NamespacedType(['std_msgs', 'msg'], 'Header'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedSequence(rosidl_parser.definition.NamespacedType(['arm_msgs', 'msg'], 'HoleDetection')), # 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__))
|
||||
from std_msgs.msg import Header
|
||||
self.header = kwargs.get('header', Header())
|
||||
self.ok = kwargs.get('ok', bool())
|
||||
self.message = kwargs.get('message', str())
|
||||
self.holes = kwargs.get('holes', [])
|
||||
|
||||
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.header != other.header:
|
||||
return False
|
||||
if self.ok != other.ok:
|
||||
return False
|
||||
if self.message != other.message:
|
||||
return False
|
||||
if self.holes != other.holes:
|
||||
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 header(self):
|
||||
"""Message field 'header'."""
|
||||
return self._header
|
||||
|
||||
@header.setter
|
||||
def header(self, value):
|
||||
if __debug__:
|
||||
from std_msgs.msg import Header
|
||||
assert \
|
||||
isinstance(value, Header), \
|
||||
"The 'header' field must be a sub message of type 'Header'"
|
||||
self._header = value
|
||||
|
||||
@builtins.property
|
||||
def ok(self):
|
||||
"""Message field 'ok'."""
|
||||
return self._ok
|
||||
|
||||
@ok.setter
|
||||
def ok(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'ok' field must be of type 'bool'"
|
||||
self._ok = value
|
||||
|
||||
@builtins.property
|
||||
def message(self):
|
||||
"""Message field 'message'."""
|
||||
return self._message
|
||||
|
||||
@message.setter
|
||||
def message(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'message' field must be of type 'str'"
|
||||
self._message = value
|
||||
|
||||
@builtins.property
|
||||
def holes(self):
|
||||
"""Message field 'holes'."""
|
||||
return self._holes
|
||||
|
||||
@holes.setter
|
||||
def holes(self, value):
|
||||
if __debug__:
|
||||
from arm_msgs.msg import HoleDetection
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Set
|
||||
from collections import UserList
|
||||
from collections import UserString
|
||||
assert \
|
||||
((isinstance(value, Sequence) or
|
||||
isinstance(value, Set) or
|
||||
isinstance(value, UserList)) and
|
||||
not isinstance(value, str) and
|
||||
not isinstance(value, UserString) and
|
||||
all(isinstance(v, HoleDetection) for v in value) and
|
||||
True), \
|
||||
"The 'holes' field must be a set or sequence and each value of type 'HoleDetection'"
|
||||
self._holes = value
|
||||
@@ -0,0 +1,231 @@
|
||||
// generated from rosidl_generator_py/resource/_idl_support.c.em
|
||||
// with input from arm_msgs:msg/HoleDetections.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 "arm_msgs/msg/detail/hole_detections__struct.h"
|
||||
#include "arm_msgs/msg/detail/hole_detections__functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/string.h"
|
||||
#include "rosidl_runtime_c/string_functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/primitives_sequence.h"
|
||||
#include "rosidl_runtime_c/primitives_sequence_functions.h"
|
||||
|
||||
// Nested array functions includes
|
||||
#include "arm_msgs/msg/detail/hole_detection__functions.h"
|
||||
// end nested array functions include
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
bool std_msgs__msg__header__convert_from_py(PyObject * _pymsg, void * _ros_message);
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
PyObject * std_msgs__msg__header__convert_to_py(void * raw_ros_message);
|
||||
bool arm_msgs__msg__hole_detection__convert_from_py(PyObject * _pymsg, void * _ros_message);
|
||||
PyObject * arm_msgs__msg__hole_detection__convert_to_py(void * raw_ros_message);
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__msg__hole_detections__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[45];
|
||||
{
|
||||
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("arm_msgs.msg._hole_detections.HoleDetections", full_classname_dest, 44) == 0);
|
||||
}
|
||||
arm_msgs__msg__HoleDetections * ros_message = _ros_message;
|
||||
{ // header
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "header");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (!std_msgs__msg__header__convert_from_py(field, &ros_message->header)) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // ok
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "ok");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->ok = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // message
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "message");
|
||||
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->message, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // holes
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "holes");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
PyObject * seq_field = PySequence_Fast(field, "expected a sequence in 'holes'");
|
||||
if (!seq_field) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = PySequence_Size(field);
|
||||
if (-1 == size) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
if (!arm_msgs__msg__HoleDetection__Sequence__init(&(ros_message->holes), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create arm_msgs__msg__HoleDetection__Sequence ros_message");
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
arm_msgs__msg__HoleDetection * dest = ros_message->holes.data;
|
||||
for (Py_ssize_t i = 0; i < size; ++i) {
|
||||
if (!arm_msgs__msg__hole_detection__convert_from_py(PySequence_Fast_GET_ITEM(seq_field, i), &dest[i])) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__msg__hole_detections__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of HoleDetections */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.msg._hole_detections");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "HoleDetections");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__msg__HoleDetections * ros_message = (arm_msgs__msg__HoleDetections *)raw_ros_message;
|
||||
{ // header
|
||||
PyObject * field = NULL;
|
||||
field = std_msgs__msg__header__convert_to_py(&ros_message->header);
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "header", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // ok
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->ok ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "ok", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // message
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->message.data,
|
||||
strlen(ros_message->message.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "message", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // holes
|
||||
PyObject * field = NULL;
|
||||
size_t size = ros_message->holes.size;
|
||||
field = PyList_New(size);
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
arm_msgs__msg__HoleDetection * item;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
item = &(ros_message->holes.data[i]);
|
||||
PyObject * pyitem = arm_msgs__msg__hole_detection__convert_to_py(item);
|
||||
if (!pyitem) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
int rc = PyList_SetItem(field, i, pyitem);
|
||||
(void)rc;
|
||||
assert(rc == 0);
|
||||
}
|
||||
assert(PySequence_Check(field));
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "holes", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ownership of _pymessage is transferred to the caller
|
||||
return _pymessage;
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
# generated from rosidl_generator_py/resource/_idl.py.em
|
||||
# with input from arm_msgs:msg/JointCommand.idl
|
||||
# generated code does not contain a copyright notice
|
||||
|
||||
|
||||
# Import statements for member types
|
||||
|
||||
# Member 'positions'
|
||||
# Member 'velocities'
|
||||
# Member 'accelerations'
|
||||
import array # noqa: E402, I100
|
||||
|
||||
import builtins # noqa: E402, I100
|
||||
|
||||
import math # noqa: E402, I100
|
||||
|
||||
import rosidl_parser.definition # noqa: E402, I100
|
||||
|
||||
|
||||
class Metaclass_JointCommand(type):
|
||||
"""Metaclass of message 'JointCommand'."""
|
||||
|
||||
_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.msg.JointCommand')
|
||||
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__joint_command
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__joint_command
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__joint_command
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__msg__joint_command
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__joint_command
|
||||
|
||||
from std_msgs.msg import Header
|
||||
if Header.__class__._TYPE_SUPPORT is None:
|
||||
Header.__class__.__import_type_support__()
|
||||
|
||||
@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 JointCommand(metaclass=Metaclass_JointCommand):
|
||||
"""Message class 'JointCommand'."""
|
||||
|
||||
__slots__ = [
|
||||
'_header',
|
||||
'_joint_names',
|
||||
'_positions',
|
||||
'_velocities',
|
||||
'_accelerations',
|
||||
'_time_from_start',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'header': 'std_msgs/Header',
|
||||
'joint_names': 'sequence<string>',
|
||||
'positions': 'sequence<double>',
|
||||
'velocities': 'sequence<double>',
|
||||
'accelerations': 'sequence<double>',
|
||||
'time_from_start': 'double',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.NamespacedType(['std_msgs', 'msg'], 'Header'), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedSequence(rosidl_parser.definition.UnboundedString()), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedSequence(rosidl_parser.definition.BasicType('double')), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedSequence(rosidl_parser.definition.BasicType('double')), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedSequence(rosidl_parser.definition.BasicType('double')), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # 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__))
|
||||
from std_msgs.msg import Header
|
||||
self.header = kwargs.get('header', Header())
|
||||
self.joint_names = kwargs.get('joint_names', [])
|
||||
self.positions = array.array('d', kwargs.get('positions', []))
|
||||
self.velocities = array.array('d', kwargs.get('velocities', []))
|
||||
self.accelerations = array.array('d', kwargs.get('accelerations', []))
|
||||
self.time_from_start = kwargs.get('time_from_start', 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.header != other.header:
|
||||
return False
|
||||
if self.joint_names != other.joint_names:
|
||||
return False
|
||||
if self.positions != other.positions:
|
||||
return False
|
||||
if self.velocities != other.velocities:
|
||||
return False
|
||||
if self.accelerations != other.accelerations:
|
||||
return False
|
||||
if self.time_from_start != other.time_from_start:
|
||||
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 header(self):
|
||||
"""Message field 'header'."""
|
||||
return self._header
|
||||
|
||||
@header.setter
|
||||
def header(self, value):
|
||||
if __debug__:
|
||||
from std_msgs.msg import Header
|
||||
assert \
|
||||
isinstance(value, Header), \
|
||||
"The 'header' field must be a sub message of type 'Header'"
|
||||
self._header = value
|
||||
|
||||
@builtins.property
|
||||
def joint_names(self):
|
||||
"""Message field 'joint_names'."""
|
||||
return self._joint_names
|
||||
|
||||
@joint_names.setter
|
||||
def joint_names(self, value):
|
||||
if __debug__:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Set
|
||||
from collections import UserList
|
||||
from collections import UserString
|
||||
assert \
|
||||
((isinstance(value, Sequence) or
|
||||
isinstance(value, Set) or
|
||||
isinstance(value, UserList)) and
|
||||
not isinstance(value, str) and
|
||||
not isinstance(value, UserString) and
|
||||
all(isinstance(v, str) for v in value) and
|
||||
True), \
|
||||
"The 'joint_names' field must be a set or sequence and each value of type 'str'"
|
||||
self._joint_names = value
|
||||
|
||||
@builtins.property
|
||||
def positions(self):
|
||||
"""Message field 'positions'."""
|
||||
return self._positions
|
||||
|
||||
@positions.setter
|
||||
def positions(self, value):
|
||||
if isinstance(value, array.array):
|
||||
assert value.typecode == 'd', \
|
||||
"The 'positions' array.array() must have the type code of 'd'"
|
||||
self._positions = value
|
||||
return
|
||||
if __debug__:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Set
|
||||
from collections import UserList
|
||||
from collections import UserString
|
||||
assert \
|
||||
((isinstance(value, Sequence) or
|
||||
isinstance(value, Set) or
|
||||
isinstance(value, UserList)) and
|
||||
not isinstance(value, str) and
|
||||
not isinstance(value, UserString) and
|
||||
all(isinstance(v, float) for v in value) and
|
||||
all(not (val < -1.7976931348623157e+308 or val > 1.7976931348623157e+308) or math.isinf(val) for val in value)), \
|
||||
"The 'positions' field must be a set or sequence and each value of type 'float' and each double in [-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]"
|
||||
self._positions = array.array('d', value)
|
||||
|
||||
@builtins.property
|
||||
def velocities(self):
|
||||
"""Message field 'velocities'."""
|
||||
return self._velocities
|
||||
|
||||
@velocities.setter
|
||||
def velocities(self, value):
|
||||
if isinstance(value, array.array):
|
||||
assert value.typecode == 'd', \
|
||||
"The 'velocities' array.array() must have the type code of 'd'"
|
||||
self._velocities = value
|
||||
return
|
||||
if __debug__:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Set
|
||||
from collections import UserList
|
||||
from collections import UserString
|
||||
assert \
|
||||
((isinstance(value, Sequence) or
|
||||
isinstance(value, Set) or
|
||||
isinstance(value, UserList)) and
|
||||
not isinstance(value, str) and
|
||||
not isinstance(value, UserString) and
|
||||
all(isinstance(v, float) for v in value) and
|
||||
all(not (val < -1.7976931348623157e+308 or val > 1.7976931348623157e+308) or math.isinf(val) for val in value)), \
|
||||
"The 'velocities' field must be a set or sequence and each value of type 'float' and each double in [-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]"
|
||||
self._velocities = array.array('d', value)
|
||||
|
||||
@builtins.property
|
||||
def accelerations(self):
|
||||
"""Message field 'accelerations'."""
|
||||
return self._accelerations
|
||||
|
||||
@accelerations.setter
|
||||
def accelerations(self, value):
|
||||
if isinstance(value, array.array):
|
||||
assert value.typecode == 'd', \
|
||||
"The 'accelerations' array.array() must have the type code of 'd'"
|
||||
self._accelerations = value
|
||||
return
|
||||
if __debug__:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Set
|
||||
from collections import UserList
|
||||
from collections import UserString
|
||||
assert \
|
||||
((isinstance(value, Sequence) or
|
||||
isinstance(value, Set) or
|
||||
isinstance(value, UserList)) and
|
||||
not isinstance(value, str) and
|
||||
not isinstance(value, UserString) and
|
||||
all(isinstance(v, float) for v in value) and
|
||||
all(not (val < -1.7976931348623157e+308 or val > 1.7976931348623157e+308) or math.isinf(val) for val in value)), \
|
||||
"The 'accelerations' field must be a set or sequence and each value of type 'float' and each double in [-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]"
|
||||
self._accelerations = array.array('d', value)
|
||||
|
||||
@builtins.property
|
||||
def time_from_start(self):
|
||||
"""Message field 'time_from_start'."""
|
||||
return self._time_from_start
|
||||
|
||||
@time_from_start.setter
|
||||
def time_from_start(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'time_from_start' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'time_from_start' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._time_from_start = value
|
||||
@@ -0,0 +1,560 @@
|
||||
// generated from rosidl_generator_py/resource/_idl_support.c.em
|
||||
// with input from arm_msgs:msg/JointCommand.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 "arm_msgs/msg/detail/joint_command__struct.h"
|
||||
#include "arm_msgs/msg/detail/joint_command__functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/primitives_sequence.h"
|
||||
#include "rosidl_runtime_c/primitives_sequence_functions.h"
|
||||
#include "rosidl_runtime_c/string.h"
|
||||
#include "rosidl_runtime_c/string_functions.h"
|
||||
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
bool std_msgs__msg__header__convert_from_py(PyObject * _pymsg, void * _ros_message);
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
PyObject * std_msgs__msg__header__convert_to_py(void * raw_ros_message);
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__msg__joint_command__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[41];
|
||||
{
|
||||
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("arm_msgs.msg._joint_command.JointCommand", full_classname_dest, 40) == 0);
|
||||
}
|
||||
arm_msgs__msg__JointCommand * ros_message = _ros_message;
|
||||
{ // header
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "header");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (!std_msgs__msg__header__convert_from_py(field, &ros_message->header)) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // joint_names
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "joint_names");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
{
|
||||
PyObject * seq_field = PySequence_Fast(field, "expected a sequence in 'joint_names'");
|
||||
if (!seq_field) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = PySequence_Size(field);
|
||||
if (-1 == size) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
if (!rosidl_runtime_c__String__Sequence__init(&(ros_message->joint_names), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create String__Sequence ros_message");
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
rosidl_runtime_c__String * dest = ros_message->joint_names.data;
|
||||
for (Py_ssize_t i = 0; i < size; ++i) {
|
||||
PyObject * item = PySequence_Fast_GET_ITEM(seq_field, i);
|
||||
if (!item) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
assert(PyUnicode_Check(item));
|
||||
PyObject * encoded_item = PyUnicode_AsUTF8String(item);
|
||||
if (!encoded_item) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
rosidl_runtime_c__String__assign(&dest[i], PyBytes_AS_STRING(encoded_item));
|
||||
Py_DECREF(encoded_item);
|
||||
}
|
||||
Py_DECREF(seq_field);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // positions
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "positions");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (PyObject_CheckBuffer(field)) {
|
||||
// Optimization for converting arrays of primitives
|
||||
Py_buffer view;
|
||||
int rc = PyObject_GetBuffer(field, &view, PyBUF_SIMPLE);
|
||||
if (rc < 0) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = view.len / sizeof(double);
|
||||
if (!rosidl_runtime_c__double__Sequence__init(&(ros_message->positions), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create double__Sequence ros_message");
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
double * dest = ros_message->positions.data;
|
||||
rc = PyBuffer_ToContiguous(dest, &view, view.len, 'C');
|
||||
if (rc < 0) {
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
PyBuffer_Release(&view);
|
||||
} else {
|
||||
PyObject * seq_field = PySequence_Fast(field, "expected a sequence in 'positions'");
|
||||
if (!seq_field) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = PySequence_Size(field);
|
||||
if (-1 == size) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
if (!rosidl_runtime_c__double__Sequence__init(&(ros_message->positions), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create double__Sequence ros_message");
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
double * dest = ros_message->positions.data;
|
||||
for (Py_ssize_t i = 0; i < size; ++i) {
|
||||
PyObject * item = PySequence_Fast_GET_ITEM(seq_field, i);
|
||||
if (!item) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(item));
|
||||
double tmp = PyFloat_AS_DOUBLE(item);
|
||||
memcpy(&dest[i], &tmp, sizeof(double));
|
||||
}
|
||||
Py_DECREF(seq_field);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // velocities
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "velocities");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (PyObject_CheckBuffer(field)) {
|
||||
// Optimization for converting arrays of primitives
|
||||
Py_buffer view;
|
||||
int rc = PyObject_GetBuffer(field, &view, PyBUF_SIMPLE);
|
||||
if (rc < 0) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = view.len / sizeof(double);
|
||||
if (!rosidl_runtime_c__double__Sequence__init(&(ros_message->velocities), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create double__Sequence ros_message");
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
double * dest = ros_message->velocities.data;
|
||||
rc = PyBuffer_ToContiguous(dest, &view, view.len, 'C');
|
||||
if (rc < 0) {
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
PyBuffer_Release(&view);
|
||||
} else {
|
||||
PyObject * seq_field = PySequence_Fast(field, "expected a sequence in 'velocities'");
|
||||
if (!seq_field) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = PySequence_Size(field);
|
||||
if (-1 == size) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
if (!rosidl_runtime_c__double__Sequence__init(&(ros_message->velocities), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create double__Sequence ros_message");
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
double * dest = ros_message->velocities.data;
|
||||
for (Py_ssize_t i = 0; i < size; ++i) {
|
||||
PyObject * item = PySequence_Fast_GET_ITEM(seq_field, i);
|
||||
if (!item) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(item));
|
||||
double tmp = PyFloat_AS_DOUBLE(item);
|
||||
memcpy(&dest[i], &tmp, sizeof(double));
|
||||
}
|
||||
Py_DECREF(seq_field);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // accelerations
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "accelerations");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (PyObject_CheckBuffer(field)) {
|
||||
// Optimization for converting arrays of primitives
|
||||
Py_buffer view;
|
||||
int rc = PyObject_GetBuffer(field, &view, PyBUF_SIMPLE);
|
||||
if (rc < 0) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = view.len / sizeof(double);
|
||||
if (!rosidl_runtime_c__double__Sequence__init(&(ros_message->accelerations), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create double__Sequence ros_message");
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
double * dest = ros_message->accelerations.data;
|
||||
rc = PyBuffer_ToContiguous(dest, &view, view.len, 'C');
|
||||
if (rc < 0) {
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
PyBuffer_Release(&view);
|
||||
} else {
|
||||
PyObject * seq_field = PySequence_Fast(field, "expected a sequence in 'accelerations'");
|
||||
if (!seq_field) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = PySequence_Size(field);
|
||||
if (-1 == size) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
if (!rosidl_runtime_c__double__Sequence__init(&(ros_message->accelerations), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create double__Sequence ros_message");
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
double * dest = ros_message->accelerations.data;
|
||||
for (Py_ssize_t i = 0; i < size; ++i) {
|
||||
PyObject * item = PySequence_Fast_GET_ITEM(seq_field, i);
|
||||
if (!item) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(item));
|
||||
double tmp = PyFloat_AS_DOUBLE(item);
|
||||
memcpy(&dest[i], &tmp, sizeof(double));
|
||||
}
|
||||
Py_DECREF(seq_field);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // time_from_start
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "time_from_start");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->time_from_start = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__msg__joint_command__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of JointCommand */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.msg._joint_command");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "JointCommand");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__msg__JointCommand * ros_message = (arm_msgs__msg__JointCommand *)raw_ros_message;
|
||||
{ // header
|
||||
PyObject * field = NULL;
|
||||
field = std_msgs__msg__header__convert_to_py(&ros_message->header);
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "header", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // joint_names
|
||||
PyObject * field = NULL;
|
||||
size_t size = ros_message->joint_names.size;
|
||||
rosidl_runtime_c__String * src = ros_message->joint_names.data;
|
||||
field = PyList_New(size);
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
PyObject * decoded_item = PyUnicode_DecodeUTF8(src[i].data, strlen(src[i].data), "replace");
|
||||
if (!decoded_item) {
|
||||
return NULL;
|
||||
}
|
||||
int rc = PyList_SetItem(field, i, decoded_item);
|
||||
(void)rc;
|
||||
assert(rc == 0);
|
||||
}
|
||||
assert(PySequence_Check(field));
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "joint_names", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // positions
|
||||
PyObject * field = NULL;
|
||||
field = PyObject_GetAttrString(_pymessage, "positions");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
assert(field->ob_type != NULL);
|
||||
assert(field->ob_type->tp_name != NULL);
|
||||
assert(strcmp(field->ob_type->tp_name, "array.array") == 0);
|
||||
// ensure that itemsize matches the sizeof of the ROS message field
|
||||
PyObject * itemsize_attr = PyObject_GetAttrString(field, "itemsize");
|
||||
assert(itemsize_attr != NULL);
|
||||
size_t itemsize = PyLong_AsSize_t(itemsize_attr);
|
||||
Py_DECREF(itemsize_attr);
|
||||
if (itemsize != sizeof(double)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "itemsize doesn't match expectation");
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
// clear the array, poor approach to remove potential default values
|
||||
Py_ssize_t length = PyObject_Length(field);
|
||||
if (-1 == length) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
if (length > 0) {
|
||||
PyObject * pop = PyObject_GetAttrString(field, "pop");
|
||||
assert(pop != NULL);
|
||||
for (Py_ssize_t i = 0; i < length; ++i) {
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(pop, NULL);
|
||||
if (!ret) {
|
||||
Py_DECREF(pop);
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(pop);
|
||||
}
|
||||
if (ros_message->positions.size > 0) {
|
||||
// populating the array.array using the frombytes method
|
||||
PyObject * frombytes = PyObject_GetAttrString(field, "frombytes");
|
||||
assert(frombytes != NULL);
|
||||
double * src = &(ros_message->positions.data[0]);
|
||||
PyObject * data = PyBytes_FromStringAndSize((const char *)src, ros_message->positions.size * sizeof(double));
|
||||
assert(data != NULL);
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(frombytes, data, NULL);
|
||||
Py_DECREF(data);
|
||||
Py_DECREF(frombytes);
|
||||
if (!ret) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // velocities
|
||||
PyObject * field = NULL;
|
||||
field = PyObject_GetAttrString(_pymessage, "velocities");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
assert(field->ob_type != NULL);
|
||||
assert(field->ob_type->tp_name != NULL);
|
||||
assert(strcmp(field->ob_type->tp_name, "array.array") == 0);
|
||||
// ensure that itemsize matches the sizeof of the ROS message field
|
||||
PyObject * itemsize_attr = PyObject_GetAttrString(field, "itemsize");
|
||||
assert(itemsize_attr != NULL);
|
||||
size_t itemsize = PyLong_AsSize_t(itemsize_attr);
|
||||
Py_DECREF(itemsize_attr);
|
||||
if (itemsize != sizeof(double)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "itemsize doesn't match expectation");
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
// clear the array, poor approach to remove potential default values
|
||||
Py_ssize_t length = PyObject_Length(field);
|
||||
if (-1 == length) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
if (length > 0) {
|
||||
PyObject * pop = PyObject_GetAttrString(field, "pop");
|
||||
assert(pop != NULL);
|
||||
for (Py_ssize_t i = 0; i < length; ++i) {
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(pop, NULL);
|
||||
if (!ret) {
|
||||
Py_DECREF(pop);
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(pop);
|
||||
}
|
||||
if (ros_message->velocities.size > 0) {
|
||||
// populating the array.array using the frombytes method
|
||||
PyObject * frombytes = PyObject_GetAttrString(field, "frombytes");
|
||||
assert(frombytes != NULL);
|
||||
double * src = &(ros_message->velocities.data[0]);
|
||||
PyObject * data = PyBytes_FromStringAndSize((const char *)src, ros_message->velocities.size * sizeof(double));
|
||||
assert(data != NULL);
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(frombytes, data, NULL);
|
||||
Py_DECREF(data);
|
||||
Py_DECREF(frombytes);
|
||||
if (!ret) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // accelerations
|
||||
PyObject * field = NULL;
|
||||
field = PyObject_GetAttrString(_pymessage, "accelerations");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
assert(field->ob_type != NULL);
|
||||
assert(field->ob_type->tp_name != NULL);
|
||||
assert(strcmp(field->ob_type->tp_name, "array.array") == 0);
|
||||
// ensure that itemsize matches the sizeof of the ROS message field
|
||||
PyObject * itemsize_attr = PyObject_GetAttrString(field, "itemsize");
|
||||
assert(itemsize_attr != NULL);
|
||||
size_t itemsize = PyLong_AsSize_t(itemsize_attr);
|
||||
Py_DECREF(itemsize_attr);
|
||||
if (itemsize != sizeof(double)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "itemsize doesn't match expectation");
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
// clear the array, poor approach to remove potential default values
|
||||
Py_ssize_t length = PyObject_Length(field);
|
||||
if (-1 == length) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
if (length > 0) {
|
||||
PyObject * pop = PyObject_GetAttrString(field, "pop");
|
||||
assert(pop != NULL);
|
||||
for (Py_ssize_t i = 0; i < length; ++i) {
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(pop, NULL);
|
||||
if (!ret) {
|
||||
Py_DECREF(pop);
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(pop);
|
||||
}
|
||||
if (ros_message->accelerations.size > 0) {
|
||||
// populating the array.array using the frombytes method
|
||||
PyObject * frombytes = PyObject_GetAttrString(field, "frombytes");
|
||||
assert(frombytes != NULL);
|
||||
double * src = &(ros_message->accelerations.data[0]);
|
||||
PyObject * data = PyBytes_FromStringAndSize((const char *)src, ros_message->accelerations.size * sizeof(double));
|
||||
assert(data != NULL);
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(frombytes, data, NULL);
|
||||
Py_DECREF(data);
|
||||
Py_DECREF(frombytes);
|
||||
if (!ret) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // time_from_start
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->time_from_start);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "time_from_start", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ownership of _pymessage is transferred to the caller
|
||||
return _pymessage;
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
# generated from rosidl_generator_py/resource/_idl.py.em
|
||||
# with input from arm_msgs:msg/TactileStatus.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_TactileStatus(type):
|
||||
"""Metaclass of message 'TactileStatus'."""
|
||||
|
||||
_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.msg.TactileStatus')
|
||||
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__tactile_status
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__tactile_status
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__tactile_status
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__msg__tactile_status
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__tactile_status
|
||||
|
||||
from std_msgs.msg import Header
|
||||
if Header.__class__._TYPE_SUPPORT is None:
|
||||
Header.__class__.__import_type_support__()
|
||||
|
||||
@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 TactileStatus(metaclass=Metaclass_TactileStatus):
|
||||
"""Message class 'TactileStatus'."""
|
||||
|
||||
__slots__ = [
|
||||
'_header',
|
||||
'_side',
|
||||
'_connected',
|
||||
'_contact',
|
||||
'_fnormal',
|
||||
'_fshearx',
|
||||
'_fsheary',
|
||||
'_fps',
|
||||
'_centroid_u',
|
||||
'_centroid_v',
|
||||
'_error_msg',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'header': 'std_msgs/Header',
|
||||
'side': 'string',
|
||||
'connected': 'boolean',
|
||||
'contact': 'boolean',
|
||||
'fnormal': 'float',
|
||||
'fshearx': 'float',
|
||||
'fsheary': 'float',
|
||||
'fps': 'float',
|
||||
'centroid_u': 'float',
|
||||
'centroid_v': 'float',
|
||||
'error_msg': 'string',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.NamespacedType(['std_msgs', 'msg'], 'Header'), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('boolean'), # 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
|
||||
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__))
|
||||
from std_msgs.msg import Header
|
||||
self.header = kwargs.get('header', Header())
|
||||
self.side = kwargs.get('side', str())
|
||||
self.connected = kwargs.get('connected', bool())
|
||||
self.contact = kwargs.get('contact', bool())
|
||||
self.fnormal = kwargs.get('fnormal', float())
|
||||
self.fshearx = kwargs.get('fshearx', float())
|
||||
self.fsheary = kwargs.get('fsheary', float())
|
||||
self.fps = kwargs.get('fps', float())
|
||||
self.centroid_u = kwargs.get('centroid_u', float())
|
||||
self.centroid_v = kwargs.get('centroid_v', float())
|
||||
self.error_msg = kwargs.get('error_msg', 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.header != other.header:
|
||||
return False
|
||||
if self.side != other.side:
|
||||
return False
|
||||
if self.connected != other.connected:
|
||||
return False
|
||||
if self.contact != other.contact:
|
||||
return False
|
||||
if self.fnormal != other.fnormal:
|
||||
return False
|
||||
if self.fshearx != other.fshearx:
|
||||
return False
|
||||
if self.fsheary != other.fsheary:
|
||||
return False
|
||||
if self.fps != other.fps:
|
||||
return False
|
||||
if self.centroid_u != other.centroid_u:
|
||||
return False
|
||||
if self.centroid_v != other.centroid_v:
|
||||
return False
|
||||
if self.error_msg != other.error_msg:
|
||||
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 header(self):
|
||||
"""Message field 'header'."""
|
||||
return self._header
|
||||
|
||||
@header.setter
|
||||
def header(self, value):
|
||||
if __debug__:
|
||||
from std_msgs.msg import Header
|
||||
assert \
|
||||
isinstance(value, Header), \
|
||||
"The 'header' field must be a sub message of type 'Header'"
|
||||
self._header = value
|
||||
|
||||
@builtins.property
|
||||
def side(self):
|
||||
"""Message field 'side'."""
|
||||
return self._side
|
||||
|
||||
@side.setter
|
||||
def side(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'side' field must be of type 'str'"
|
||||
self._side = value
|
||||
|
||||
@builtins.property
|
||||
def connected(self):
|
||||
"""Message field 'connected'."""
|
||||
return self._connected
|
||||
|
||||
@connected.setter
|
||||
def connected(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'connected' field must be of type 'bool'"
|
||||
self._connected = value
|
||||
|
||||
@builtins.property
|
||||
def contact(self):
|
||||
"""Message field 'contact'."""
|
||||
return self._contact
|
||||
|
||||
@contact.setter
|
||||
def contact(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'contact' field must be of type 'bool'"
|
||||
self._contact = value
|
||||
|
||||
@builtins.property
|
||||
def fnormal(self):
|
||||
"""Message field 'fnormal'."""
|
||||
return self._fnormal
|
||||
|
||||
@fnormal.setter
|
||||
def fnormal(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'fnormal' field must be of type 'float'"
|
||||
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
|
||||
"The 'fnormal' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
|
||||
self._fnormal = value
|
||||
|
||||
@builtins.property
|
||||
def fshearx(self):
|
||||
"""Message field 'fshearx'."""
|
||||
return self._fshearx
|
||||
|
||||
@fshearx.setter
|
||||
def fshearx(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'fshearx' field must be of type 'float'"
|
||||
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
|
||||
"The 'fshearx' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
|
||||
self._fshearx = value
|
||||
|
||||
@builtins.property
|
||||
def fsheary(self):
|
||||
"""Message field 'fsheary'."""
|
||||
return self._fsheary
|
||||
|
||||
@fsheary.setter
|
||||
def fsheary(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'fsheary' field must be of type 'float'"
|
||||
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
|
||||
"The 'fsheary' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
|
||||
self._fsheary = value
|
||||
|
||||
@builtins.property
|
||||
def fps(self):
|
||||
"""Message field 'fps'."""
|
||||
return self._fps
|
||||
|
||||
@fps.setter
|
||||
def fps(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'fps' field must be of type 'float'"
|
||||
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
|
||||
"The 'fps' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
|
||||
self._fps = value
|
||||
|
||||
@builtins.property
|
||||
def centroid_u(self):
|
||||
"""Message field 'centroid_u'."""
|
||||
return self._centroid_u
|
||||
|
||||
@centroid_u.setter
|
||||
def centroid_u(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'centroid_u' field must be of type 'float'"
|
||||
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
|
||||
"The 'centroid_u' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
|
||||
self._centroid_u = value
|
||||
|
||||
@builtins.property
|
||||
def centroid_v(self):
|
||||
"""Message field 'centroid_v'."""
|
||||
return self._centroid_v
|
||||
|
||||
@centroid_v.setter
|
||||
def centroid_v(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'centroid_v' field must be of type 'float'"
|
||||
assert not (value < -3.402823466e+38 or value > 3.402823466e+38) or math.isinf(value), \
|
||||
"The 'centroid_v' field must be a float in [-3.402823466e+38, 3.402823466e+38]"
|
||||
self._centroid_v = value
|
||||
|
||||
@builtins.property
|
||||
def error_msg(self):
|
||||
"""Message field 'error_msg'."""
|
||||
return self._error_msg
|
||||
|
||||
@error_msg.setter
|
||||
def error_msg(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'error_msg' field must be of type 'str'"
|
||||
self._error_msg = value
|
||||
@@ -0,0 +1,334 @@
|
||||
// generated from rosidl_generator_py/resource/_idl_support.c.em
|
||||
// with input from arm_msgs:msg/TactileStatus.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 "arm_msgs/msg/detail/tactile_status__struct.h"
|
||||
#include "arm_msgs/msg/detail/tactile_status__functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/string.h"
|
||||
#include "rosidl_runtime_c/string_functions.h"
|
||||
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
bool std_msgs__msg__header__convert_from_py(PyObject * _pymsg, void * _ros_message);
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
PyObject * std_msgs__msg__header__convert_to_py(void * raw_ros_message);
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__msg__tactile_status__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[43];
|
||||
{
|
||||
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("arm_msgs.msg._tactile_status.TactileStatus", full_classname_dest, 42) == 0);
|
||||
}
|
||||
arm_msgs__msg__TactileStatus * ros_message = _ros_message;
|
||||
{ // header
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "header");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (!std_msgs__msg__header__convert_from_py(field, &ros_message->header)) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // side
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "side");
|
||||
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->side, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // connected
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "connected");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->connected = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // contact
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "contact");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->contact = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // fnormal
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "fnormal");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->fnormal = (float)PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // fshearx
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "fshearx");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->fshearx = (float)PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // fsheary
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "fsheary");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->fsheary = (float)PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // fps
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "fps");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->fps = (float)PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // centroid_u
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "centroid_u");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->centroid_u = (float)PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // centroid_v
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "centroid_v");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->centroid_v = (float)PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // error_msg
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "error_msg");
|
||||
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->error_msg, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__msg__tactile_status__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of TactileStatus */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.msg._tactile_status");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "TactileStatus");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__msg__TactileStatus * ros_message = (arm_msgs__msg__TactileStatus *)raw_ros_message;
|
||||
{ // header
|
||||
PyObject * field = NULL;
|
||||
field = std_msgs__msg__header__convert_to_py(&ros_message->header);
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "header", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // side
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->side.data,
|
||||
strlen(ros_message->side.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "side", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // connected
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->connected ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "connected", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // contact
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->contact ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "contact", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // fnormal
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->fnormal);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "fnormal", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // fshearx
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->fshearx);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "fshearx", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // fsheary
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->fsheary);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "fsheary", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // fps
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->fps);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "fps", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // centroid_u
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->centroid_u);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "centroid_u", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // centroid_v
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->centroid_v);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "centroid_v", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // error_msg
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->error_msg.data,
|
||||
strlen(ros_message->error_msg.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "error_msg", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ownership of _pymessage is transferred to the caller
|
||||
return _pymessage;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
from arm_msgs.srv._get_arm_state import GetArmState # noqa: F401
|
||||
from arm_msgs.srv._gripper_execute import GripperExecute # noqa: F401
|
||||
from arm_msgs.srv._set_named_pose import SetNamedPose # noqa: F401
|
||||
from arm_msgs.srv._switch_tool import SwitchTool # noqa: F401
|
||||
@@ -0,0 +1,363 @@
|
||||
# generated from rosidl_generator_py/resource/_idl.py.em
|
||||
# with input from arm_msgs:srv/GetArmState.idl
|
||||
# generated code does not contain a copyright notice
|
||||
|
||||
|
||||
# Import statements for member types
|
||||
|
||||
import rosidl_parser.definition # noqa: E402, I100
|
||||
|
||||
|
||||
class Metaclass_GetArmState_Request(type):
|
||||
"""Metaclass of message 'GetArmState_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.srv.GetArmState_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__get_arm_state__request
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__get_arm_state__request
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__get_arm_state__request
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__srv__get_arm_state__request
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__get_arm_state__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 GetArmState_Request(metaclass=Metaclass_GetArmState_Request):
|
||||
"""Message class 'GetArmState_Request'."""
|
||||
|
||||
__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)
|
||||
|
||||
|
||||
# Import statements for member types
|
||||
|
||||
# Member 'joint_positions'
|
||||
import array # noqa: E402, I100
|
||||
|
||||
import builtins # noqa: E402, I100
|
||||
|
||||
import math # noqa: E402, I100
|
||||
|
||||
# already imported above
|
||||
# import rosidl_parser.definition
|
||||
|
||||
|
||||
class Metaclass_GetArmState_Response(type):
|
||||
"""Metaclass of message 'GetArmState_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.srv.GetArmState_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__get_arm_state__response
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__get_arm_state__response
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__get_arm_state__response
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__srv__get_arm_state__response
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__get_arm_state__response
|
||||
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
if PoseStamped.__class__._TYPE_SUPPORT is None:
|
||||
PoseStamped.__class__.__import_type_support__()
|
||||
|
||||
@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 GetArmState_Response(metaclass=Metaclass_GetArmState_Response):
|
||||
"""Message class 'GetArmState_Response'."""
|
||||
|
||||
__slots__ = [
|
||||
'_success',
|
||||
'_mode',
|
||||
'_joint_positions',
|
||||
'_ee_pose',
|
||||
'_message',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'success': 'boolean',
|
||||
'mode': 'string',
|
||||
'joint_positions': 'sequence<double>',
|
||||
'ee_pose': 'geometry_msgs/PoseStamped',
|
||||
'message': 'string',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedSequence(rosidl_parser.definition.BasicType('double')), # noqa: E501
|
||||
rosidl_parser.definition.NamespacedType(['geometry_msgs', 'msg'], 'PoseStamped'), # 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.success = kwargs.get('success', bool())
|
||||
self.mode = kwargs.get('mode', str())
|
||||
self.joint_positions = array.array('d', kwargs.get('joint_positions', []))
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
self.ee_pose = kwargs.get('ee_pose', PoseStamped())
|
||||
self.message = kwargs.get('message', 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.success != other.success:
|
||||
return False
|
||||
if self.mode != other.mode:
|
||||
return False
|
||||
if self.joint_positions != other.joint_positions:
|
||||
return False
|
||||
if self.ee_pose != other.ee_pose:
|
||||
return False
|
||||
if self.message != other.message:
|
||||
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 success(self):
|
||||
"""Message field 'success'."""
|
||||
return self._success
|
||||
|
||||
@success.setter
|
||||
def success(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'success' field must be of type 'bool'"
|
||||
self._success = value
|
||||
|
||||
@builtins.property
|
||||
def mode(self):
|
||||
"""Message field 'mode'."""
|
||||
return self._mode
|
||||
|
||||
@mode.setter
|
||||
def mode(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'mode' field must be of type 'str'"
|
||||
self._mode = value
|
||||
|
||||
@builtins.property
|
||||
def joint_positions(self):
|
||||
"""Message field 'joint_positions'."""
|
||||
return self._joint_positions
|
||||
|
||||
@joint_positions.setter
|
||||
def joint_positions(self, value):
|
||||
if isinstance(value, array.array):
|
||||
assert value.typecode == 'd', \
|
||||
"The 'joint_positions' array.array() must have the type code of 'd'"
|
||||
self._joint_positions = value
|
||||
return
|
||||
if __debug__:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Set
|
||||
from collections import UserList
|
||||
from collections import UserString
|
||||
assert \
|
||||
((isinstance(value, Sequence) or
|
||||
isinstance(value, Set) or
|
||||
isinstance(value, UserList)) and
|
||||
not isinstance(value, str) and
|
||||
not isinstance(value, UserString) and
|
||||
all(isinstance(v, float) for v in value) and
|
||||
all(not (val < -1.7976931348623157e+308 or val > 1.7976931348623157e+308) or math.isinf(val) for val in value)), \
|
||||
"The 'joint_positions' field must be a set or sequence and each value of type 'float' and each double in [-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]"
|
||||
self._joint_positions = array.array('d', value)
|
||||
|
||||
@builtins.property
|
||||
def ee_pose(self):
|
||||
"""Message field 'ee_pose'."""
|
||||
return self._ee_pose
|
||||
|
||||
@ee_pose.setter
|
||||
def ee_pose(self, value):
|
||||
if __debug__:
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
assert \
|
||||
isinstance(value, PoseStamped), \
|
||||
"The 'ee_pose' field must be a sub message of type 'PoseStamped'"
|
||||
self._ee_pose = value
|
||||
|
||||
@builtins.property
|
||||
def message(self):
|
||||
"""Message field 'message'."""
|
||||
return self._message
|
||||
|
||||
@message.setter
|
||||
def message(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'message' field must be of type 'str'"
|
||||
self._message = value
|
||||
|
||||
|
||||
class Metaclass_GetArmState(type):
|
||||
"""Metaclass of service 'GetArmState'."""
|
||||
|
||||
_TYPE_SUPPORT = None
|
||||
|
||||
@classmethod
|
||||
def __import_type_support__(cls):
|
||||
try:
|
||||
from rosidl_generator_py import import_type_support
|
||||
module = import_type_support('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.srv.GetArmState')
|
||||
logger.debug(
|
||||
'Failed to import needed modules for type support:\n' +
|
||||
traceback.format_exc())
|
||||
else:
|
||||
cls._TYPE_SUPPORT = module.type_support_srv__srv__get_arm_state
|
||||
|
||||
from arm_msgs.srv import _get_arm_state
|
||||
if _get_arm_state.Metaclass_GetArmState_Request._TYPE_SUPPORT is None:
|
||||
_get_arm_state.Metaclass_GetArmState_Request.__import_type_support__()
|
||||
if _get_arm_state.Metaclass_GetArmState_Response._TYPE_SUPPORT is None:
|
||||
_get_arm_state.Metaclass_GetArmState_Response.__import_type_support__()
|
||||
|
||||
|
||||
class GetArmState(metaclass=Metaclass_GetArmState):
|
||||
from arm_msgs.srv._get_arm_state import GetArmState_Request as Request
|
||||
from arm_msgs.srv._get_arm_state import GetArmState_Response as Response
|
||||
|
||||
def __init__(self):
|
||||
raise NotImplementedError('Service classes can not be instantiated')
|
||||
@@ -0,0 +1,392 @@
|
||||
// generated from rosidl_generator_py/resource/_idl_support.c.em
|
||||
// with input from arm_msgs:srv/GetArmState.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 "arm_msgs/srv/detail/get_arm_state__struct.h"
|
||||
#include "arm_msgs/srv/detail/get_arm_state__functions.h"
|
||||
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__srv__get_arm_state__request__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[48];
|
||||
{
|
||||
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("arm_msgs.srv._get_arm_state.GetArmState_Request", full_classname_dest, 47) == 0);
|
||||
}
|
||||
arm_msgs__srv__GetArmState_Request * ros_message = _ros_message;
|
||||
ros_message->structure_needs_at_least_one_member = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__srv__get_arm_state__request__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of GetArmState_Request */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.srv._get_arm_state");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "GetArmState_Request");
|
||||
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;
|
||||
}
|
||||
|
||||
#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 "arm_msgs/srv/detail/get_arm_state__struct.h"
|
||||
// already included above
|
||||
// #include "arm_msgs/srv/detail/get_arm_state__functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/string.h"
|
||||
#include "rosidl_runtime_c/string_functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/primitives_sequence.h"
|
||||
#include "rosidl_runtime_c/primitives_sequence_functions.h"
|
||||
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
bool geometry_msgs__msg__pose_stamped__convert_from_py(PyObject * _pymsg, void * _ros_message);
|
||||
ROSIDL_GENERATOR_C_IMPORT
|
||||
PyObject * geometry_msgs__msg__pose_stamped__convert_to_py(void * raw_ros_message);
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__srv__get_arm_state__response__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[49];
|
||||
{
|
||||
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("arm_msgs.srv._get_arm_state.GetArmState_Response", full_classname_dest, 48) == 0);
|
||||
}
|
||||
arm_msgs__srv__GetArmState_Response * ros_message = _ros_message;
|
||||
{ // success
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "success");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->success = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // mode
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "mode");
|
||||
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->mode, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // joint_positions
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "joint_positions");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (PyObject_CheckBuffer(field)) {
|
||||
// Optimization for converting arrays of primitives
|
||||
Py_buffer view;
|
||||
int rc = PyObject_GetBuffer(field, &view, PyBUF_SIMPLE);
|
||||
if (rc < 0) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = view.len / sizeof(double);
|
||||
if (!rosidl_runtime_c__double__Sequence__init(&(ros_message->joint_positions), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create double__Sequence ros_message");
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
double * dest = ros_message->joint_positions.data;
|
||||
rc = PyBuffer_ToContiguous(dest, &view, view.len, 'C');
|
||||
if (rc < 0) {
|
||||
PyBuffer_Release(&view);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
PyBuffer_Release(&view);
|
||||
} else {
|
||||
PyObject * seq_field = PySequence_Fast(field, "expected a sequence in 'joint_positions'");
|
||||
if (!seq_field) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = PySequence_Size(field);
|
||||
if (-1 == size) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
if (!rosidl_runtime_c__double__Sequence__init(&(ros_message->joint_positions), size)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "unable to create double__Sequence ros_message");
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
double * dest = ros_message->joint_positions.data;
|
||||
for (Py_ssize_t i = 0; i < size; ++i) {
|
||||
PyObject * item = PySequence_Fast_GET_ITEM(seq_field, i);
|
||||
if (!item) {
|
||||
Py_DECREF(seq_field);
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(item));
|
||||
double tmp = PyFloat_AS_DOUBLE(item);
|
||||
memcpy(&dest[i], &tmp, sizeof(double));
|
||||
}
|
||||
Py_DECREF(seq_field);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // ee_pose
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "ee_pose");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (!geometry_msgs__msg__pose_stamped__convert_from_py(field, &ros_message->ee_pose)) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // message
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "message");
|
||||
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->message, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__srv__get_arm_state__response__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of GetArmState_Response */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.srv._get_arm_state");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "GetArmState_Response");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__srv__GetArmState_Response * ros_message = (arm_msgs__srv__GetArmState_Response *)raw_ros_message;
|
||||
{ // success
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->success ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "success", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // mode
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->mode.data,
|
||||
strlen(ros_message->mode.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "mode", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // joint_positions
|
||||
PyObject * field = NULL;
|
||||
field = PyObject_GetAttrString(_pymessage, "joint_positions");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
assert(field->ob_type != NULL);
|
||||
assert(field->ob_type->tp_name != NULL);
|
||||
assert(strcmp(field->ob_type->tp_name, "array.array") == 0);
|
||||
// ensure that itemsize matches the sizeof of the ROS message field
|
||||
PyObject * itemsize_attr = PyObject_GetAttrString(field, "itemsize");
|
||||
assert(itemsize_attr != NULL);
|
||||
size_t itemsize = PyLong_AsSize_t(itemsize_attr);
|
||||
Py_DECREF(itemsize_attr);
|
||||
if (itemsize != sizeof(double)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "itemsize doesn't match expectation");
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
// clear the array, poor approach to remove potential default values
|
||||
Py_ssize_t length = PyObject_Length(field);
|
||||
if (-1 == length) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
if (length > 0) {
|
||||
PyObject * pop = PyObject_GetAttrString(field, "pop");
|
||||
assert(pop != NULL);
|
||||
for (Py_ssize_t i = 0; i < length; ++i) {
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(pop, NULL);
|
||||
if (!ret) {
|
||||
Py_DECREF(pop);
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(pop);
|
||||
}
|
||||
if (ros_message->joint_positions.size > 0) {
|
||||
// populating the array.array using the frombytes method
|
||||
PyObject * frombytes = PyObject_GetAttrString(field, "frombytes");
|
||||
assert(frombytes != NULL);
|
||||
double * src = &(ros_message->joint_positions.data[0]);
|
||||
PyObject * data = PyBytes_FromStringAndSize((const char *)src, ros_message->joint_positions.size * sizeof(double));
|
||||
assert(data != NULL);
|
||||
PyObject * ret = PyObject_CallFunctionObjArgs(frombytes, data, NULL);
|
||||
Py_DECREF(data);
|
||||
Py_DECREF(frombytes);
|
||||
if (!ret) {
|
||||
Py_DECREF(field);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // ee_pose
|
||||
PyObject * field = NULL;
|
||||
field = geometry_msgs__msg__pose_stamped__convert_to_py(&ros_message->ee_pose);
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "ee_pose", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // message
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->message.data,
|
||||
strlen(ros_message->message.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "message", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ownership of _pymessage is transferred to the caller
|
||||
return _pymessage;
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
# generated from rosidl_generator_py/resource/_idl.py.em
|
||||
# with input from arm_msgs:srv/GripperExecute.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_GripperExecute_Request(type):
|
||||
"""Metaclass of message 'GripperExecute_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.srv.GripperExecute_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__gripper_execute__request
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__gripper_execute__request
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__gripper_execute__request
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__srv__gripper_execute__request
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__gripper_execute__request
|
||||
|
||||
from arm_msgs.msg import GripperCommand
|
||||
if GripperCommand.__class__._TYPE_SUPPORT is None:
|
||||
GripperCommand.__class__.__import_type_support__()
|
||||
|
||||
@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 GripperExecute_Request(metaclass=Metaclass_GripperExecute_Request):
|
||||
"""Message class 'GripperExecute_Request'."""
|
||||
|
||||
__slots__ = [
|
||||
'_command',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'command': 'arm_msgs/GripperCommand',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.NamespacedType(['arm_msgs', 'msg'], 'GripperCommand'), # 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__))
|
||||
from arm_msgs.msg import GripperCommand
|
||||
self.command = kwargs.get('command', GripperCommand())
|
||||
|
||||
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.command != other.command:
|
||||
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 command(self):
|
||||
"""Message field 'command'."""
|
||||
return self._command
|
||||
|
||||
@command.setter
|
||||
def command(self, value):
|
||||
if __debug__:
|
||||
from arm_msgs.msg import GripperCommand
|
||||
assert \
|
||||
isinstance(value, GripperCommand), \
|
||||
"The 'command' field must be a sub message of type 'GripperCommand'"
|
||||
self._command = value
|
||||
|
||||
|
||||
# Import statements for member types
|
||||
|
||||
# already imported above
|
||||
# import builtins
|
||||
|
||||
# already imported above
|
||||
# import rosidl_parser.definition
|
||||
|
||||
|
||||
class Metaclass_GripperExecute_Response(type):
|
||||
"""Metaclass of message 'GripperExecute_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.srv.GripperExecute_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__gripper_execute__response
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__gripper_execute__response
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__gripper_execute__response
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__srv__gripper_execute__response
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__gripper_execute__response
|
||||
|
||||
from arm_msgs.msg import GripperStatus
|
||||
if GripperStatus.__class__._TYPE_SUPPORT is None:
|
||||
GripperStatus.__class__.__import_type_support__()
|
||||
|
||||
@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 GripperExecute_Response(metaclass=Metaclass_GripperExecute_Response):
|
||||
"""Message class 'GripperExecute_Response'."""
|
||||
|
||||
__slots__ = [
|
||||
'_success',
|
||||
'_message',
|
||||
'_status',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'success': 'boolean',
|
||||
'message': 'string',
|
||||
'status': 'arm_msgs/GripperStatus',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.NamespacedType(['arm_msgs', 'msg'], 'GripperStatus'), # 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.success = kwargs.get('success', bool())
|
||||
self.message = kwargs.get('message', str())
|
||||
from arm_msgs.msg import GripperStatus
|
||||
self.status = kwargs.get('status', GripperStatus())
|
||||
|
||||
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.success != other.success:
|
||||
return False
|
||||
if self.message != other.message:
|
||||
return False
|
||||
if self.status != other.status:
|
||||
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 success(self):
|
||||
"""Message field 'success'."""
|
||||
return self._success
|
||||
|
||||
@success.setter
|
||||
def success(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'success' field must be of type 'bool'"
|
||||
self._success = value
|
||||
|
||||
@builtins.property
|
||||
def message(self):
|
||||
"""Message field 'message'."""
|
||||
return self._message
|
||||
|
||||
@message.setter
|
||||
def message(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'message' field must be of type 'str'"
|
||||
self._message = value
|
||||
|
||||
@builtins.property
|
||||
def status(self):
|
||||
"""Message field 'status'."""
|
||||
return self._status
|
||||
|
||||
@status.setter
|
||||
def status(self, value):
|
||||
if __debug__:
|
||||
from arm_msgs.msg import GripperStatus
|
||||
assert \
|
||||
isinstance(value, GripperStatus), \
|
||||
"The 'status' field must be a sub message of type 'GripperStatus'"
|
||||
self._status = value
|
||||
|
||||
|
||||
class Metaclass_GripperExecute(type):
|
||||
"""Metaclass of service 'GripperExecute'."""
|
||||
|
||||
_TYPE_SUPPORT = None
|
||||
|
||||
@classmethod
|
||||
def __import_type_support__(cls):
|
||||
try:
|
||||
from rosidl_generator_py import import_type_support
|
||||
module = import_type_support('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.srv.GripperExecute')
|
||||
logger.debug(
|
||||
'Failed to import needed modules for type support:\n' +
|
||||
traceback.format_exc())
|
||||
else:
|
||||
cls._TYPE_SUPPORT = module.type_support_srv__srv__gripper_execute
|
||||
|
||||
from arm_msgs.srv import _gripper_execute
|
||||
if _gripper_execute.Metaclass_GripperExecute_Request._TYPE_SUPPORT is None:
|
||||
_gripper_execute.Metaclass_GripperExecute_Request.__import_type_support__()
|
||||
if _gripper_execute.Metaclass_GripperExecute_Response._TYPE_SUPPORT is None:
|
||||
_gripper_execute.Metaclass_GripperExecute_Response.__import_type_support__()
|
||||
|
||||
|
||||
class GripperExecute(metaclass=Metaclass_GripperExecute):
|
||||
from arm_msgs.srv._gripper_execute import GripperExecute_Request as Request
|
||||
from arm_msgs.srv._gripper_execute import GripperExecute_Response as Response
|
||||
|
||||
def __init__(self):
|
||||
raise NotImplementedError('Service classes can not be instantiated')
|
||||
@@ -0,0 +1,262 @@
|
||||
// generated from rosidl_generator_py/resource/_idl_support.c.em
|
||||
// with input from arm_msgs:srv/GripperExecute.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 "arm_msgs/srv/detail/gripper_execute__struct.h"
|
||||
#include "arm_msgs/srv/detail/gripper_execute__functions.h"
|
||||
|
||||
bool arm_msgs__msg__gripper_command__convert_from_py(PyObject * _pymsg, void * _ros_message);
|
||||
PyObject * arm_msgs__msg__gripper_command__convert_to_py(void * raw_ros_message);
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__srv__gripper_execute__request__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[53];
|
||||
{
|
||||
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("arm_msgs.srv._gripper_execute.GripperExecute_Request", full_classname_dest, 52) == 0);
|
||||
}
|
||||
arm_msgs__srv__GripperExecute_Request * ros_message = _ros_message;
|
||||
{ // command
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "command");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (!arm_msgs__msg__gripper_command__convert_from_py(field, &ros_message->command)) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__srv__gripper_execute__request__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of GripperExecute_Request */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.srv._gripper_execute");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "GripperExecute_Request");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__srv__GripperExecute_Request * ros_message = (arm_msgs__srv__GripperExecute_Request *)raw_ros_message;
|
||||
{ // command
|
||||
PyObject * field = NULL;
|
||||
field = arm_msgs__msg__gripper_command__convert_to_py(&ros_message->command);
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "command", 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 "arm_msgs/srv/detail/gripper_execute__struct.h"
|
||||
// already included above
|
||||
// #include "arm_msgs/srv/detail/gripper_execute__functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/string.h"
|
||||
#include "rosidl_runtime_c/string_functions.h"
|
||||
|
||||
bool arm_msgs__msg__gripper_status__convert_from_py(PyObject * _pymsg, void * _ros_message);
|
||||
PyObject * arm_msgs__msg__gripper_status__convert_to_py(void * raw_ros_message);
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__srv__gripper_execute__response__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("arm_msgs.srv._gripper_execute.GripperExecute_Response", full_classname_dest, 53) == 0);
|
||||
}
|
||||
arm_msgs__srv__GripperExecute_Response * ros_message = _ros_message;
|
||||
{ // success
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "success");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->success = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // message
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "message");
|
||||
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->message, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // status
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "status");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
if (!arm_msgs__msg__gripper_status__convert_from_py(field, &ros_message->status)) {
|
||||
Py_DECREF(field);
|
||||
return false;
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__srv__gripper_execute__response__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of GripperExecute_Response */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.srv._gripper_execute");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "GripperExecute_Response");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__srv__GripperExecute_Response * ros_message = (arm_msgs__srv__GripperExecute_Response *)raw_ros_message;
|
||||
{ // success
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->success ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "success", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // message
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->message.data,
|
||||
strlen(ros_message->message.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "message", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // status
|
||||
PyObject * field = NULL;
|
||||
field = arm_msgs__msg__gripper_status__convert_to_py(&ros_message->status);
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "status", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ownership of _pymessage is transferred to the caller
|
||||
return _pymessage;
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
# generated from rosidl_generator_py/resource/_idl.py.em
|
||||
# with input from arm_msgs:srv/SetNamedPose.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_SetNamedPose_Request(type):
|
||||
"""Metaclass of message 'SetNamedPose_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.srv.SetNamedPose_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_named_pose__request
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__set_named_pose__request
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__set_named_pose__request
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__srv__set_named_pose__request
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__set_named_pose__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 SetNamedPose_Request(metaclass=Metaclass_SetNamedPose_Request):
|
||||
"""Message class 'SetNamedPose_Request'."""
|
||||
|
||||
__slots__ = [
|
||||
'_pose_name',
|
||||
'_velocity_scale',
|
||||
'_acceleration_scale',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'pose_name': 'string',
|
||||
'velocity_scale': 'double',
|
||||
'acceleration_scale': 'double',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # 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.pose_name = kwargs.get('pose_name', str())
|
||||
self.velocity_scale = kwargs.get('velocity_scale', float())
|
||||
self.acceleration_scale = kwargs.get('acceleration_scale', 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.pose_name != other.pose_name:
|
||||
return False
|
||||
if self.velocity_scale != other.velocity_scale:
|
||||
return False
|
||||
if self.acceleration_scale != other.acceleration_scale:
|
||||
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 pose_name(self):
|
||||
"""Message field 'pose_name'."""
|
||||
return self._pose_name
|
||||
|
||||
@pose_name.setter
|
||||
def pose_name(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'pose_name' field must be of type 'str'"
|
||||
self._pose_name = value
|
||||
|
||||
@builtins.property
|
||||
def velocity_scale(self):
|
||||
"""Message field 'velocity_scale'."""
|
||||
return self._velocity_scale
|
||||
|
||||
@velocity_scale.setter
|
||||
def velocity_scale(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'velocity_scale' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'velocity_scale' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._velocity_scale = value
|
||||
|
||||
@builtins.property
|
||||
def acceleration_scale(self):
|
||||
"""Message field 'acceleration_scale'."""
|
||||
return self._acceleration_scale
|
||||
|
||||
@acceleration_scale.setter
|
||||
def acceleration_scale(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'acceleration_scale' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'acceleration_scale' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._acceleration_scale = value
|
||||
|
||||
|
||||
# Import statements for member types
|
||||
|
||||
# already imported above
|
||||
# import builtins
|
||||
|
||||
# already imported above
|
||||
# import rosidl_parser.definition
|
||||
|
||||
|
||||
class Metaclass_SetNamedPose_Response(type):
|
||||
"""Metaclass of message 'SetNamedPose_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.srv.SetNamedPose_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_named_pose__response
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__set_named_pose__response
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__set_named_pose__response
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__srv__set_named_pose__response
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__set_named_pose__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 SetNamedPose_Response(metaclass=Metaclass_SetNamedPose_Response):
|
||||
"""Message class 'SetNamedPose_Response'."""
|
||||
|
||||
__slots__ = [
|
||||
'_success',
|
||||
'_message',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'success': 'boolean',
|
||||
'message': 'string',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.BasicType('boolean'), # 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.success = kwargs.get('success', bool())
|
||||
self.message = kwargs.get('message', 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.success != other.success:
|
||||
return False
|
||||
if self.message != other.message:
|
||||
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 success(self):
|
||||
"""Message field 'success'."""
|
||||
return self._success
|
||||
|
||||
@success.setter
|
||||
def success(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'success' field must be of type 'bool'"
|
||||
self._success = value
|
||||
|
||||
@builtins.property
|
||||
def message(self):
|
||||
"""Message field 'message'."""
|
||||
return self._message
|
||||
|
||||
@message.setter
|
||||
def message(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'message' field must be of type 'str'"
|
||||
self._message = value
|
||||
|
||||
|
||||
class Metaclass_SetNamedPose(type):
|
||||
"""Metaclass of service 'SetNamedPose'."""
|
||||
|
||||
_TYPE_SUPPORT = None
|
||||
|
||||
@classmethod
|
||||
def __import_type_support__(cls):
|
||||
try:
|
||||
from rosidl_generator_py import import_type_support
|
||||
module = import_type_support('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.srv.SetNamedPose')
|
||||
logger.debug(
|
||||
'Failed to import needed modules for type support:\n' +
|
||||
traceback.format_exc())
|
||||
else:
|
||||
cls._TYPE_SUPPORT = module.type_support_srv__srv__set_named_pose
|
||||
|
||||
from arm_msgs.srv import _set_named_pose
|
||||
if _set_named_pose.Metaclass_SetNamedPose_Request._TYPE_SUPPORT is None:
|
||||
_set_named_pose.Metaclass_SetNamedPose_Request.__import_type_support__()
|
||||
if _set_named_pose.Metaclass_SetNamedPose_Response._TYPE_SUPPORT is None:
|
||||
_set_named_pose.Metaclass_SetNamedPose_Response.__import_type_support__()
|
||||
|
||||
|
||||
class SetNamedPose(metaclass=Metaclass_SetNamedPose):
|
||||
from arm_msgs.srv._set_named_pose import SetNamedPose_Request as Request
|
||||
from arm_msgs.srv._set_named_pose import SetNamedPose_Response as Response
|
||||
|
||||
def __init__(self):
|
||||
raise NotImplementedError('Service classes can not be instantiated')
|
||||
@@ -0,0 +1,285 @@
|
||||
// generated from rosidl_generator_py/resource/_idl_support.c.em
|
||||
// with input from arm_msgs:srv/SetNamedPose.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 "arm_msgs/srv/detail/set_named_pose__struct.h"
|
||||
#include "arm_msgs/srv/detail/set_named_pose__functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/string.h"
|
||||
#include "rosidl_runtime_c/string_functions.h"
|
||||
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__srv__set_named_pose__request__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[50];
|
||||
{
|
||||
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("arm_msgs.srv._set_named_pose.SetNamedPose_Request", full_classname_dest, 49) == 0);
|
||||
}
|
||||
arm_msgs__srv__SetNamedPose_Request * ros_message = _ros_message;
|
||||
{ // pose_name
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "pose_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->pose_name, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // velocity_scale
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "velocity_scale");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->velocity_scale = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // acceleration_scale
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "acceleration_scale");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->acceleration_scale = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__srv__set_named_pose__request__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of SetNamedPose_Request */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.srv._set_named_pose");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "SetNamedPose_Request");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__srv__SetNamedPose_Request * ros_message = (arm_msgs__srv__SetNamedPose_Request *)raw_ros_message;
|
||||
{ // pose_name
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->pose_name.data,
|
||||
strlen(ros_message->pose_name.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "pose_name", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // velocity_scale
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->velocity_scale);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "velocity_scale", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // acceleration_scale
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->acceleration_scale);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "acceleration_scale", 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 "arm_msgs/srv/detail/set_named_pose__struct.h"
|
||||
// already included above
|
||||
// #include "arm_msgs/srv/detail/set_named_pose__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 arm_msgs__srv__set_named_pose__response__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[51];
|
||||
{
|
||||
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("arm_msgs.srv._set_named_pose.SetNamedPose_Response", full_classname_dest, 50) == 0);
|
||||
}
|
||||
arm_msgs__srv__SetNamedPose_Response * ros_message = _ros_message;
|
||||
{ // success
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "success");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->success = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // message
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "message");
|
||||
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->message, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__srv__set_named_pose__response__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of SetNamedPose_Response */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.srv._set_named_pose");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "SetNamedPose_Response");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__srv__SetNamedPose_Response * ros_message = (arm_msgs__srv__SetNamedPose_Response *)raw_ros_message;
|
||||
{ // success
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->success ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "success", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // message
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->message.data,
|
||||
strlen(ros_message->message.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "message", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ownership of _pymessage is transferred to the caller
|
||||
return _pymessage;
|
||||
}
|
||||
@@ -0,0 +1,407 @@
|
||||
# generated from rosidl_generator_py/resource/_idl.py.em
|
||||
# with input from arm_msgs:srv/SwitchTool.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_SwitchTool_Request(type):
|
||||
"""Metaclass of message 'SwitchTool_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.srv.SwitchTool_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__switch_tool__request
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__switch_tool__request
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__switch_tool__request
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__srv__switch_tool__request
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__switch_tool__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 SwitchTool_Request(metaclass=Metaclass_SwitchTool_Request):
|
||||
"""Message class 'SwitchTool_Request'."""
|
||||
|
||||
__slots__ = [
|
||||
'_tool_name',
|
||||
'_sn',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'tool_name': 'string',
|
||||
'sn': 'string',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.UnboundedString(), # 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.tool_name = kwargs.get('tool_name', str())
|
||||
self.sn = kwargs.get('sn', 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.tool_name != other.tool_name:
|
||||
return False
|
||||
if self.sn != other.sn:
|
||||
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 tool_name(self):
|
||||
"""Message field 'tool_name'."""
|
||||
return self._tool_name
|
||||
|
||||
@tool_name.setter
|
||||
def tool_name(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'tool_name' field must be of type 'str'"
|
||||
self._tool_name = value
|
||||
|
||||
@builtins.property
|
||||
def sn(self):
|
||||
"""Message field 'sn'."""
|
||||
return self._sn
|
||||
|
||||
@sn.setter
|
||||
def sn(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'sn' field must be of type 'str'"
|
||||
self._sn = value
|
||||
|
||||
|
||||
# Import statements for member types
|
||||
|
||||
# already imported above
|
||||
# import builtins
|
||||
|
||||
import math # noqa: E402, I100
|
||||
|
||||
# Member 'tool_com_m'
|
||||
import numpy # noqa: E402, I100
|
||||
|
||||
# already imported above
|
||||
# import rosidl_parser.definition
|
||||
|
||||
|
||||
class Metaclass_SwitchTool_Response(type):
|
||||
"""Metaclass of message 'SwitchTool_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('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.srv.SwitchTool_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__switch_tool__response
|
||||
cls._CONVERT_FROM_PY = module.convert_from_py_msg__srv__switch_tool__response
|
||||
cls._CONVERT_TO_PY = module.convert_to_py_msg__srv__switch_tool__response
|
||||
cls._TYPE_SUPPORT = module.type_support_msg__srv__switch_tool__response
|
||||
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__srv__switch_tool__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 SwitchTool_Response(metaclass=Metaclass_SwitchTool_Response):
|
||||
"""Message class 'SwitchTool_Response'."""
|
||||
|
||||
__slots__ = [
|
||||
'_success',
|
||||
'_message',
|
||||
'_current_tool',
|
||||
'_tool_mass_kg',
|
||||
'_tool_com_m',
|
||||
]
|
||||
|
||||
_fields_and_field_types = {
|
||||
'success': 'boolean',
|
||||
'message': 'string',
|
||||
'current_tool': 'string',
|
||||
'tool_mass_kg': 'double',
|
||||
'tool_com_m': 'double[3]',
|
||||
}
|
||||
|
||||
SLOT_TYPES = (
|
||||
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.UnboundedString(), # noqa: E501
|
||||
rosidl_parser.definition.BasicType('double'), # noqa: E501
|
||||
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('double'), 3), # 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.success = kwargs.get('success', bool())
|
||||
self.message = kwargs.get('message', str())
|
||||
self.current_tool = kwargs.get('current_tool', str())
|
||||
self.tool_mass_kg = kwargs.get('tool_mass_kg', float())
|
||||
if 'tool_com_m' not in kwargs:
|
||||
self.tool_com_m = numpy.zeros(3, dtype=numpy.float64)
|
||||
else:
|
||||
self.tool_com_m = numpy.array(kwargs.get('tool_com_m'), dtype=numpy.float64)
|
||||
assert self.tool_com_m.shape == (3, )
|
||||
|
||||
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.success != other.success:
|
||||
return False
|
||||
if self.message != other.message:
|
||||
return False
|
||||
if self.current_tool != other.current_tool:
|
||||
return False
|
||||
if self.tool_mass_kg != other.tool_mass_kg:
|
||||
return False
|
||||
if all(self.tool_com_m != other.tool_com_m):
|
||||
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 success(self):
|
||||
"""Message field 'success'."""
|
||||
return self._success
|
||||
|
||||
@success.setter
|
||||
def success(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, bool), \
|
||||
"The 'success' field must be of type 'bool'"
|
||||
self._success = value
|
||||
|
||||
@builtins.property
|
||||
def message(self):
|
||||
"""Message field 'message'."""
|
||||
return self._message
|
||||
|
||||
@message.setter
|
||||
def message(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'message' field must be of type 'str'"
|
||||
self._message = value
|
||||
|
||||
@builtins.property
|
||||
def current_tool(self):
|
||||
"""Message field 'current_tool'."""
|
||||
return self._current_tool
|
||||
|
||||
@current_tool.setter
|
||||
def current_tool(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, str), \
|
||||
"The 'current_tool' field must be of type 'str'"
|
||||
self._current_tool = value
|
||||
|
||||
@builtins.property
|
||||
def tool_mass_kg(self):
|
||||
"""Message field 'tool_mass_kg'."""
|
||||
return self._tool_mass_kg
|
||||
|
||||
@tool_mass_kg.setter
|
||||
def tool_mass_kg(self, value):
|
||||
if __debug__:
|
||||
assert \
|
||||
isinstance(value, float), \
|
||||
"The 'tool_mass_kg' field must be of type 'float'"
|
||||
assert not (value < -1.7976931348623157e+308 or value > 1.7976931348623157e+308) or math.isinf(value), \
|
||||
"The 'tool_mass_kg' field must be a double in [-1.7976931348623157e+308, 1.7976931348623157e+308]"
|
||||
self._tool_mass_kg = value
|
||||
|
||||
@builtins.property
|
||||
def tool_com_m(self):
|
||||
"""Message field 'tool_com_m'."""
|
||||
return self._tool_com_m
|
||||
|
||||
@tool_com_m.setter
|
||||
def tool_com_m(self, value):
|
||||
if isinstance(value, numpy.ndarray):
|
||||
assert value.dtype == numpy.float64, \
|
||||
"The 'tool_com_m' numpy.ndarray() must have the dtype of 'numpy.float64'"
|
||||
assert value.size == 3, \
|
||||
"The 'tool_com_m' numpy.ndarray() must have a size of 3"
|
||||
self._tool_com_m = value
|
||||
return
|
||||
if __debug__:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Set
|
||||
from collections import UserList
|
||||
from collections import UserString
|
||||
assert \
|
||||
((isinstance(value, Sequence) or
|
||||
isinstance(value, Set) or
|
||||
isinstance(value, UserList)) and
|
||||
not isinstance(value, str) and
|
||||
not isinstance(value, UserString) and
|
||||
len(value) == 3 and
|
||||
all(isinstance(v, float) for v in value) and
|
||||
all(not (val < -1.7976931348623157e+308 or val > 1.7976931348623157e+308) or math.isinf(val) for val in value)), \
|
||||
"The 'tool_com_m' field must be a set or sequence with length 3 and each value of type 'float' and each double in [-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]"
|
||||
self._tool_com_m = numpy.array(value, dtype=numpy.float64)
|
||||
|
||||
|
||||
class Metaclass_SwitchTool(type):
|
||||
"""Metaclass of service 'SwitchTool'."""
|
||||
|
||||
_TYPE_SUPPORT = None
|
||||
|
||||
@classmethod
|
||||
def __import_type_support__(cls):
|
||||
try:
|
||||
from rosidl_generator_py import import_type_support
|
||||
module = import_type_support('arm_msgs')
|
||||
except ImportError:
|
||||
import logging
|
||||
import traceback
|
||||
logger = logging.getLogger(
|
||||
'arm_msgs.srv.SwitchTool')
|
||||
logger.debug(
|
||||
'Failed to import needed modules for type support:\n' +
|
||||
traceback.format_exc())
|
||||
else:
|
||||
cls._TYPE_SUPPORT = module.type_support_srv__srv__switch_tool
|
||||
|
||||
from arm_msgs.srv import _switch_tool
|
||||
if _switch_tool.Metaclass_SwitchTool_Request._TYPE_SUPPORT is None:
|
||||
_switch_tool.Metaclass_SwitchTool_Request.__import_type_support__()
|
||||
if _switch_tool.Metaclass_SwitchTool_Response._TYPE_SUPPORT is None:
|
||||
_switch_tool.Metaclass_SwitchTool_Response.__import_type_support__()
|
||||
|
||||
|
||||
class SwitchTool(metaclass=Metaclass_SwitchTool):
|
||||
from arm_msgs.srv._switch_tool import SwitchTool_Request as Request
|
||||
from arm_msgs.srv._switch_tool import SwitchTool_Response as Response
|
||||
|
||||
def __init__(self):
|
||||
raise NotImplementedError('Service classes can not be instantiated')
|
||||
@@ -0,0 +1,374 @@
|
||||
// generated from rosidl_generator_py/resource/_idl_support.c.em
|
||||
// with input from arm_msgs:srv/SwitchTool.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 "arm_msgs/srv/detail/switch_tool__struct.h"
|
||||
#include "arm_msgs/srv/detail/switch_tool__functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/string.h"
|
||||
#include "rosidl_runtime_c/string_functions.h"
|
||||
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__srv__switch_tool__request__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[45];
|
||||
{
|
||||
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("arm_msgs.srv._switch_tool.SwitchTool_Request", full_classname_dest, 44) == 0);
|
||||
}
|
||||
arm_msgs__srv__SwitchTool_Request * ros_message = _ros_message;
|
||||
{ // tool_name
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "tool_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->tool_name, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // sn
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "sn");
|
||||
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->sn, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__srv__switch_tool__request__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of SwitchTool_Request */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.srv._switch_tool");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "SwitchTool_Request");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__srv__SwitchTool_Request * ros_message = (arm_msgs__srv__SwitchTool_Request *)raw_ros_message;
|
||||
{ // tool_name
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->tool_name.data,
|
||||
strlen(ros_message->tool_name.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "tool_name", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // sn
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->sn.data,
|
||||
strlen(ros_message->sn.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "sn", 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 "arm_msgs/srv/detail/switch_tool__struct.h"
|
||||
// already included above
|
||||
// #include "arm_msgs/srv/detail/switch_tool__functions.h"
|
||||
|
||||
// already included above
|
||||
// #include "rosidl_runtime_c/string.h"
|
||||
// already included above
|
||||
// #include "rosidl_runtime_c/string_functions.h"
|
||||
|
||||
#include "rosidl_runtime_c/primitives_sequence.h"
|
||||
#include "rosidl_runtime_c/primitives_sequence_functions.h"
|
||||
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
bool arm_msgs__srv__switch_tool__response__convert_from_py(PyObject * _pymsg, void * _ros_message)
|
||||
{
|
||||
// check that the passed message is of the expected Python class
|
||||
{
|
||||
char full_classname_dest[46];
|
||||
{
|
||||
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("arm_msgs.srv._switch_tool.SwitchTool_Response", full_classname_dest, 45) == 0);
|
||||
}
|
||||
arm_msgs__srv__SwitchTool_Response * ros_message = _ros_message;
|
||||
{ // success
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "success");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyBool_Check(field));
|
||||
ros_message->success = (Py_True == field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // message
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "message");
|
||||
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->message, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // current_tool
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "current_tool");
|
||||
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->current_tool, PyBytes_AS_STRING(encoded_field));
|
||||
Py_DECREF(encoded_field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // tool_mass_kg
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "tool_mass_kg");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
assert(PyFloat_Check(field));
|
||||
ros_message->tool_mass_kg = PyFloat_AS_DOUBLE(field);
|
||||
Py_DECREF(field);
|
||||
}
|
||||
{ // tool_com_m
|
||||
PyObject * field = PyObject_GetAttrString(_pymsg, "tool_com_m");
|
||||
if (!field) {
|
||||
return false;
|
||||
}
|
||||
{
|
||||
// TODO(dirk-thomas) use a better way to check the type before casting
|
||||
assert(field->ob_type != NULL);
|
||||
assert(field->ob_type->tp_name != NULL);
|
||||
assert(strcmp(field->ob_type->tp_name, "numpy.ndarray") == 0);
|
||||
PyArrayObject * seq_field = (PyArrayObject *)field;
|
||||
Py_INCREF(seq_field);
|
||||
assert(PyArray_NDIM(seq_field) == 1);
|
||||
assert(PyArray_TYPE(seq_field) == NPY_FLOAT64);
|
||||
Py_ssize_t size = 3;
|
||||
double * dest = ros_message->tool_com_m;
|
||||
for (Py_ssize_t i = 0; i < size; ++i) {
|
||||
double tmp = *(npy_float64 *)PyArray_GETPTR1(seq_field, i);
|
||||
memcpy(&dest[i], &tmp, sizeof(double));
|
||||
}
|
||||
Py_DECREF(seq_field);
|
||||
}
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ROSIDL_GENERATOR_C_EXPORT
|
||||
PyObject * arm_msgs__srv__switch_tool__response__convert_to_py(void * raw_ros_message)
|
||||
{
|
||||
/* NOTE(esteve): Call constructor of SwitchTool_Response */
|
||||
PyObject * _pymessage = NULL;
|
||||
{
|
||||
PyObject * pymessage_module = PyImport_ImportModule("arm_msgs.srv._switch_tool");
|
||||
assert(pymessage_module);
|
||||
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "SwitchTool_Response");
|
||||
assert(pymessage_class);
|
||||
Py_DECREF(pymessage_module);
|
||||
_pymessage = PyObject_CallObject(pymessage_class, NULL);
|
||||
Py_DECREF(pymessage_class);
|
||||
if (!_pymessage) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
arm_msgs__srv__SwitchTool_Response * ros_message = (arm_msgs__srv__SwitchTool_Response *)raw_ros_message;
|
||||
{ // success
|
||||
PyObject * field = NULL;
|
||||
field = PyBool_FromLong(ros_message->success ? 1 : 0);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "success", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // message
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->message.data,
|
||||
strlen(ros_message->message.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "message", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // current_tool
|
||||
PyObject * field = NULL;
|
||||
field = PyUnicode_DecodeUTF8(
|
||||
ros_message->current_tool.data,
|
||||
strlen(ros_message->current_tool.data),
|
||||
"replace");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "current_tool", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // tool_mass_kg
|
||||
PyObject * field = NULL;
|
||||
field = PyFloat_FromDouble(ros_message->tool_mass_kg);
|
||||
{
|
||||
int rc = PyObject_SetAttrString(_pymessage, "tool_mass_kg", field);
|
||||
Py_DECREF(field);
|
||||
if (rc) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // tool_com_m
|
||||
PyObject * field = NULL;
|
||||
field = PyObject_GetAttrString(_pymessage, "tool_com_m");
|
||||
if (!field) {
|
||||
return NULL;
|
||||
}
|
||||
assert(field->ob_type != NULL);
|
||||
assert(field->ob_type->tp_name != NULL);
|
||||
assert(strcmp(field->ob_type->tp_name, "numpy.ndarray") == 0);
|
||||
PyArrayObject * seq_field = (PyArrayObject *)field;
|
||||
assert(PyArray_NDIM(seq_field) == 1);
|
||||
assert(PyArray_TYPE(seq_field) == NPY_FLOAT64);
|
||||
assert(sizeof(npy_float64) == sizeof(double));
|
||||
npy_float64 * dst = (npy_float64 *)PyArray_GETPTR1(seq_field, 0);
|
||||
double * src = &(ros_message->tool_com_m[0]);
|
||||
memcpy(dst, src, 3 * sizeof(double));
|
||||
Py_DECREF(field);
|
||||
}
|
||||
|
||||
// ownership of _pymessage is transferred to the caller
|
||||
return _pymessage;
|
||||
}
|
||||
Reference in New Issue
Block a user