remove package not working

This commit is contained in:
Sem van der Hoeven
2023-04-19 10:04:22 +00:00
parent c9c2add7c7
commit f6b74583c7
9136 changed files with 562508 additions and 596632 deletions

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/libpx4_msgs__python.so

Binary file not shown.

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/libpx4_msgs__rosidl_typesupport_fastrtps_c.so

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/libpx4_msgs__rosidl_typesupport_fastrtps_cpp.so

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/__init__.py

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/__init__.py

View File

@@ -0,0 +1,185 @@
from px4_msgs.msg._action_request import ActionRequest # noqa: F401
from px4_msgs.msg._actuator_armed import ActuatorArmed # noqa: F401
from px4_msgs.msg._actuator_controls_status import ActuatorControlsStatus # noqa: F401
from px4_msgs.msg._actuator_motors import ActuatorMotors # noqa: F401
from px4_msgs.msg._actuator_outputs import ActuatorOutputs # noqa: F401
from px4_msgs.msg._actuator_servos import ActuatorServos # noqa: F401
from px4_msgs.msg._actuator_servos_trim import ActuatorServosTrim # noqa: F401
from px4_msgs.msg._actuator_test import ActuatorTest # noqa: F401
from px4_msgs.msg._adc_report import AdcReport # noqa: F401
from px4_msgs.msg._airspeed import Airspeed # noqa: F401
from px4_msgs.msg._airspeed_validated import AirspeedValidated # noqa: F401
from px4_msgs.msg._airspeed_wind import AirspeedWind # noqa: F401
from px4_msgs.msg._autotune_attitude_control_status import AutotuneAttitudeControlStatus # noqa: F401
from px4_msgs.msg._battery_status import BatteryStatus # noqa: F401
from px4_msgs.msg._button_event import ButtonEvent # noqa: F401
from px4_msgs.msg._camera_capture import CameraCapture # noqa: F401
from px4_msgs.msg._camera_status import CameraStatus # noqa: F401
from px4_msgs.msg._camera_trigger import CameraTrigger # noqa: F401
from px4_msgs.msg._cellular_status import CellularStatus # noqa: F401
from px4_msgs.msg._collision_constraints import CollisionConstraints # noqa: F401
from px4_msgs.msg._collision_report import CollisionReport # noqa: F401
from px4_msgs.msg._control_allocator_status import ControlAllocatorStatus # noqa: F401
from px4_msgs.msg._cpuload import Cpuload # noqa: F401
from px4_msgs.msg._debug_array import DebugArray # noqa: F401
from px4_msgs.msg._debug_key_value import DebugKeyValue # noqa: F401
from px4_msgs.msg._debug_value import DebugValue # noqa: F401
from px4_msgs.msg._debug_vect import DebugVect # noqa: F401
from px4_msgs.msg._differential_pressure import DifferentialPressure # noqa: F401
from px4_msgs.msg._distance_sensor import DistanceSensor # noqa: F401
from px4_msgs.msg._ekf2_timestamps import Ekf2Timestamps # noqa: F401
from px4_msgs.msg._esc_report import EscReport # noqa: F401
from px4_msgs.msg._esc_status import EscStatus # noqa: F401
from px4_msgs.msg._estimator_aid_source1d import EstimatorAidSource1d # noqa: F401
from px4_msgs.msg._estimator_aid_source2d import EstimatorAidSource2d # noqa: F401
from px4_msgs.msg._estimator_aid_source3d import EstimatorAidSource3d # noqa: F401
from px4_msgs.msg._estimator_bias import EstimatorBias # noqa: F401
from px4_msgs.msg._estimator_bias3d import EstimatorBias3d # noqa: F401
from px4_msgs.msg._estimator_event_flags import EstimatorEventFlags # noqa: F401
from px4_msgs.msg._estimator_gps_status import EstimatorGpsStatus # noqa: F401
from px4_msgs.msg._estimator_innovations import EstimatorInnovations # noqa: F401
from px4_msgs.msg._estimator_selector_status import EstimatorSelectorStatus # noqa: F401
from px4_msgs.msg._estimator_sensor_bias import EstimatorSensorBias # noqa: F401
from px4_msgs.msg._estimator_states import EstimatorStates # noqa: F401
from px4_msgs.msg._estimator_status import EstimatorStatus # noqa: F401
from px4_msgs.msg._estimator_status_flags import EstimatorStatusFlags # noqa: F401
from px4_msgs.msg._event import Event # noqa: F401
from px4_msgs.msg._failsafe_flags import FailsafeFlags # noqa: F401
from px4_msgs.msg._failure_detector_status import FailureDetectorStatus # noqa: F401
from px4_msgs.msg._follow_target import FollowTarget # noqa: F401
from px4_msgs.msg._follow_target_estimator import FollowTargetEstimator # noqa: F401
from px4_msgs.msg._follow_target_status import FollowTargetStatus # noqa: F401
from px4_msgs.msg._generator_status import GeneratorStatus # noqa: F401
from px4_msgs.msg._geofence_result import GeofenceResult # noqa: F401
from px4_msgs.msg._gimbal_controls import GimbalControls # noqa: F401
from px4_msgs.msg._gimbal_device_attitude_status import GimbalDeviceAttitudeStatus # noqa: F401
from px4_msgs.msg._gimbal_device_information import GimbalDeviceInformation # noqa: F401
from px4_msgs.msg._gimbal_device_set_attitude import GimbalDeviceSetAttitude # noqa: F401
from px4_msgs.msg._gimbal_manager_information import GimbalManagerInformation # noqa: F401
from px4_msgs.msg._gimbal_manager_set_attitude import GimbalManagerSetAttitude # noqa: F401
from px4_msgs.msg._gimbal_manager_set_manual_control import GimbalManagerSetManualControl # noqa: F401
from px4_msgs.msg._gimbal_manager_status import GimbalManagerStatus # noqa: F401
from px4_msgs.msg._gps_dump import GpsDump # noqa: F401
from px4_msgs.msg._gps_inject_data import GpsInjectData # noqa: F401
from px4_msgs.msg._gripper import Gripper # noqa: F401
from px4_msgs.msg._health_report import HealthReport # noqa: F401
from px4_msgs.msg._heater_status import HeaterStatus # noqa: F401
from px4_msgs.msg._home_position import HomePosition # noqa: F401
from px4_msgs.msg._hover_thrust_estimate import HoverThrustEstimate # noqa: F401
from px4_msgs.msg._input_rc import InputRc # noqa: F401
from px4_msgs.msg._internal_combustion_engine_status import InternalCombustionEngineStatus # noqa: F401
from px4_msgs.msg._iridiumsbd_status import IridiumsbdStatus # noqa: F401
from px4_msgs.msg._irlock_report import IrlockReport # noqa: F401
from px4_msgs.msg._landing_gear import LandingGear # noqa: F401
from px4_msgs.msg._landing_gear_wheel import LandingGearWheel # noqa: F401
from px4_msgs.msg._landing_target_innovations import LandingTargetInnovations # noqa: F401
from px4_msgs.msg._landing_target_pose import LandingTargetPose # noqa: F401
from px4_msgs.msg._launch_detection_status import LaunchDetectionStatus # noqa: F401
from px4_msgs.msg._led_control import LedControl # noqa: F401
from px4_msgs.msg._log_message import LogMessage # noqa: F401
from px4_msgs.msg._logger_status import LoggerStatus # noqa: F401
from px4_msgs.msg._mag_worker_data import MagWorkerData # noqa: F401
from px4_msgs.msg._magnetometer_bias_estimate import MagnetometerBiasEstimate # noqa: F401
from px4_msgs.msg._manual_control_setpoint import ManualControlSetpoint # noqa: F401
from px4_msgs.msg._manual_control_switches import ManualControlSwitches # noqa: F401
from px4_msgs.msg._mavlink_log import MavlinkLog # noqa: F401
from px4_msgs.msg._mavlink_tunnel import MavlinkTunnel # noqa: F401
from px4_msgs.msg._mission import Mission # noqa: F401
from px4_msgs.msg._mission_result import MissionResult # noqa: F401
from px4_msgs.msg._mode_completed import ModeCompleted # noqa: F401
from px4_msgs.msg._mount_orientation import MountOrientation # noqa: F401
from px4_msgs.msg._navigator_mission_item import NavigatorMissionItem # noqa: F401
from px4_msgs.msg._normalized_unsigned_setpoint import NormalizedUnsignedSetpoint # noqa: F401
from px4_msgs.msg._npfg_status import NpfgStatus # noqa: F401
from px4_msgs.msg._obstacle_distance import ObstacleDistance # noqa: F401
from px4_msgs.msg._offboard_control_mode import OffboardControlMode # noqa: F401
from px4_msgs.msg._onboard_computer_status import OnboardComputerStatus # noqa: F401
from px4_msgs.msg._orb_test import OrbTest # noqa: F401
from px4_msgs.msg._orb_test_large import OrbTestLarge # noqa: F401
from px4_msgs.msg._orb_test_medium import OrbTestMedium # noqa: F401
from px4_msgs.msg._orbit_status import OrbitStatus # noqa: F401
from px4_msgs.msg._parameter_update import ParameterUpdate # noqa: F401
from px4_msgs.msg._ping import Ping # noqa: F401
from px4_msgs.msg._position_controller_landing_status import PositionControllerLandingStatus # noqa: F401
from px4_msgs.msg._position_controller_status import PositionControllerStatus # noqa: F401
from px4_msgs.msg._position_setpoint import PositionSetpoint # noqa: F401
from px4_msgs.msg._position_setpoint_triplet import PositionSetpointTriplet # noqa: F401
from px4_msgs.msg._power_button_state import PowerButtonState # noqa: F401
from px4_msgs.msg._power_monitor import PowerMonitor # noqa: F401
from px4_msgs.msg._pps_capture import PpsCapture # noqa: F401
from px4_msgs.msg._pwm_input import PwmInput # noqa: F401
from px4_msgs.msg._px4io_status import Px4ioStatus # noqa: F401
from px4_msgs.msg._qshell_req import QshellReq # noqa: F401
from px4_msgs.msg._qshell_retval import QshellRetval # noqa: F401
from px4_msgs.msg._radio_status import RadioStatus # noqa: F401
from px4_msgs.msg._rate_ctrl_status import RateCtrlStatus # noqa: F401
from px4_msgs.msg._rc_channels import RcChannels # noqa: F401
from px4_msgs.msg._rc_parameter_map import RcParameterMap # noqa: F401
from px4_msgs.msg._rpm import Rpm # noqa: F401
from px4_msgs.msg._rtl_time_estimate import RtlTimeEstimate # noqa: F401
from px4_msgs.msg._satellite_info import SatelliteInfo # noqa: F401
from px4_msgs.msg._sensor_accel import SensorAccel # noqa: F401
from px4_msgs.msg._sensor_accel_fifo import SensorAccelFifo # noqa: F401
from px4_msgs.msg._sensor_baro import SensorBaro # noqa: F401
from px4_msgs.msg._sensor_combined import SensorCombined # noqa: F401
from px4_msgs.msg._sensor_correction import SensorCorrection # noqa: F401
from px4_msgs.msg._sensor_gnss_relative import SensorGnssRelative # noqa: F401
from px4_msgs.msg._sensor_gps import SensorGps # noqa: F401
from px4_msgs.msg._sensor_gyro import SensorGyro # noqa: F401
from px4_msgs.msg._sensor_gyro_fft import SensorGyroFft # noqa: F401
from px4_msgs.msg._sensor_gyro_fifo import SensorGyroFifo # noqa: F401
from px4_msgs.msg._sensor_hygrometer import SensorHygrometer # noqa: F401
from px4_msgs.msg._sensor_mag import SensorMag # noqa: F401
from px4_msgs.msg._sensor_optical_flow import SensorOpticalFlow # noqa: F401
from px4_msgs.msg._sensor_preflight_mag import SensorPreflightMag # noqa: F401
from px4_msgs.msg._sensor_selection import SensorSelection # noqa: F401
from px4_msgs.msg._sensors_status import SensorsStatus # noqa: F401
from px4_msgs.msg._sensors_status_imu import SensorsStatusImu # noqa: F401
from px4_msgs.msg._system_power import SystemPower # noqa: F401
from px4_msgs.msg._takeoff_status import TakeoffStatus # noqa: F401
from px4_msgs.msg._task_stack_info import TaskStackInfo # noqa: F401
from px4_msgs.msg._tecs_status import TecsStatus # noqa: F401
from px4_msgs.msg._telemetry_status import TelemetryStatus # noqa: F401
from px4_msgs.msg._tiltrotor_extra_controls import TiltrotorExtraControls # noqa: F401
from px4_msgs.msg._timesync_status import TimesyncStatus # noqa: F401
from px4_msgs.msg._trajectory_bezier import TrajectoryBezier # noqa: F401
from px4_msgs.msg._trajectory_setpoint import TrajectorySetpoint # noqa: F401
from px4_msgs.msg._trajectory_waypoint import TrajectoryWaypoint # noqa: F401
from px4_msgs.msg._transponder_report import TransponderReport # noqa: F401
from px4_msgs.msg._tune_control import TuneControl # noqa: F401
from px4_msgs.msg._uavcan_parameter_request import UavcanParameterRequest # noqa: F401
from px4_msgs.msg._uavcan_parameter_value import UavcanParameterValue # noqa: F401
from px4_msgs.msg._ulog_stream import UlogStream # noqa: F401
from px4_msgs.msg._ulog_stream_ack import UlogStreamAck # noqa: F401
from px4_msgs.msg._uwb_distance import UwbDistance # noqa: F401
from px4_msgs.msg._uwb_grid import UwbGrid # noqa: F401
from px4_msgs.msg._vehicle_acceleration import VehicleAcceleration # noqa: F401
from px4_msgs.msg._vehicle_air_data import VehicleAirData # noqa: F401
from px4_msgs.msg._vehicle_angular_acceleration_setpoint import VehicleAngularAccelerationSetpoint # noqa: F401
from px4_msgs.msg._vehicle_angular_velocity import VehicleAngularVelocity # noqa: F401
from px4_msgs.msg._vehicle_attitude import VehicleAttitude # noqa: F401
from px4_msgs.msg._vehicle_attitude_setpoint import VehicleAttitudeSetpoint # noqa: F401
from px4_msgs.msg._vehicle_command import VehicleCommand # noqa: F401
from px4_msgs.msg._vehicle_command_ack import VehicleCommandAck # noqa: F401
from px4_msgs.msg._vehicle_constraints import VehicleConstraints # noqa: F401
from px4_msgs.msg._vehicle_control_mode import VehicleControlMode # noqa: F401
from px4_msgs.msg._vehicle_global_position import VehicleGlobalPosition # noqa: F401
from px4_msgs.msg._vehicle_imu import VehicleImu # noqa: F401
from px4_msgs.msg._vehicle_imu_status import VehicleImuStatus # noqa: F401
from px4_msgs.msg._vehicle_land_detected import VehicleLandDetected # noqa: F401
from px4_msgs.msg._vehicle_local_position import VehicleLocalPosition # noqa: F401
from px4_msgs.msg._vehicle_local_position_setpoint import VehicleLocalPositionSetpoint # noqa: F401
from px4_msgs.msg._vehicle_magnetometer import VehicleMagnetometer # noqa: F401
from px4_msgs.msg._vehicle_odometry import VehicleOdometry # noqa: F401
from px4_msgs.msg._vehicle_optical_flow import VehicleOpticalFlow # noqa: F401
from px4_msgs.msg._vehicle_optical_flow_vel import VehicleOpticalFlowVel # noqa: F401
from px4_msgs.msg._vehicle_rates_setpoint import VehicleRatesSetpoint # noqa: F401
from px4_msgs.msg._vehicle_roi import VehicleRoi # noqa: F401
from px4_msgs.msg._vehicle_status import VehicleStatus # noqa: F401
from px4_msgs.msg._vehicle_thrust_setpoint import VehicleThrustSetpoint # noqa: F401
from px4_msgs.msg._vehicle_torque_setpoint import VehicleTorqueSetpoint # noqa: F401
from px4_msgs.msg._vehicle_trajectory_bezier import VehicleTrajectoryBezier # noqa: F401
from px4_msgs.msg._vehicle_trajectory_waypoint import VehicleTrajectoryWaypoint # noqa: F401
from px4_msgs.msg._vtol_vehicle_status import VtolVehicleStatus # noqa: F401
from px4_msgs.msg._wind import Wind # noqa: F401
from px4_msgs.msg._yaw_estimator_status import YawEstimatorStatus # noqa: F401

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_action_request.py

View File

@@ -0,0 +1,287 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/ActionRequest.idl
# generated code does not contain a copyright notice
# Import statements for member types
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_ActionRequest(type):
"""Metaclass of message 'ActionRequest'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'ACTION_DISARM': 0,
'ACTION_ARM': 1,
'ACTION_TOGGLE_ARMING': 2,
'ACTION_UNKILL': 3,
'ACTION_KILL': 4,
'ACTION_SWITCH_MODE': 5,
'ACTION_VTOL_TRANSITION_TO_MULTICOPTER': 6,
'ACTION_VTOL_TRANSITION_TO_FIXEDWING': 7,
'SOURCE_RC_STICK_GESTURE': 0,
'SOURCE_RC_SWITCH': 1,
'SOURCE_RC_BUTTON': 2,
'SOURCE_RC_MODE_SLOT': 3,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.ActionRequest')
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__action_request
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__action_request
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__action_request
cls._TYPE_SUPPORT = module.type_support_msg__msg__action_request
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__action_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 {
'ACTION_DISARM': cls.__constants['ACTION_DISARM'],
'ACTION_ARM': cls.__constants['ACTION_ARM'],
'ACTION_TOGGLE_ARMING': cls.__constants['ACTION_TOGGLE_ARMING'],
'ACTION_UNKILL': cls.__constants['ACTION_UNKILL'],
'ACTION_KILL': cls.__constants['ACTION_KILL'],
'ACTION_SWITCH_MODE': cls.__constants['ACTION_SWITCH_MODE'],
'ACTION_VTOL_TRANSITION_TO_MULTICOPTER': cls.__constants['ACTION_VTOL_TRANSITION_TO_MULTICOPTER'],
'ACTION_VTOL_TRANSITION_TO_FIXEDWING': cls.__constants['ACTION_VTOL_TRANSITION_TO_FIXEDWING'],
'SOURCE_RC_STICK_GESTURE': cls.__constants['SOURCE_RC_STICK_GESTURE'],
'SOURCE_RC_SWITCH': cls.__constants['SOURCE_RC_SWITCH'],
'SOURCE_RC_BUTTON': cls.__constants['SOURCE_RC_BUTTON'],
'SOURCE_RC_MODE_SLOT': cls.__constants['SOURCE_RC_MODE_SLOT'],
}
@property
def ACTION_DISARM(self):
"""Message constant 'ACTION_DISARM'."""
return Metaclass_ActionRequest.__constants['ACTION_DISARM']
@property
def ACTION_ARM(self):
"""Message constant 'ACTION_ARM'."""
return Metaclass_ActionRequest.__constants['ACTION_ARM']
@property
def ACTION_TOGGLE_ARMING(self):
"""Message constant 'ACTION_TOGGLE_ARMING'."""
return Metaclass_ActionRequest.__constants['ACTION_TOGGLE_ARMING']
@property
def ACTION_UNKILL(self):
"""Message constant 'ACTION_UNKILL'."""
return Metaclass_ActionRequest.__constants['ACTION_UNKILL']
@property
def ACTION_KILL(self):
"""Message constant 'ACTION_KILL'."""
return Metaclass_ActionRequest.__constants['ACTION_KILL']
@property
def ACTION_SWITCH_MODE(self):
"""Message constant 'ACTION_SWITCH_MODE'."""
return Metaclass_ActionRequest.__constants['ACTION_SWITCH_MODE']
@property
def ACTION_VTOL_TRANSITION_TO_MULTICOPTER(self):
"""Message constant 'ACTION_VTOL_TRANSITION_TO_MULTICOPTER'."""
return Metaclass_ActionRequest.__constants['ACTION_VTOL_TRANSITION_TO_MULTICOPTER']
@property
def ACTION_VTOL_TRANSITION_TO_FIXEDWING(self):
"""Message constant 'ACTION_VTOL_TRANSITION_TO_FIXEDWING'."""
return Metaclass_ActionRequest.__constants['ACTION_VTOL_TRANSITION_TO_FIXEDWING']
@property
def SOURCE_RC_STICK_GESTURE(self):
"""Message constant 'SOURCE_RC_STICK_GESTURE'."""
return Metaclass_ActionRequest.__constants['SOURCE_RC_STICK_GESTURE']
@property
def SOURCE_RC_SWITCH(self):
"""Message constant 'SOURCE_RC_SWITCH'."""
return Metaclass_ActionRequest.__constants['SOURCE_RC_SWITCH']
@property
def SOURCE_RC_BUTTON(self):
"""Message constant 'SOURCE_RC_BUTTON'."""
return Metaclass_ActionRequest.__constants['SOURCE_RC_BUTTON']
@property
def SOURCE_RC_MODE_SLOT(self):
"""Message constant 'SOURCE_RC_MODE_SLOT'."""
return Metaclass_ActionRequest.__constants['SOURCE_RC_MODE_SLOT']
class ActionRequest(metaclass=Metaclass_ActionRequest):
"""
Message class 'ActionRequest'.
Constants:
ACTION_DISARM
ACTION_ARM
ACTION_TOGGLE_ARMING
ACTION_UNKILL
ACTION_KILL
ACTION_SWITCH_MODE
ACTION_VTOL_TRANSITION_TO_MULTICOPTER
ACTION_VTOL_TRANSITION_TO_FIXEDWING
SOURCE_RC_STICK_GESTURE
SOURCE_RC_SWITCH
SOURCE_RC_BUTTON
SOURCE_RC_MODE_SLOT
"""
__slots__ = [
'_timestamp',
'_action',
'_source',
'_mode',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'action': 'uint8',
'source': 'uint8',
'mode': 'uint8',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
)
def __init__(self, **kwargs):
assert all('_' + key in self.__slots__ for key in kwargs.keys()), \
'Invalid arguments passed to constructor: %s' % \
', '.join(sorted(k for k in kwargs.keys() if '_' + k not in self.__slots__))
self.timestamp = kwargs.get('timestamp', int())
self.action = kwargs.get('action', int())
self.source = kwargs.get('source', int())
self.mode = kwargs.get('mode', int())
def __repr__(self):
typename = self.__class__.__module__.split('.')
typename.pop()
typename.append(self.__class__.__name__)
args = []
for s, t in zip(self.__slots__, self.SLOT_TYPES):
field = getattr(self, s)
fieldstr = repr(field)
# We use Python array type for fields that can be directly stored
# in them, and "normal" sequences for everything else. If it is
# a type that we store in an array, strip off the 'array' portion.
if (
isinstance(t, rosidl_parser.definition.AbstractSequence) and
isinstance(t.value_type, rosidl_parser.definition.BasicType) and
t.value_type.typename in ['float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64']
):
if len(field) == 0:
fieldstr = '[]'
else:
assert fieldstr.startswith('array(')
prefix = "array('X', "
suffix = ')'
fieldstr = fieldstr[len(prefix):-len(suffix)]
args.append(s[1:] + '=' + fieldstr)
return '%s(%s)' % ('.'.join(typename), ', '.join(args))
def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
if self.timestamp != other.timestamp:
return False
if self.action != other.action:
return False
if self.source != other.source:
return False
if self.mode != other.mode:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def action(self):
"""Message field 'action'."""
return self._action
@action.setter
def action(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'action' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'action' field must be an unsigned integer in [0, 255]"
self._action = value
@property
def source(self):
"""Message field 'source'."""
return self._source
@source.setter
def source(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'source' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'source' field must be an unsigned integer in [0, 255]"
self._source = value
@property
def mode(self):
"""Message field 'mode'."""
return self._mode
@mode.setter
def mode(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'mode' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'mode' field must be an unsigned integer in [0, 255]"
self._mode = value

View File

@@ -0,0 +1,158 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/ActionRequest.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 "px4_msgs/msg/detail/action_request__struct.h"
#include "px4_msgs/msg/detail/action_request__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__action_request__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("px4_msgs.msg._action_request.ActionRequest", full_classname_dest, 42) == 0);
}
px4_msgs__msg__ActionRequest * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // action
PyObject * field = PyObject_GetAttrString(_pymsg, "action");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->action = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // source
PyObject * field = PyObject_GetAttrString(_pymsg, "source");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->source = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // mode
PyObject * field = PyObject_GetAttrString(_pymsg, "mode");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->mode = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__action_request__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of ActionRequest */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._action_request");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "ActionRequest");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__ActionRequest * ros_message = (px4_msgs__msg__ActionRequest *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // action
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->action);
{
int rc = PyObject_SetAttrString(_pymessage, "action", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // source
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->source);
{
int rc = PyObject_SetAttrString(_pymessage, "source", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // mode
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->mode);
{
int rc = PyObject_SetAttrString(_pymessage, "mode", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_armed.py

View File

@@ -0,0 +1,257 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/ActuatorArmed.idl
# generated code does not contain a copyright notice
# Import statements for member types
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_ActuatorArmed(type):
"""Metaclass of message 'ActuatorArmed'."""
_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('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.ActuatorArmed')
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__actuator_armed
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__actuator_armed
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__actuator_armed
cls._TYPE_SUPPORT = module.type_support_msg__msg__actuator_armed
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__actuator_armed
@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 ActuatorArmed(metaclass=Metaclass_ActuatorArmed):
"""Message class 'ActuatorArmed'."""
__slots__ = [
'_timestamp',
'_armed',
'_prearmed',
'_ready_to_arm',
'_lockdown',
'_manual_lockdown',
'_force_failsafe',
'_in_esc_calibration_mode',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'armed': 'boolean',
'prearmed': 'boolean',
'ready_to_arm': 'boolean',
'lockdown': 'boolean',
'manual_lockdown': 'boolean',
'force_failsafe': 'boolean',
'in_esc_calibration_mode': 'boolean',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # 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('boolean'), # noqa: E501
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
rosidl_parser.definition.BasicType('boolean'), # 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.timestamp = kwargs.get('timestamp', int())
self.armed = kwargs.get('armed', bool())
self.prearmed = kwargs.get('prearmed', bool())
self.ready_to_arm = kwargs.get('ready_to_arm', bool())
self.lockdown = kwargs.get('lockdown', bool())
self.manual_lockdown = kwargs.get('manual_lockdown', bool())
self.force_failsafe = kwargs.get('force_failsafe', bool())
self.in_esc_calibration_mode = kwargs.get('in_esc_calibration_mode', bool())
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.timestamp != other.timestamp:
return False
if self.armed != other.armed:
return False
if self.prearmed != other.prearmed:
return False
if self.ready_to_arm != other.ready_to_arm:
return False
if self.lockdown != other.lockdown:
return False
if self.manual_lockdown != other.manual_lockdown:
return False
if self.force_failsafe != other.force_failsafe:
return False
if self.in_esc_calibration_mode != other.in_esc_calibration_mode:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def armed(self):
"""Message field 'armed'."""
return self._armed
@armed.setter
def armed(self, value):
if __debug__:
assert \
isinstance(value, bool), \
"The 'armed' field must be of type 'bool'"
self._armed = value
@property
def prearmed(self):
"""Message field 'prearmed'."""
return self._prearmed
@prearmed.setter
def prearmed(self, value):
if __debug__:
assert \
isinstance(value, bool), \
"The 'prearmed' field must be of type 'bool'"
self._prearmed = value
@property
def ready_to_arm(self):
"""Message field 'ready_to_arm'."""
return self._ready_to_arm
@ready_to_arm.setter
def ready_to_arm(self, value):
if __debug__:
assert \
isinstance(value, bool), \
"The 'ready_to_arm' field must be of type 'bool'"
self._ready_to_arm = value
@property
def lockdown(self):
"""Message field 'lockdown'."""
return self._lockdown
@lockdown.setter
def lockdown(self, value):
if __debug__:
assert \
isinstance(value, bool), \
"The 'lockdown' field must be of type 'bool'"
self._lockdown = value
@property
def manual_lockdown(self):
"""Message field 'manual_lockdown'."""
return self._manual_lockdown
@manual_lockdown.setter
def manual_lockdown(self, value):
if __debug__:
assert \
isinstance(value, bool), \
"The 'manual_lockdown' field must be of type 'bool'"
self._manual_lockdown = value
@property
def force_failsafe(self):
"""Message field 'force_failsafe'."""
return self._force_failsafe
@force_failsafe.setter
def force_failsafe(self, value):
if __debug__:
assert \
isinstance(value, bool), \
"The 'force_failsafe' field must be of type 'bool'"
self._force_failsafe = value
@property
def in_esc_calibration_mode(self):
"""Message field 'in_esc_calibration_mode'."""
return self._in_esc_calibration_mode
@in_esc_calibration_mode.setter
def in_esc_calibration_mode(self, value):
if __debug__:
assert \
isinstance(value, bool), \
"The 'in_esc_calibration_mode' field must be of type 'bool'"
self._in_esc_calibration_mode = value

View File

@@ -0,0 +1,238 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/ActuatorArmed.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 "px4_msgs/msg/detail/actuator_armed__struct.h"
#include "px4_msgs/msg/detail/actuator_armed__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__actuator_armed__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("px4_msgs.msg._actuator_armed.ActuatorArmed", full_classname_dest, 42) == 0);
}
px4_msgs__msg__ActuatorArmed * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // armed
PyObject * field = PyObject_GetAttrString(_pymsg, "armed");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->armed = (Py_True == field);
Py_DECREF(field);
}
{ // prearmed
PyObject * field = PyObject_GetAttrString(_pymsg, "prearmed");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->prearmed = (Py_True == field);
Py_DECREF(field);
}
{ // ready_to_arm
PyObject * field = PyObject_GetAttrString(_pymsg, "ready_to_arm");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->ready_to_arm = (Py_True == field);
Py_DECREF(field);
}
{ // lockdown
PyObject * field = PyObject_GetAttrString(_pymsg, "lockdown");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->lockdown = (Py_True == field);
Py_DECREF(field);
}
{ // manual_lockdown
PyObject * field = PyObject_GetAttrString(_pymsg, "manual_lockdown");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->manual_lockdown = (Py_True == field);
Py_DECREF(field);
}
{ // force_failsafe
PyObject * field = PyObject_GetAttrString(_pymsg, "force_failsafe");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->force_failsafe = (Py_True == field);
Py_DECREF(field);
}
{ // in_esc_calibration_mode
PyObject * field = PyObject_GetAttrString(_pymsg, "in_esc_calibration_mode");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->in_esc_calibration_mode = (Py_True == field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__actuator_armed__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of ActuatorArmed */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._actuator_armed");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "ActuatorArmed");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__ActuatorArmed * ros_message = (px4_msgs__msg__ActuatorArmed *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // armed
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->armed ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "armed", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // prearmed
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->prearmed ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "prearmed", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // ready_to_arm
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->ready_to_arm ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "ready_to_arm", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // lockdown
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->lockdown ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "lockdown", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // manual_lockdown
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->manual_lockdown ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "manual_lockdown", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // force_failsafe
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->force_failsafe ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "force_failsafe", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // in_esc_calibration_mode
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->in_esc_calibration_mode ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "in_esc_calibration_mode", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_controls.py

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_controls0.py

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_controls1.py

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_controls2.py

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_controls3.py

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_controls_status.py

View File

@@ -0,0 +1,168 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/ActuatorControlsStatus.idl
# generated code does not contain a copyright notice
# Import statements for member types
# Member 'control_power'
import numpy # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_ActuatorControlsStatus(type):
"""Metaclass of message 'ActuatorControlsStatus'."""
_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('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.ActuatorControlsStatus')
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__actuator_controls_status
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__actuator_controls_status
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__actuator_controls_status
cls._TYPE_SUPPORT = module.type_support_msg__msg__actuator_controls_status
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__actuator_controls_status
@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 ActuatorControlsStatus(metaclass=Metaclass_ActuatorControlsStatus):
"""Message class 'ActuatorControlsStatus'."""
__slots__ = [
'_timestamp',
'_control_power',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'control_power': 'float[3]',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 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.timestamp = kwargs.get('timestamp', int())
if 'control_power' not in kwargs:
self.control_power = numpy.zeros(3, dtype=numpy.float32)
else:
self.control_power = numpy.array(kwargs.get('control_power'), dtype=numpy.float32)
assert self.control_power.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.timestamp != other.timestamp:
return False
if all(self.control_power != other.control_power):
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def control_power(self):
"""Message field 'control_power'."""
return self._control_power
@control_power.setter
def control_power(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'control_power' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 3, \
"The 'control_power' numpy.ndarray() must have a size of 3"
self._control_power = 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
True), \
"The 'control_power' field must be a set or sequence with length 3 and each value of type 'float'"
self._control_power = numpy.array(value, dtype=numpy.float32)

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_controls_status0.py

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_controls_status1.py

View File

@@ -0,0 +1,143 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/ActuatorControlsStatus.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 "px4_msgs/msg/detail/actuator_controls_status__struct.h"
#include "px4_msgs/msg/detail/actuator_controls_status__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__actuator_controls_status__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[62];
{
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("px4_msgs.msg._actuator_controls_status.ActuatorControlsStatus", full_classname_dest, 61) == 0);
}
px4_msgs__msg__ActuatorControlsStatus * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // control_power
PyObject * field = PyObject_GetAttrString(_pymsg, "control_power");
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_FLOAT32);
Py_ssize_t size = 3;
float * dest = ros_message->control_power;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__actuator_controls_status__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of ActuatorControlsStatus */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._actuator_controls_status");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "ActuatorControlsStatus");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__ActuatorControlsStatus * ros_message = (px4_msgs__msg__ActuatorControlsStatus *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // control_power
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "control_power");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->control_power[0]);
memcpy(dst, src, 3 * sizeof(float));
Py_DECREF(field);
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_controls_virtual_fw.py

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_controls_virtual_mc.py

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_motors.py

View File

@@ -0,0 +1,230 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/ActuatorMotors.idl
# generated code does not contain a copyright notice
# Import statements for member types
# Member 'control'
import numpy # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_ActuatorMotors(type):
"""Metaclass of message 'ActuatorMotors'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'ACTUATOR_FUNCTION_MOTOR1': 101,
'NUM_CONTROLS': 12,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.ActuatorMotors')
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__actuator_motors
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__actuator_motors
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__actuator_motors
cls._TYPE_SUPPORT = module.type_support_msg__msg__actuator_motors
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__actuator_motors
@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 {
'ACTUATOR_FUNCTION_MOTOR1': cls.__constants['ACTUATOR_FUNCTION_MOTOR1'],
'NUM_CONTROLS': cls.__constants['NUM_CONTROLS'],
}
@property
def ACTUATOR_FUNCTION_MOTOR1(self):
"""Message constant 'ACTUATOR_FUNCTION_MOTOR1'."""
return Metaclass_ActuatorMotors.__constants['ACTUATOR_FUNCTION_MOTOR1']
@property
def NUM_CONTROLS(self):
"""Message constant 'NUM_CONTROLS'."""
return Metaclass_ActuatorMotors.__constants['NUM_CONTROLS']
class ActuatorMotors(metaclass=Metaclass_ActuatorMotors):
"""
Message class 'ActuatorMotors'.
Constants:
ACTUATOR_FUNCTION_MOTOR1
NUM_CONTROLS
"""
__slots__ = [
'_timestamp',
'_timestamp_sample',
'_reversible_flags',
'_control',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'timestamp_sample': 'uint64',
'reversible_flags': 'uint16',
'control': 'float[12]',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint16'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 12), # 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.timestamp = kwargs.get('timestamp', int())
self.timestamp_sample = kwargs.get('timestamp_sample', int())
self.reversible_flags = kwargs.get('reversible_flags', int())
if 'control' not in kwargs:
self.control = numpy.zeros(12, dtype=numpy.float32)
else:
self.control = numpy.array(kwargs.get('control'), dtype=numpy.float32)
assert self.control.shape == (12, )
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.timestamp != other.timestamp:
return False
if self.timestamp_sample != other.timestamp_sample:
return False
if self.reversible_flags != other.reversible_flags:
return False
if all(self.control != other.control):
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def timestamp_sample(self):
"""Message field 'timestamp_sample'."""
return self._timestamp_sample
@timestamp_sample.setter
def timestamp_sample(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp_sample' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp_sample' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp_sample = value
@property
def reversible_flags(self):
"""Message field 'reversible_flags'."""
return self._reversible_flags
@reversible_flags.setter
def reversible_flags(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'reversible_flags' field must be of type 'int'"
assert value >= 0 and value < 65536, \
"The 'reversible_flags' field must be an unsigned integer in [0, 65535]"
self._reversible_flags = value
@property
def control(self):
"""Message field 'control'."""
return self._control
@control.setter
def control(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'control' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 12, \
"The 'control' numpy.ndarray() must have a size of 12"
self._control = 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) == 12 and
all(isinstance(v, float) for v in value) and
True), \
"The 'control' field must be a set or sequence with length 12 and each value of type 'float'"
self._control = numpy.array(value, dtype=numpy.float32)

View File

@@ -0,0 +1,183 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/ActuatorMotors.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 "px4_msgs/msg/detail/actuator_motors__struct.h"
#include "px4_msgs/msg/detail/actuator_motors__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__actuator_motors__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("px4_msgs.msg._actuator_motors.ActuatorMotors", full_classname_dest, 44) == 0);
}
px4_msgs__msg__ActuatorMotors * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // timestamp_sample
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp_sample");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp_sample = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // reversible_flags
PyObject * field = PyObject_GetAttrString(_pymsg, "reversible_flags");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->reversible_flags = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // control
PyObject * field = PyObject_GetAttrString(_pymsg, "control");
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_FLOAT32);
Py_ssize_t size = 12;
float * dest = ros_message->control;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__actuator_motors__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of ActuatorMotors */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._actuator_motors");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "ActuatorMotors");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__ActuatorMotors * ros_message = (px4_msgs__msg__ActuatorMotors *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // timestamp_sample
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp_sample);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp_sample", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // reversible_flags
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->reversible_flags);
{
int rc = PyObject_SetAttrString(_pymessage, "reversible_flags", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // control
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "control");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->control[0]);
memcpy(dst, src, 12 * sizeof(float));
Py_DECREF(field);
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_outputs.py

View File

@@ -0,0 +1,209 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/ActuatorOutputs.idl
# generated code does not contain a copyright notice
# Import statements for member types
# Member 'output'
import numpy # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_ActuatorOutputs(type):
"""Metaclass of message 'ActuatorOutputs'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'NUM_ACTUATOR_OUTPUTS': 16,
'NUM_ACTUATOR_OUTPUT_GROUPS': 4,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.ActuatorOutputs')
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__actuator_outputs
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__actuator_outputs
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__actuator_outputs
cls._TYPE_SUPPORT = module.type_support_msg__msg__actuator_outputs
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__actuator_outputs
@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 {
'NUM_ACTUATOR_OUTPUTS': cls.__constants['NUM_ACTUATOR_OUTPUTS'],
'NUM_ACTUATOR_OUTPUT_GROUPS': cls.__constants['NUM_ACTUATOR_OUTPUT_GROUPS'],
}
@property
def NUM_ACTUATOR_OUTPUTS(self):
"""Message constant 'NUM_ACTUATOR_OUTPUTS'."""
return Metaclass_ActuatorOutputs.__constants['NUM_ACTUATOR_OUTPUTS']
@property
def NUM_ACTUATOR_OUTPUT_GROUPS(self):
"""Message constant 'NUM_ACTUATOR_OUTPUT_GROUPS'."""
return Metaclass_ActuatorOutputs.__constants['NUM_ACTUATOR_OUTPUT_GROUPS']
class ActuatorOutputs(metaclass=Metaclass_ActuatorOutputs):
"""
Message class 'ActuatorOutputs'.
Constants:
NUM_ACTUATOR_OUTPUTS
NUM_ACTUATOR_OUTPUT_GROUPS
"""
__slots__ = [
'_timestamp',
'_noutputs',
'_output',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'noutputs': 'uint32',
'output': 'float[16]',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint32'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 16), # 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.timestamp = kwargs.get('timestamp', int())
self.noutputs = kwargs.get('noutputs', int())
if 'output' not in kwargs:
self.output = numpy.zeros(16, dtype=numpy.float32)
else:
self.output = numpy.array(kwargs.get('output'), dtype=numpy.float32)
assert self.output.shape == (16, )
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.timestamp != other.timestamp:
return False
if self.noutputs != other.noutputs:
return False
if all(self.output != other.output):
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def noutputs(self):
"""Message field 'noutputs'."""
return self._noutputs
@noutputs.setter
def noutputs(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'noutputs' field must be of type 'int'"
assert value >= 0 and value < 4294967296, \
"The 'noutputs' field must be an unsigned integer in [0, 4294967295]"
self._noutputs = value
@property
def output(self):
"""Message field 'output'."""
return self._output
@output.setter
def output(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'output' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 16, \
"The 'output' numpy.ndarray() must have a size of 16"
self._output = 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) == 16 and
all(isinstance(v, float) for v in value) and
True), \
"The 'output' field must be a set or sequence with length 16 and each value of type 'float'"
self._output = numpy.array(value, dtype=numpy.float32)

View File

@@ -0,0 +1,163 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/ActuatorOutputs.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 "px4_msgs/msg/detail/actuator_outputs__struct.h"
#include "px4_msgs/msg/detail/actuator_outputs__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__actuator_outputs__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[47];
{
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("px4_msgs.msg._actuator_outputs.ActuatorOutputs", full_classname_dest, 46) == 0);
}
px4_msgs__msg__ActuatorOutputs * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // noutputs
PyObject * field = PyObject_GetAttrString(_pymsg, "noutputs");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->noutputs = PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // output
PyObject * field = PyObject_GetAttrString(_pymsg, "output");
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_FLOAT32);
Py_ssize_t size = 16;
float * dest = ros_message->output;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__actuator_outputs__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of ActuatorOutputs */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._actuator_outputs");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "ActuatorOutputs");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__ActuatorOutputs * ros_message = (px4_msgs__msg__ActuatorOutputs *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // noutputs
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->noutputs);
{
int rc = PyObject_SetAttrString(_pymessage, "noutputs", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // output
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "output");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->output[0]);
memcpy(dst, src, 16 * sizeof(float));
Py_DECREF(field);
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_outputs_sim.py

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_servos.py

View File

@@ -0,0 +1,201 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/ActuatorServos.idl
# generated code does not contain a copyright notice
# Import statements for member types
# Member 'control'
import numpy # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_ActuatorServos(type):
"""Metaclass of message 'ActuatorServos'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'NUM_CONTROLS': 8,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.ActuatorServos')
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__actuator_servos
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__actuator_servos
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__actuator_servos
cls._TYPE_SUPPORT = module.type_support_msg__msg__actuator_servos
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__actuator_servos
@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 {
'NUM_CONTROLS': cls.__constants['NUM_CONTROLS'],
}
@property
def NUM_CONTROLS(self):
"""Message constant 'NUM_CONTROLS'."""
return Metaclass_ActuatorServos.__constants['NUM_CONTROLS']
class ActuatorServos(metaclass=Metaclass_ActuatorServos):
"""
Message class 'ActuatorServos'.
Constants:
NUM_CONTROLS
"""
__slots__ = [
'_timestamp',
'_timestamp_sample',
'_control',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'timestamp_sample': 'uint64',
'control': 'float[8]',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 8), # 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.timestamp = kwargs.get('timestamp', int())
self.timestamp_sample = kwargs.get('timestamp_sample', int())
if 'control' not in kwargs:
self.control = numpy.zeros(8, dtype=numpy.float32)
else:
self.control = numpy.array(kwargs.get('control'), dtype=numpy.float32)
assert self.control.shape == (8, )
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.timestamp != other.timestamp:
return False
if self.timestamp_sample != other.timestamp_sample:
return False
if all(self.control != other.control):
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def timestamp_sample(self):
"""Message field 'timestamp_sample'."""
return self._timestamp_sample
@timestamp_sample.setter
def timestamp_sample(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp_sample' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp_sample' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp_sample = value
@property
def control(self):
"""Message field 'control'."""
return self._control
@control.setter
def control(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'control' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 8, \
"The 'control' numpy.ndarray() must have a size of 8"
self._control = 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) == 8 and
all(isinstance(v, float) for v in value) and
True), \
"The 'control' field must be a set or sequence with length 8 and each value of type 'float'"
self._control = numpy.array(value, dtype=numpy.float32)

View File

@@ -0,0 +1,163 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/ActuatorServos.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 "px4_msgs/msg/detail/actuator_servos__struct.h"
#include "px4_msgs/msg/detail/actuator_servos__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__actuator_servos__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("px4_msgs.msg._actuator_servos.ActuatorServos", full_classname_dest, 44) == 0);
}
px4_msgs__msg__ActuatorServos * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // timestamp_sample
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp_sample");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp_sample = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // control
PyObject * field = PyObject_GetAttrString(_pymsg, "control");
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_FLOAT32);
Py_ssize_t size = 8;
float * dest = ros_message->control;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__actuator_servos__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of ActuatorServos */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._actuator_servos");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "ActuatorServos");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__ActuatorServos * ros_message = (px4_msgs__msg__ActuatorServos *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // timestamp_sample
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp_sample);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp_sample", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // control
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "control");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->control[0]);
memcpy(dst, src, 8 * sizeof(float));
Py_DECREF(field);
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_servos_trim.py

View File

@@ -0,0 +1,180 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/ActuatorServosTrim.idl
# generated code does not contain a copyright notice
# Import statements for member types
# Member 'trim'
import numpy # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_ActuatorServosTrim(type):
"""Metaclass of message 'ActuatorServosTrim'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'NUM_CONTROLS': 8,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.ActuatorServosTrim')
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__actuator_servos_trim
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__actuator_servos_trim
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__actuator_servos_trim
cls._TYPE_SUPPORT = module.type_support_msg__msg__actuator_servos_trim
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__actuator_servos_trim
@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 {
'NUM_CONTROLS': cls.__constants['NUM_CONTROLS'],
}
@property
def NUM_CONTROLS(self):
"""Message constant 'NUM_CONTROLS'."""
return Metaclass_ActuatorServosTrim.__constants['NUM_CONTROLS']
class ActuatorServosTrim(metaclass=Metaclass_ActuatorServosTrim):
"""
Message class 'ActuatorServosTrim'.
Constants:
NUM_CONTROLS
"""
__slots__ = [
'_timestamp',
'_trim',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'trim': 'float[8]',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 8), # 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.timestamp = kwargs.get('timestamp', int())
if 'trim' not in kwargs:
self.trim = numpy.zeros(8, dtype=numpy.float32)
else:
self.trim = numpy.array(kwargs.get('trim'), dtype=numpy.float32)
assert self.trim.shape == (8, )
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.timestamp != other.timestamp:
return False
if all(self.trim != other.trim):
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def trim(self):
"""Message field 'trim'."""
return self._trim
@trim.setter
def trim(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'trim' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 8, \
"The 'trim' numpy.ndarray() must have a size of 8"
self._trim = 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) == 8 and
all(isinstance(v, float) for v in value) and
True), \
"The 'trim' field must be a set or sequence with length 8 and each value of type 'float'"
self._trim = numpy.array(value, dtype=numpy.float32)

View File

@@ -0,0 +1,143 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/ActuatorServosTrim.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 "px4_msgs/msg/detail/actuator_servos_trim__struct.h"
#include "px4_msgs/msg/detail/actuator_servos_trim__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__actuator_servos_trim__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("px4_msgs.msg._actuator_servos_trim.ActuatorServosTrim", full_classname_dest, 53) == 0);
}
px4_msgs__msg__ActuatorServosTrim * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // trim
PyObject * field = PyObject_GetAttrString(_pymsg, "trim");
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_FLOAT32);
Py_ssize_t size = 8;
float * dest = ros_message->trim;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__actuator_servos_trim__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of ActuatorServosTrim */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._actuator_servos_trim");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "ActuatorServosTrim");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__ActuatorServosTrim * ros_message = (px4_msgs__msg__ActuatorServosTrim *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // trim
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "trim");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->trim[0]);
memcpy(dst, src, 8 * sizeof(float));
Py_DECREF(field);
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_actuator_test.py

View File

@@ -0,0 +1,266 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/ActuatorTest.idl
# generated code does not contain a copyright notice
# Import statements for member types
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_ActuatorTest(type):
"""Metaclass of message 'ActuatorTest'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'ACTION_RELEASE_CONTROL': 0,
'ACTION_DO_CONTROL': 1,
'FUNCTION_MOTOR1': 101,
'MAX_NUM_MOTORS': 12,
'FUNCTION_SERVO1': 201,
'MAX_NUM_SERVOS': 8,
'ORB_QUEUE_LENGTH': 12,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.ActuatorTest')
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__actuator_test
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__actuator_test
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__actuator_test
cls._TYPE_SUPPORT = module.type_support_msg__msg__actuator_test
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__actuator_test
@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 {
'ACTION_RELEASE_CONTROL': cls.__constants['ACTION_RELEASE_CONTROL'],
'ACTION_DO_CONTROL': cls.__constants['ACTION_DO_CONTROL'],
'FUNCTION_MOTOR1': cls.__constants['FUNCTION_MOTOR1'],
'MAX_NUM_MOTORS': cls.__constants['MAX_NUM_MOTORS'],
'FUNCTION_SERVO1': cls.__constants['FUNCTION_SERVO1'],
'MAX_NUM_SERVOS': cls.__constants['MAX_NUM_SERVOS'],
'ORB_QUEUE_LENGTH': cls.__constants['ORB_QUEUE_LENGTH'],
}
@property
def ACTION_RELEASE_CONTROL(self):
"""Message constant 'ACTION_RELEASE_CONTROL'."""
return Metaclass_ActuatorTest.__constants['ACTION_RELEASE_CONTROL']
@property
def ACTION_DO_CONTROL(self):
"""Message constant 'ACTION_DO_CONTROL'."""
return Metaclass_ActuatorTest.__constants['ACTION_DO_CONTROL']
@property
def FUNCTION_MOTOR1(self):
"""Message constant 'FUNCTION_MOTOR1'."""
return Metaclass_ActuatorTest.__constants['FUNCTION_MOTOR1']
@property
def MAX_NUM_MOTORS(self):
"""Message constant 'MAX_NUM_MOTORS'."""
return Metaclass_ActuatorTest.__constants['MAX_NUM_MOTORS']
@property
def FUNCTION_SERVO1(self):
"""Message constant 'FUNCTION_SERVO1'."""
return Metaclass_ActuatorTest.__constants['FUNCTION_SERVO1']
@property
def MAX_NUM_SERVOS(self):
"""Message constant 'MAX_NUM_SERVOS'."""
return Metaclass_ActuatorTest.__constants['MAX_NUM_SERVOS']
@property
def ORB_QUEUE_LENGTH(self):
"""Message constant 'ORB_QUEUE_LENGTH'."""
return Metaclass_ActuatorTest.__constants['ORB_QUEUE_LENGTH']
class ActuatorTest(metaclass=Metaclass_ActuatorTest):
"""
Message class 'ActuatorTest'.
Constants:
ACTION_RELEASE_CONTROL
ACTION_DO_CONTROL
FUNCTION_MOTOR1
MAX_NUM_MOTORS
FUNCTION_SERVO1
MAX_NUM_SERVOS
ORB_QUEUE_LENGTH
"""
__slots__ = [
'_timestamp',
'_action',
'_function',
'_value',
'_timeout_ms',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'action': 'uint8',
'function': 'uint16',
'value': 'float',
'timeout_ms': 'uint32',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint16'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('uint32'), # 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.timestamp = kwargs.get('timestamp', int())
self.action = kwargs.get('action', int())
self.function = kwargs.get('function', int())
self.value = kwargs.get('value', float())
self.timeout_ms = kwargs.get('timeout_ms', int())
def __repr__(self):
typename = self.__class__.__module__.split('.')
typename.pop()
typename.append(self.__class__.__name__)
args = []
for s, t in zip(self.__slots__, self.SLOT_TYPES):
field = getattr(self, s)
fieldstr = repr(field)
# We use Python array type for fields that can be directly stored
# in them, and "normal" sequences for everything else. If it is
# a type that we store in an array, strip off the 'array' portion.
if (
isinstance(t, rosidl_parser.definition.AbstractSequence) and
isinstance(t.value_type, rosidl_parser.definition.BasicType) and
t.value_type.typename in ['float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64']
):
if len(field) == 0:
fieldstr = '[]'
else:
assert fieldstr.startswith('array(')
prefix = "array('X', "
suffix = ')'
fieldstr = fieldstr[len(prefix):-len(suffix)]
args.append(s[1:] + '=' + fieldstr)
return '%s(%s)' % ('.'.join(typename), ', '.join(args))
def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
if self.timestamp != other.timestamp:
return False
if self.action != other.action:
return False
if self.function != other.function:
return False
if self.value != other.value:
return False
if self.timeout_ms != other.timeout_ms:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def action(self):
"""Message field 'action'."""
return self._action
@action.setter
def action(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'action' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'action' field must be an unsigned integer in [0, 255]"
self._action = value
@property
def function(self):
"""Message field 'function'."""
return self._function
@function.setter
def function(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'function' field must be of type 'int'"
assert value >= 0 and value < 65536, \
"The 'function' field must be an unsigned integer in [0, 65535]"
self._function = value
@property
def value(self):
"""Message field 'value'."""
return self._value
@value.setter
def value(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'value' field must be of type 'float'"
self._value = value
@property
def timeout_ms(self):
"""Message field 'timeout_ms'."""
return self._timeout_ms
@timeout_ms.setter
def timeout_ms(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timeout_ms' field must be of type 'int'"
assert value >= 0 and value < 4294967296, \
"The 'timeout_ms' field must be an unsigned integer in [0, 4294967295]"
self._timeout_ms = value

View File

@@ -0,0 +1,178 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/ActuatorTest.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 "px4_msgs/msg/detail/actuator_test__struct.h"
#include "px4_msgs/msg/detail/actuator_test__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__actuator_test__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("px4_msgs.msg._actuator_test.ActuatorTest", full_classname_dest, 40) == 0);
}
px4_msgs__msg__ActuatorTest * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // action
PyObject * field = PyObject_GetAttrString(_pymsg, "action");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->action = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // function
PyObject * field = PyObject_GetAttrString(_pymsg, "function");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->function = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // value
PyObject * field = PyObject_GetAttrString(_pymsg, "value");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->value = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // timeout_ms
PyObject * field = PyObject_GetAttrString(_pymsg, "timeout_ms");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timeout_ms = PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__actuator_test__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of ActuatorTest */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._actuator_test");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "ActuatorTest");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__ActuatorTest * ros_message = (px4_msgs__msg__ActuatorTest *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // action
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->action);
{
int rc = PyObject_SetAttrString(_pymessage, "action", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // function
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->function);
{
int rc = PyObject_SetAttrString(_pymessage, "function", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // value
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->value);
{
int rc = PyObject_SetAttrString(_pymessage, "value", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // timeout_ms
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->timeout_ms);
{
int rc = PyObject_SetAttrString(_pymessage, "timeout_ms", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_adc_report.py

View File

@@ -0,0 +1,271 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/AdcReport.idl
# generated code does not contain a copyright notice
# Import statements for member types
# Member 'channel_id'
# Member 'raw_data'
import numpy # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_AdcReport(type):
"""Metaclass of message 'AdcReport'."""
_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('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.AdcReport')
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__adc_report
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__adc_report
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__adc_report
cls._TYPE_SUPPORT = module.type_support_msg__msg__adc_report
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__adc_report
@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 AdcReport(metaclass=Metaclass_AdcReport):
"""Message class 'AdcReport'."""
__slots__ = [
'_timestamp',
'_device_id',
'_channel_id',
'_raw_data',
'_resolution',
'_v_ref',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'device_id': 'uint32',
'channel_id': 'int16[12]',
'raw_data': 'int32[12]',
'resolution': 'uint32',
'v_ref': 'float',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint32'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('int16'), 12), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('int32'), 12), # noqa: E501
rosidl_parser.definition.BasicType('uint32'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
)
def __init__(self, **kwargs):
assert all('_' + key in self.__slots__ for key in kwargs.keys()), \
'Invalid arguments passed to constructor: %s' % \
', '.join(sorted(k for k in kwargs.keys() if '_' + k not in self.__slots__))
self.timestamp = kwargs.get('timestamp', int())
self.device_id = kwargs.get('device_id', int())
if 'channel_id' not in kwargs:
self.channel_id = numpy.zeros(12, dtype=numpy.int16)
else:
self.channel_id = numpy.array(kwargs.get('channel_id'), dtype=numpy.int16)
assert self.channel_id.shape == (12, )
if 'raw_data' not in kwargs:
self.raw_data = numpy.zeros(12, dtype=numpy.int32)
else:
self.raw_data = numpy.array(kwargs.get('raw_data'), dtype=numpy.int32)
assert self.raw_data.shape == (12, )
self.resolution = kwargs.get('resolution', int())
self.v_ref = kwargs.get('v_ref', 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.timestamp != other.timestamp:
return False
if self.device_id != other.device_id:
return False
if all(self.channel_id != other.channel_id):
return False
if all(self.raw_data != other.raw_data):
return False
if self.resolution != other.resolution:
return False
if self.v_ref != other.v_ref:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def device_id(self):
"""Message field 'device_id'."""
return self._device_id
@device_id.setter
def device_id(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'device_id' field must be of type 'int'"
assert value >= 0 and value < 4294967296, \
"The 'device_id' field must be an unsigned integer in [0, 4294967295]"
self._device_id = value
@property
def channel_id(self):
"""Message field 'channel_id'."""
return self._channel_id
@channel_id.setter
def channel_id(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.int16, \
"The 'channel_id' numpy.ndarray() must have the dtype of 'numpy.int16'"
assert value.size == 12, \
"The 'channel_id' numpy.ndarray() must have a size of 12"
self._channel_id = 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) == 12 and
all(isinstance(v, int) for v in value) and
all(val >= -32768 and val < 32768 for val in value)), \
"The 'channel_id' field must be a set or sequence with length 12 and each value of type 'int' and each integer in [-32768, 32767]"
self._channel_id = numpy.array(value, dtype=numpy.int16)
@property
def raw_data(self):
"""Message field 'raw_data'."""
return self._raw_data
@raw_data.setter
def raw_data(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.int32, \
"The 'raw_data' numpy.ndarray() must have the dtype of 'numpy.int32'"
assert value.size == 12, \
"The 'raw_data' numpy.ndarray() must have a size of 12"
self._raw_data = 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) == 12 and
all(isinstance(v, int) for v in value) and
all(val >= -2147483648 and val < 2147483648 for val in value)), \
"The 'raw_data' field must be a set or sequence with length 12 and each value of type 'int' and each integer in [-2147483648, 2147483647]"
self._raw_data = numpy.array(value, dtype=numpy.int32)
@property
def resolution(self):
"""Message field 'resolution'."""
return self._resolution
@resolution.setter
def resolution(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'resolution' field must be of type 'int'"
assert value >= 0 and value < 4294967296, \
"The 'resolution' field must be an unsigned integer in [0, 4294967295]"
self._resolution = value
@property
def v_ref(self):
"""Message field 'v_ref'."""
return self._v_ref
@v_ref.setter
def v_ref(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'v_ref' field must be of type 'float'"
self._v_ref = value

View File

@@ -0,0 +1,245 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/AdcReport.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 "px4_msgs/msg/detail/adc_report__struct.h"
#include "px4_msgs/msg/detail/adc_report__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__adc_report__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("px4_msgs.msg._adc_report.AdcReport", full_classname_dest, 34) == 0);
}
px4_msgs__msg__AdcReport * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // device_id
PyObject * field = PyObject_GetAttrString(_pymsg, "device_id");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->device_id = PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // channel_id
PyObject * field = PyObject_GetAttrString(_pymsg, "channel_id");
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_INT16);
Py_ssize_t size = 12;
int16_t * dest = ros_message->channel_id;
for (Py_ssize_t i = 0; i < size; ++i) {
int16_t tmp = *(npy_int16 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(int16_t));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
{ // raw_data
PyObject * field = PyObject_GetAttrString(_pymsg, "raw_data");
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_INT32);
Py_ssize_t size = 12;
int32_t * dest = ros_message->raw_data;
for (Py_ssize_t i = 0; i < size; ++i) {
int32_t tmp = *(npy_int32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(int32_t));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
{ // resolution
PyObject * field = PyObject_GetAttrString(_pymsg, "resolution");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->resolution = PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // v_ref
PyObject * field = PyObject_GetAttrString(_pymsg, "v_ref");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->v_ref = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__adc_report__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of AdcReport */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._adc_report");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "AdcReport");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__AdcReport * ros_message = (px4_msgs__msg__AdcReport *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // device_id
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->device_id);
{
int rc = PyObject_SetAttrString(_pymessage, "device_id", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // channel_id
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "channel_id");
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_INT16);
assert(sizeof(npy_int16) == sizeof(int16_t));
npy_int16 * dst = (npy_int16 *)PyArray_GETPTR1(seq_field, 0);
int16_t * src = &(ros_message->channel_id[0]);
memcpy(dst, src, 12 * sizeof(int16_t));
Py_DECREF(field);
}
{ // raw_data
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "raw_data");
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_INT32);
assert(sizeof(npy_int32) == sizeof(int32_t));
npy_int32 * dst = (npy_int32 *)PyArray_GETPTR1(seq_field, 0);
int32_t * src = &(ros_message->raw_data[0]);
memcpy(dst, src, 12 * sizeof(int32_t));
Py_DECREF(field);
}
{ // resolution
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->resolution);
{
int rc = PyObject_SetAttrString(_pymessage, "resolution", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // v_ref
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->v_ref);
{
int rc = PyObject_SetAttrString(_pymessage, "v_ref", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_airspeed.py

View File

@@ -0,0 +1,221 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/Airspeed.idl
# generated code does not contain a copyright notice
# Import statements for member types
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_Airspeed(type):
"""Metaclass of message 'Airspeed'."""
_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('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.Airspeed')
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__airspeed
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__airspeed
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__airspeed
cls._TYPE_SUPPORT = module.type_support_msg__msg__airspeed
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__airspeed
@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 Airspeed(metaclass=Metaclass_Airspeed):
"""Message class 'Airspeed'."""
__slots__ = [
'_timestamp',
'_timestamp_sample',
'_indicated_airspeed_m_s',
'_true_airspeed_m_s',
'_air_temperature_celsius',
'_confidence',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'timestamp_sample': 'uint64',
'indicated_airspeed_m_s': 'float',
'true_airspeed_m_s': 'float',
'air_temperature_celsius': 'float',
'confidence': 'float',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
)
def __init__(self, **kwargs):
assert all('_' + key in self.__slots__ for key in kwargs.keys()), \
'Invalid arguments passed to constructor: %s' % \
', '.join(sorted(k for k in kwargs.keys() if '_' + k not in self.__slots__))
self.timestamp = kwargs.get('timestamp', int())
self.timestamp_sample = kwargs.get('timestamp_sample', int())
self.indicated_airspeed_m_s = kwargs.get('indicated_airspeed_m_s', float())
self.true_airspeed_m_s = kwargs.get('true_airspeed_m_s', float())
self.air_temperature_celsius = kwargs.get('air_temperature_celsius', float())
self.confidence = kwargs.get('confidence', 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.timestamp != other.timestamp:
return False
if self.timestamp_sample != other.timestamp_sample:
return False
if self.indicated_airspeed_m_s != other.indicated_airspeed_m_s:
return False
if self.true_airspeed_m_s != other.true_airspeed_m_s:
return False
if self.air_temperature_celsius != other.air_temperature_celsius:
return False
if self.confidence != other.confidence:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def timestamp_sample(self):
"""Message field 'timestamp_sample'."""
return self._timestamp_sample
@timestamp_sample.setter
def timestamp_sample(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp_sample' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp_sample' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp_sample = value
@property
def indicated_airspeed_m_s(self):
"""Message field 'indicated_airspeed_m_s'."""
return self._indicated_airspeed_m_s
@indicated_airspeed_m_s.setter
def indicated_airspeed_m_s(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'indicated_airspeed_m_s' field must be of type 'float'"
self._indicated_airspeed_m_s = value
@property
def true_airspeed_m_s(self):
"""Message field 'true_airspeed_m_s'."""
return self._true_airspeed_m_s
@true_airspeed_m_s.setter
def true_airspeed_m_s(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'true_airspeed_m_s' field must be of type 'float'"
self._true_airspeed_m_s = value
@property
def air_temperature_celsius(self):
"""Message field 'air_temperature_celsius'."""
return self._air_temperature_celsius
@air_temperature_celsius.setter
def air_temperature_celsius(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'air_temperature_celsius' field must be of type 'float'"
self._air_temperature_celsius = value
@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'"
self._confidence = value

View File

@@ -0,0 +1,198 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/Airspeed.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 "px4_msgs/msg/detail/airspeed__struct.h"
#include "px4_msgs/msg/detail/airspeed__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__airspeed__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[32];
{
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("px4_msgs.msg._airspeed.Airspeed", full_classname_dest, 31) == 0);
}
px4_msgs__msg__Airspeed * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // timestamp_sample
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp_sample");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp_sample = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // indicated_airspeed_m_s
PyObject * field = PyObject_GetAttrString(_pymsg, "indicated_airspeed_m_s");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->indicated_airspeed_m_s = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // true_airspeed_m_s
PyObject * field = PyObject_GetAttrString(_pymsg, "true_airspeed_m_s");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->true_airspeed_m_s = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // air_temperature_celsius
PyObject * field = PyObject_GetAttrString(_pymsg, "air_temperature_celsius");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->air_temperature_celsius = (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);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__airspeed__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of Airspeed */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._airspeed");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "Airspeed");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__Airspeed * ros_message = (px4_msgs__msg__Airspeed *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // timestamp_sample
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp_sample);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp_sample", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // indicated_airspeed_m_s
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->indicated_airspeed_m_s);
{
int rc = PyObject_SetAttrString(_pymessage, "indicated_airspeed_m_s", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // true_airspeed_m_s
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->true_airspeed_m_s);
{
int rc = PyObject_SetAttrString(_pymessage, "true_airspeed_m_s", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // air_temperature_celsius
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->air_temperature_celsius);
{
int rc = PyObject_SetAttrString(_pymessage, "air_temperature_celsius", 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;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_airspeed_validated.py

View File

@@ -0,0 +1,259 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/AirspeedValidated.idl
# generated code does not contain a copyright notice
# Import statements for member types
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_AirspeedValidated(type):
"""Metaclass of message 'AirspeedValidated'."""
_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('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.AirspeedValidated')
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__airspeed_validated
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__airspeed_validated
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__airspeed_validated
cls._TYPE_SUPPORT = module.type_support_msg__msg__airspeed_validated
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__airspeed_validated
@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 AirspeedValidated(metaclass=Metaclass_AirspeedValidated):
"""Message class 'AirspeedValidated'."""
__slots__ = [
'_timestamp',
'_indicated_airspeed_m_s',
'_calibrated_airspeed_m_s',
'_true_airspeed_m_s',
'_calibrated_ground_minus_wind_m_s',
'_true_ground_minus_wind_m_s',
'_airspeed_sensor_measurement_valid',
'_selected_airspeed_index',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'indicated_airspeed_m_s': 'float',
'calibrated_airspeed_m_s': 'float',
'true_airspeed_m_s': 'float',
'calibrated_ground_minus_wind_m_s': 'float',
'true_ground_minus_wind_m_s': 'float',
'airspeed_sensor_measurement_valid': 'boolean',
'selected_airspeed_index': 'int8',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # 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('boolean'), # noqa: E501
rosidl_parser.definition.BasicType('int8'), # 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.timestamp = kwargs.get('timestamp', int())
self.indicated_airspeed_m_s = kwargs.get('indicated_airspeed_m_s', float())
self.calibrated_airspeed_m_s = kwargs.get('calibrated_airspeed_m_s', float())
self.true_airspeed_m_s = kwargs.get('true_airspeed_m_s', float())
self.calibrated_ground_minus_wind_m_s = kwargs.get('calibrated_ground_minus_wind_m_s', float())
self.true_ground_minus_wind_m_s = kwargs.get('true_ground_minus_wind_m_s', float())
self.airspeed_sensor_measurement_valid = kwargs.get('airspeed_sensor_measurement_valid', bool())
self.selected_airspeed_index = kwargs.get('selected_airspeed_index', int())
def __repr__(self):
typename = self.__class__.__module__.split('.')
typename.pop()
typename.append(self.__class__.__name__)
args = []
for s, t in zip(self.__slots__, self.SLOT_TYPES):
field = getattr(self, s)
fieldstr = repr(field)
# We use Python array type for fields that can be directly stored
# in them, and "normal" sequences for everything else. If it is
# a type that we store in an array, strip off the 'array' portion.
if (
isinstance(t, rosidl_parser.definition.AbstractSequence) and
isinstance(t.value_type, rosidl_parser.definition.BasicType) and
t.value_type.typename in ['float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64']
):
if len(field) == 0:
fieldstr = '[]'
else:
assert fieldstr.startswith('array(')
prefix = "array('X', "
suffix = ')'
fieldstr = fieldstr[len(prefix):-len(suffix)]
args.append(s[1:] + '=' + fieldstr)
return '%s(%s)' % ('.'.join(typename), ', '.join(args))
def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
if self.timestamp != other.timestamp:
return False
if self.indicated_airspeed_m_s != other.indicated_airspeed_m_s:
return False
if self.calibrated_airspeed_m_s != other.calibrated_airspeed_m_s:
return False
if self.true_airspeed_m_s != other.true_airspeed_m_s:
return False
if self.calibrated_ground_minus_wind_m_s != other.calibrated_ground_minus_wind_m_s:
return False
if self.true_ground_minus_wind_m_s != other.true_ground_minus_wind_m_s:
return False
if self.airspeed_sensor_measurement_valid != other.airspeed_sensor_measurement_valid:
return False
if self.selected_airspeed_index != other.selected_airspeed_index:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def indicated_airspeed_m_s(self):
"""Message field 'indicated_airspeed_m_s'."""
return self._indicated_airspeed_m_s
@indicated_airspeed_m_s.setter
def indicated_airspeed_m_s(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'indicated_airspeed_m_s' field must be of type 'float'"
self._indicated_airspeed_m_s = value
@property
def calibrated_airspeed_m_s(self):
"""Message field 'calibrated_airspeed_m_s'."""
return self._calibrated_airspeed_m_s
@calibrated_airspeed_m_s.setter
def calibrated_airspeed_m_s(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'calibrated_airspeed_m_s' field must be of type 'float'"
self._calibrated_airspeed_m_s = value
@property
def true_airspeed_m_s(self):
"""Message field 'true_airspeed_m_s'."""
return self._true_airspeed_m_s
@true_airspeed_m_s.setter
def true_airspeed_m_s(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'true_airspeed_m_s' field must be of type 'float'"
self._true_airspeed_m_s = value
@property
def calibrated_ground_minus_wind_m_s(self):
"""Message field 'calibrated_ground_minus_wind_m_s'."""
return self._calibrated_ground_minus_wind_m_s
@calibrated_ground_minus_wind_m_s.setter
def calibrated_ground_minus_wind_m_s(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'calibrated_ground_minus_wind_m_s' field must be of type 'float'"
self._calibrated_ground_minus_wind_m_s = value
@property
def true_ground_minus_wind_m_s(self):
"""Message field 'true_ground_minus_wind_m_s'."""
return self._true_ground_minus_wind_m_s
@true_ground_minus_wind_m_s.setter
def true_ground_minus_wind_m_s(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'true_ground_minus_wind_m_s' field must be of type 'float'"
self._true_ground_minus_wind_m_s = value
@property
def airspeed_sensor_measurement_valid(self):
"""Message field 'airspeed_sensor_measurement_valid'."""
return self._airspeed_sensor_measurement_valid
@airspeed_sensor_measurement_valid.setter
def airspeed_sensor_measurement_valid(self, value):
if __debug__:
assert \
isinstance(value, bool), \
"The 'airspeed_sensor_measurement_valid' field must be of type 'bool'"
self._airspeed_sensor_measurement_valid = value
@property
def selected_airspeed_index(self):
"""Message field 'selected_airspeed_index'."""
return self._selected_airspeed_index
@selected_airspeed_index.setter
def selected_airspeed_index(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'selected_airspeed_index' field must be of type 'int'"
assert value >= -128 and value < 128, \
"The 'selected_airspeed_index' field must be an integer in [-128, 127]"
self._selected_airspeed_index = value

View File

@@ -0,0 +1,238 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/AirspeedValidated.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 "px4_msgs/msg/detail/airspeed_validated__struct.h"
#include "px4_msgs/msg/detail/airspeed_validated__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__airspeed_validated__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("px4_msgs.msg._airspeed_validated.AirspeedValidated", full_classname_dest, 50) == 0);
}
px4_msgs__msg__AirspeedValidated * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // indicated_airspeed_m_s
PyObject * field = PyObject_GetAttrString(_pymsg, "indicated_airspeed_m_s");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->indicated_airspeed_m_s = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // calibrated_airspeed_m_s
PyObject * field = PyObject_GetAttrString(_pymsg, "calibrated_airspeed_m_s");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->calibrated_airspeed_m_s = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // true_airspeed_m_s
PyObject * field = PyObject_GetAttrString(_pymsg, "true_airspeed_m_s");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->true_airspeed_m_s = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // calibrated_ground_minus_wind_m_s
PyObject * field = PyObject_GetAttrString(_pymsg, "calibrated_ground_minus_wind_m_s");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->calibrated_ground_minus_wind_m_s = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // true_ground_minus_wind_m_s
PyObject * field = PyObject_GetAttrString(_pymsg, "true_ground_minus_wind_m_s");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->true_ground_minus_wind_m_s = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // airspeed_sensor_measurement_valid
PyObject * field = PyObject_GetAttrString(_pymsg, "airspeed_sensor_measurement_valid");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->airspeed_sensor_measurement_valid = (Py_True == field);
Py_DECREF(field);
}
{ // selected_airspeed_index
PyObject * field = PyObject_GetAttrString(_pymsg, "selected_airspeed_index");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->selected_airspeed_index = (int8_t)PyLong_AsLong(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__airspeed_validated__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of AirspeedValidated */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._airspeed_validated");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "AirspeedValidated");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__AirspeedValidated * ros_message = (px4_msgs__msg__AirspeedValidated *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // indicated_airspeed_m_s
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->indicated_airspeed_m_s);
{
int rc = PyObject_SetAttrString(_pymessage, "indicated_airspeed_m_s", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // calibrated_airspeed_m_s
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->calibrated_airspeed_m_s);
{
int rc = PyObject_SetAttrString(_pymessage, "calibrated_airspeed_m_s", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // true_airspeed_m_s
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->true_airspeed_m_s);
{
int rc = PyObject_SetAttrString(_pymessage, "true_airspeed_m_s", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // calibrated_ground_minus_wind_m_s
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->calibrated_ground_minus_wind_m_s);
{
int rc = PyObject_SetAttrString(_pymessage, "calibrated_ground_minus_wind_m_s", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // true_ground_minus_wind_m_s
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->true_ground_minus_wind_m_s);
{
int rc = PyObject_SetAttrString(_pymessage, "true_ground_minus_wind_m_s", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // airspeed_sensor_measurement_valid
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->airspeed_sensor_measurement_valid ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "airspeed_sensor_measurement_valid", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // selected_airspeed_index
PyObject * field = NULL;
field = PyLong_FromLong(ros_message->selected_airspeed_index);
{
int rc = PyObject_SetAttrString(_pymessage, "selected_airspeed_index", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_airspeed_wind.py

View File

@@ -0,0 +1,411 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/AirspeedWind.idl
# generated code does not contain a copyright notice
# Import statements for member types
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_AirspeedWind(type):
"""Metaclass of message 'AirspeedWind'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'SOURCE_AS_BETA_ONLY': 0,
'SOURCE_AS_SENSOR_1': 1,
'SOURCE_AS_SENSOR_2': 2,
'SOURCE_AS_SENSOR_3': 3,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.AirspeedWind')
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__airspeed_wind
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__airspeed_wind
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__airspeed_wind
cls._TYPE_SUPPORT = module.type_support_msg__msg__airspeed_wind
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__airspeed_wind
@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 {
'SOURCE_AS_BETA_ONLY': cls.__constants['SOURCE_AS_BETA_ONLY'],
'SOURCE_AS_SENSOR_1': cls.__constants['SOURCE_AS_SENSOR_1'],
'SOURCE_AS_SENSOR_2': cls.__constants['SOURCE_AS_SENSOR_2'],
'SOURCE_AS_SENSOR_3': cls.__constants['SOURCE_AS_SENSOR_3'],
}
@property
def SOURCE_AS_BETA_ONLY(self):
"""Message constant 'SOURCE_AS_BETA_ONLY'."""
return Metaclass_AirspeedWind.__constants['SOURCE_AS_BETA_ONLY']
@property
def SOURCE_AS_SENSOR_1(self):
"""Message constant 'SOURCE_AS_SENSOR_1'."""
return Metaclass_AirspeedWind.__constants['SOURCE_AS_SENSOR_1']
@property
def SOURCE_AS_SENSOR_2(self):
"""Message constant 'SOURCE_AS_SENSOR_2'."""
return Metaclass_AirspeedWind.__constants['SOURCE_AS_SENSOR_2']
@property
def SOURCE_AS_SENSOR_3(self):
"""Message constant 'SOURCE_AS_SENSOR_3'."""
return Metaclass_AirspeedWind.__constants['SOURCE_AS_SENSOR_3']
class AirspeedWind(metaclass=Metaclass_AirspeedWind):
"""
Message class 'AirspeedWind'.
Constants:
SOURCE_AS_BETA_ONLY
SOURCE_AS_SENSOR_1
SOURCE_AS_SENSOR_2
SOURCE_AS_SENSOR_3
"""
__slots__ = [
'_timestamp',
'_timestamp_sample',
'_windspeed_north',
'_windspeed_east',
'_variance_north',
'_variance_east',
'_tas_innov',
'_tas_innov_var',
'_tas_scale_raw',
'_tas_scale_raw_var',
'_tas_scale_validated',
'_beta_innov',
'_beta_innov_var',
'_source',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'timestamp_sample': 'uint64',
'windspeed_north': 'float',
'windspeed_east': 'float',
'variance_north': 'float',
'variance_east': 'float',
'tas_innov': 'float',
'tas_innov_var': 'float',
'tas_scale_raw': 'float',
'tas_scale_raw_var': 'float',
'tas_scale_validated': 'float',
'beta_innov': 'float',
'beta_innov_var': 'float',
'source': 'uint8',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint64'), # 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.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('uint8'), # noqa: E501
)
def __init__(self, **kwargs):
assert all('_' + key in self.__slots__ for key in kwargs.keys()), \
'Invalid arguments passed to constructor: %s' % \
', '.join(sorted(k for k in kwargs.keys() if '_' + k not in self.__slots__))
self.timestamp = kwargs.get('timestamp', int())
self.timestamp_sample = kwargs.get('timestamp_sample', int())
self.windspeed_north = kwargs.get('windspeed_north', float())
self.windspeed_east = kwargs.get('windspeed_east', float())
self.variance_north = kwargs.get('variance_north', float())
self.variance_east = kwargs.get('variance_east', float())
self.tas_innov = kwargs.get('tas_innov', float())
self.tas_innov_var = kwargs.get('tas_innov_var', float())
self.tas_scale_raw = kwargs.get('tas_scale_raw', float())
self.tas_scale_raw_var = kwargs.get('tas_scale_raw_var', float())
self.tas_scale_validated = kwargs.get('tas_scale_validated', float())
self.beta_innov = kwargs.get('beta_innov', float())
self.beta_innov_var = kwargs.get('beta_innov_var', float())
self.source = kwargs.get('source', int())
def __repr__(self):
typename = self.__class__.__module__.split('.')
typename.pop()
typename.append(self.__class__.__name__)
args = []
for s, t in zip(self.__slots__, self.SLOT_TYPES):
field = getattr(self, s)
fieldstr = repr(field)
# We use Python array type for fields that can be directly stored
# in them, and "normal" sequences for everything else. If it is
# a type that we store in an array, strip off the 'array' portion.
if (
isinstance(t, rosidl_parser.definition.AbstractSequence) and
isinstance(t.value_type, rosidl_parser.definition.BasicType) and
t.value_type.typename in ['float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64']
):
if len(field) == 0:
fieldstr = '[]'
else:
assert fieldstr.startswith('array(')
prefix = "array('X', "
suffix = ')'
fieldstr = fieldstr[len(prefix):-len(suffix)]
args.append(s[1:] + '=' + fieldstr)
return '%s(%s)' % ('.'.join(typename), ', '.join(args))
def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
if self.timestamp != other.timestamp:
return False
if self.timestamp_sample != other.timestamp_sample:
return False
if self.windspeed_north != other.windspeed_north:
return False
if self.windspeed_east != other.windspeed_east:
return False
if self.variance_north != other.variance_north:
return False
if self.variance_east != other.variance_east:
return False
if self.tas_innov != other.tas_innov:
return False
if self.tas_innov_var != other.tas_innov_var:
return False
if self.tas_scale_raw != other.tas_scale_raw:
return False
if self.tas_scale_raw_var != other.tas_scale_raw_var:
return False
if self.tas_scale_validated != other.tas_scale_validated:
return False
if self.beta_innov != other.beta_innov:
return False
if self.beta_innov_var != other.beta_innov_var:
return False
if self.source != other.source:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def timestamp_sample(self):
"""Message field 'timestamp_sample'."""
return self._timestamp_sample
@timestamp_sample.setter
def timestamp_sample(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp_sample' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp_sample' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp_sample = value
@property
def windspeed_north(self):
"""Message field 'windspeed_north'."""
return self._windspeed_north
@windspeed_north.setter
def windspeed_north(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'windspeed_north' field must be of type 'float'"
self._windspeed_north = value
@property
def windspeed_east(self):
"""Message field 'windspeed_east'."""
return self._windspeed_east
@windspeed_east.setter
def windspeed_east(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'windspeed_east' field must be of type 'float'"
self._windspeed_east = value
@property
def variance_north(self):
"""Message field 'variance_north'."""
return self._variance_north
@variance_north.setter
def variance_north(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'variance_north' field must be of type 'float'"
self._variance_north = value
@property
def variance_east(self):
"""Message field 'variance_east'."""
return self._variance_east
@variance_east.setter
def variance_east(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'variance_east' field must be of type 'float'"
self._variance_east = value
@property
def tas_innov(self):
"""Message field 'tas_innov'."""
return self._tas_innov
@tas_innov.setter
def tas_innov(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'tas_innov' field must be of type 'float'"
self._tas_innov = value
@property
def tas_innov_var(self):
"""Message field 'tas_innov_var'."""
return self._tas_innov_var
@tas_innov_var.setter
def tas_innov_var(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'tas_innov_var' field must be of type 'float'"
self._tas_innov_var = value
@property
def tas_scale_raw(self):
"""Message field 'tas_scale_raw'."""
return self._tas_scale_raw
@tas_scale_raw.setter
def tas_scale_raw(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'tas_scale_raw' field must be of type 'float'"
self._tas_scale_raw = value
@property
def tas_scale_raw_var(self):
"""Message field 'tas_scale_raw_var'."""
return self._tas_scale_raw_var
@tas_scale_raw_var.setter
def tas_scale_raw_var(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'tas_scale_raw_var' field must be of type 'float'"
self._tas_scale_raw_var = value
@property
def tas_scale_validated(self):
"""Message field 'tas_scale_validated'."""
return self._tas_scale_validated
@tas_scale_validated.setter
def tas_scale_validated(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'tas_scale_validated' field must be of type 'float'"
self._tas_scale_validated = value
@property
def beta_innov(self):
"""Message field 'beta_innov'."""
return self._beta_innov
@beta_innov.setter
def beta_innov(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'beta_innov' field must be of type 'float'"
self._beta_innov = value
@property
def beta_innov_var(self):
"""Message field 'beta_innov_var'."""
return self._beta_innov_var
@beta_innov_var.setter
def beta_innov_var(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'beta_innov_var' field must be of type 'float'"
self._beta_innov_var = value
@property
def source(self):
"""Message field 'source'."""
return self._source
@source.setter
def source(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'source' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'source' field must be an unsigned integer in [0, 255]"
self._source = value

View File

@@ -0,0 +1,358 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/AirspeedWind.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 "px4_msgs/msg/detail/airspeed_wind__struct.h"
#include "px4_msgs/msg/detail/airspeed_wind__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__airspeed_wind__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("px4_msgs.msg._airspeed_wind.AirspeedWind", full_classname_dest, 40) == 0);
}
px4_msgs__msg__AirspeedWind * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // timestamp_sample
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp_sample");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp_sample = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // windspeed_north
PyObject * field = PyObject_GetAttrString(_pymsg, "windspeed_north");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->windspeed_north = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // windspeed_east
PyObject * field = PyObject_GetAttrString(_pymsg, "windspeed_east");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->windspeed_east = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // variance_north
PyObject * field = PyObject_GetAttrString(_pymsg, "variance_north");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->variance_north = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // variance_east
PyObject * field = PyObject_GetAttrString(_pymsg, "variance_east");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->variance_east = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // tas_innov
PyObject * field = PyObject_GetAttrString(_pymsg, "tas_innov");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->tas_innov = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // tas_innov_var
PyObject * field = PyObject_GetAttrString(_pymsg, "tas_innov_var");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->tas_innov_var = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // tas_scale_raw
PyObject * field = PyObject_GetAttrString(_pymsg, "tas_scale_raw");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->tas_scale_raw = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // tas_scale_raw_var
PyObject * field = PyObject_GetAttrString(_pymsg, "tas_scale_raw_var");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->tas_scale_raw_var = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // tas_scale_validated
PyObject * field = PyObject_GetAttrString(_pymsg, "tas_scale_validated");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->tas_scale_validated = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // beta_innov
PyObject * field = PyObject_GetAttrString(_pymsg, "beta_innov");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->beta_innov = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // beta_innov_var
PyObject * field = PyObject_GetAttrString(_pymsg, "beta_innov_var");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->beta_innov_var = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // source
PyObject * field = PyObject_GetAttrString(_pymsg, "source");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->source = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__airspeed_wind__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of AirspeedWind */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._airspeed_wind");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "AirspeedWind");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__AirspeedWind * ros_message = (px4_msgs__msg__AirspeedWind *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // timestamp_sample
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp_sample);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp_sample", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // windspeed_north
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->windspeed_north);
{
int rc = PyObject_SetAttrString(_pymessage, "windspeed_north", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // windspeed_east
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->windspeed_east);
{
int rc = PyObject_SetAttrString(_pymessage, "windspeed_east", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // variance_north
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->variance_north);
{
int rc = PyObject_SetAttrString(_pymessage, "variance_north", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // variance_east
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->variance_east);
{
int rc = PyObject_SetAttrString(_pymessage, "variance_east", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // tas_innov
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->tas_innov);
{
int rc = PyObject_SetAttrString(_pymessage, "tas_innov", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // tas_innov_var
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->tas_innov_var);
{
int rc = PyObject_SetAttrString(_pymessage, "tas_innov_var", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // tas_scale_raw
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->tas_scale_raw);
{
int rc = PyObject_SetAttrString(_pymessage, "tas_scale_raw", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // tas_scale_raw_var
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->tas_scale_raw_var);
{
int rc = PyObject_SetAttrString(_pymessage, "tas_scale_raw_var", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // tas_scale_validated
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->tas_scale_validated);
{
int rc = PyObject_SetAttrString(_pymessage, "tas_scale_validated", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // beta_innov
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->beta_innov);
{
int rc = PyObject_SetAttrString(_pymessage, "beta_innov", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // beta_innov_var
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->beta_innov_var);
{
int rc = PyObject_SetAttrString(_pymessage, "beta_innov_var", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // source
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->source);
{
int rc = PyObject_SetAttrString(_pymessage, "source", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_autotune_attitude_control_status.py

View File

@@ -0,0 +1,579 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/AutotuneAttitudeControlStatus.idl
# generated code does not contain a copyright notice
# Import statements for member types
# Member 'coeff'
# Member 'coeff_var'
# Member 'rate_sp'
import numpy # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_AutotuneAttitudeControlStatus(type):
"""Metaclass of message 'AutotuneAttitudeControlStatus'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'STATE_IDLE': 0,
'STATE_INIT': 1,
'STATE_ROLL': 2,
'STATE_ROLL_PAUSE': 3,
'STATE_PITCH': 4,
'STATE_PITCH_PAUSE': 5,
'STATE_YAW': 6,
'STATE_YAW_PAUSE': 7,
'STATE_VERIFICATION': 8,
'STATE_APPLY': 9,
'STATE_TEST': 10,
'STATE_COMPLETE': 11,
'STATE_FAIL': 12,
'STATE_WAIT_FOR_DISARM': 13,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.AutotuneAttitudeControlStatus')
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__autotune_attitude_control_status
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__autotune_attitude_control_status
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__autotune_attitude_control_status
cls._TYPE_SUPPORT = module.type_support_msg__msg__autotune_attitude_control_status
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__autotune_attitude_control_status
@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 {
'STATE_IDLE': cls.__constants['STATE_IDLE'],
'STATE_INIT': cls.__constants['STATE_INIT'],
'STATE_ROLL': cls.__constants['STATE_ROLL'],
'STATE_ROLL_PAUSE': cls.__constants['STATE_ROLL_PAUSE'],
'STATE_PITCH': cls.__constants['STATE_PITCH'],
'STATE_PITCH_PAUSE': cls.__constants['STATE_PITCH_PAUSE'],
'STATE_YAW': cls.__constants['STATE_YAW'],
'STATE_YAW_PAUSE': cls.__constants['STATE_YAW_PAUSE'],
'STATE_VERIFICATION': cls.__constants['STATE_VERIFICATION'],
'STATE_APPLY': cls.__constants['STATE_APPLY'],
'STATE_TEST': cls.__constants['STATE_TEST'],
'STATE_COMPLETE': cls.__constants['STATE_COMPLETE'],
'STATE_FAIL': cls.__constants['STATE_FAIL'],
'STATE_WAIT_FOR_DISARM': cls.__constants['STATE_WAIT_FOR_DISARM'],
}
@property
def STATE_IDLE(self):
"""Message constant 'STATE_IDLE'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_IDLE']
@property
def STATE_INIT(self):
"""Message constant 'STATE_INIT'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_INIT']
@property
def STATE_ROLL(self):
"""Message constant 'STATE_ROLL'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_ROLL']
@property
def STATE_ROLL_PAUSE(self):
"""Message constant 'STATE_ROLL_PAUSE'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_ROLL_PAUSE']
@property
def STATE_PITCH(self):
"""Message constant 'STATE_PITCH'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_PITCH']
@property
def STATE_PITCH_PAUSE(self):
"""Message constant 'STATE_PITCH_PAUSE'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_PITCH_PAUSE']
@property
def STATE_YAW(self):
"""Message constant 'STATE_YAW'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_YAW']
@property
def STATE_YAW_PAUSE(self):
"""Message constant 'STATE_YAW_PAUSE'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_YAW_PAUSE']
@property
def STATE_VERIFICATION(self):
"""Message constant 'STATE_VERIFICATION'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_VERIFICATION']
@property
def STATE_APPLY(self):
"""Message constant 'STATE_APPLY'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_APPLY']
@property
def STATE_TEST(self):
"""Message constant 'STATE_TEST'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_TEST']
@property
def STATE_COMPLETE(self):
"""Message constant 'STATE_COMPLETE'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_COMPLETE']
@property
def STATE_FAIL(self):
"""Message constant 'STATE_FAIL'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_FAIL']
@property
def STATE_WAIT_FOR_DISARM(self):
"""Message constant 'STATE_WAIT_FOR_DISARM'."""
return Metaclass_AutotuneAttitudeControlStatus.__constants['STATE_WAIT_FOR_DISARM']
class AutotuneAttitudeControlStatus(metaclass=Metaclass_AutotuneAttitudeControlStatus):
"""
Message class 'AutotuneAttitudeControlStatus'.
Constants:
STATE_IDLE
STATE_INIT
STATE_ROLL
STATE_ROLL_PAUSE
STATE_PITCH
STATE_PITCH_PAUSE
STATE_YAW
STATE_YAW_PAUSE
STATE_VERIFICATION
STATE_APPLY
STATE_TEST
STATE_COMPLETE
STATE_FAIL
STATE_WAIT_FOR_DISARM
"""
__slots__ = [
'_timestamp',
'_coeff',
'_coeff_var',
'_fitness',
'_innov',
'_dt_model',
'_kc',
'_ki',
'_kd',
'_kff',
'_att_p',
'_rate_sp',
'_u_filt',
'_y_filt',
'_state',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'coeff': 'float[5]',
'coeff_var': 'float[5]',
'fitness': 'float',
'innov': 'float',
'dt_model': 'float',
'kc': 'float',
'ki': 'float',
'kd': 'float',
'kff': 'float',
'att_p': 'float',
'rate_sp': 'float[3]',
'u_filt': 'float',
'y_filt': 'float',
'state': 'uint8',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 5), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 5), # 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.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 3), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
)
def __init__(self, **kwargs):
assert all('_' + key in self.__slots__ for key in kwargs.keys()), \
'Invalid arguments passed to constructor: %s' % \
', '.join(sorted(k for k in kwargs.keys() if '_' + k not in self.__slots__))
self.timestamp = kwargs.get('timestamp', int())
if 'coeff' not in kwargs:
self.coeff = numpy.zeros(5, dtype=numpy.float32)
else:
self.coeff = numpy.array(kwargs.get('coeff'), dtype=numpy.float32)
assert self.coeff.shape == (5, )
if 'coeff_var' not in kwargs:
self.coeff_var = numpy.zeros(5, dtype=numpy.float32)
else:
self.coeff_var = numpy.array(kwargs.get('coeff_var'), dtype=numpy.float32)
assert self.coeff_var.shape == (5, )
self.fitness = kwargs.get('fitness', float())
self.innov = kwargs.get('innov', float())
self.dt_model = kwargs.get('dt_model', float())
self.kc = kwargs.get('kc', float())
self.ki = kwargs.get('ki', float())
self.kd = kwargs.get('kd', float())
self.kff = kwargs.get('kff', float())
self.att_p = kwargs.get('att_p', float())
if 'rate_sp' not in kwargs:
self.rate_sp = numpy.zeros(3, dtype=numpy.float32)
else:
self.rate_sp = numpy.array(kwargs.get('rate_sp'), dtype=numpy.float32)
assert self.rate_sp.shape == (3, )
self.u_filt = kwargs.get('u_filt', float())
self.y_filt = kwargs.get('y_filt', float())
self.state = kwargs.get('state', int())
def __repr__(self):
typename = self.__class__.__module__.split('.')
typename.pop()
typename.append(self.__class__.__name__)
args = []
for s, t in zip(self.__slots__, self.SLOT_TYPES):
field = getattr(self, s)
fieldstr = repr(field)
# We use Python array type for fields that can be directly stored
# in them, and "normal" sequences for everything else. If it is
# a type that we store in an array, strip off the 'array' portion.
if (
isinstance(t, rosidl_parser.definition.AbstractSequence) and
isinstance(t.value_type, rosidl_parser.definition.BasicType) and
t.value_type.typename in ['float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64']
):
if len(field) == 0:
fieldstr = '[]'
else:
assert fieldstr.startswith('array(')
prefix = "array('X', "
suffix = ')'
fieldstr = fieldstr[len(prefix):-len(suffix)]
args.append(s[1:] + '=' + fieldstr)
return '%s(%s)' % ('.'.join(typename), ', '.join(args))
def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
if self.timestamp != other.timestamp:
return False
if all(self.coeff != other.coeff):
return False
if all(self.coeff_var != other.coeff_var):
return False
if self.fitness != other.fitness:
return False
if self.innov != other.innov:
return False
if self.dt_model != other.dt_model:
return False
if self.kc != other.kc:
return False
if self.ki != other.ki:
return False
if self.kd != other.kd:
return False
if self.kff != other.kff:
return False
if self.att_p != other.att_p:
return False
if all(self.rate_sp != other.rate_sp):
return False
if self.u_filt != other.u_filt:
return False
if self.y_filt != other.y_filt:
return False
if self.state != other.state:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def coeff(self):
"""Message field 'coeff'."""
return self._coeff
@coeff.setter
def coeff(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'coeff' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 5, \
"The 'coeff' numpy.ndarray() must have a size of 5"
self._coeff = 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) == 5 and
all(isinstance(v, float) for v in value) and
True), \
"The 'coeff' field must be a set or sequence with length 5 and each value of type 'float'"
self._coeff = numpy.array(value, dtype=numpy.float32)
@property
def coeff_var(self):
"""Message field 'coeff_var'."""
return self._coeff_var
@coeff_var.setter
def coeff_var(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'coeff_var' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 5, \
"The 'coeff_var' numpy.ndarray() must have a size of 5"
self._coeff_var = 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) == 5 and
all(isinstance(v, float) for v in value) and
True), \
"The 'coeff_var' field must be a set or sequence with length 5 and each value of type 'float'"
self._coeff_var = numpy.array(value, dtype=numpy.float32)
@property
def fitness(self):
"""Message field 'fitness'."""
return self._fitness
@fitness.setter
def fitness(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'fitness' field must be of type 'float'"
self._fitness = value
@property
def innov(self):
"""Message field 'innov'."""
return self._innov
@innov.setter
def innov(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'innov' field must be of type 'float'"
self._innov = value
@property
def dt_model(self):
"""Message field 'dt_model'."""
return self._dt_model
@dt_model.setter
def dt_model(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'dt_model' field must be of type 'float'"
self._dt_model = value
@property
def kc(self):
"""Message field 'kc'."""
return self._kc
@kc.setter
def kc(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'kc' field must be of type 'float'"
self._kc = value
@property
def ki(self):
"""Message field 'ki'."""
return self._ki
@ki.setter
def ki(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'ki' field must be of type 'float'"
self._ki = value
@property
def kd(self):
"""Message field 'kd'."""
return self._kd
@kd.setter
def kd(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'kd' field must be of type 'float'"
self._kd = value
@property
def kff(self):
"""Message field 'kff'."""
return self._kff
@kff.setter
def kff(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'kff' field must be of type 'float'"
self._kff = value
@property
def att_p(self):
"""Message field 'att_p'."""
return self._att_p
@att_p.setter
def att_p(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'att_p' field must be of type 'float'"
self._att_p = value
@property
def rate_sp(self):
"""Message field 'rate_sp'."""
return self._rate_sp
@rate_sp.setter
def rate_sp(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'rate_sp' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 3, \
"The 'rate_sp' numpy.ndarray() must have a size of 3"
self._rate_sp = 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
True), \
"The 'rate_sp' field must be a set or sequence with length 3 and each value of type 'float'"
self._rate_sp = numpy.array(value, dtype=numpy.float32)
@property
def u_filt(self):
"""Message field 'u_filt'."""
return self._u_filt
@u_filt.setter
def u_filt(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'u_filt' field must be of type 'float'"
self._u_filt = value
@property
def y_filt(self):
"""Message field 'y_filt'."""
return self._y_filt
@y_filt.setter
def y_filt(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'y_filt' field must be of type 'float'"
self._y_filt = value
@property
def state(self):
"""Message field 'state'."""
return self._state
@state.setter
def state(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'state' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'state' field must be an unsigned integer in [0, 255]"
self._state = value

View File

@@ -0,0 +1,447 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/AutotuneAttitudeControlStatus.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 "px4_msgs/msg/detail/autotune_attitude_control_status__struct.h"
#include "px4_msgs/msg/detail/autotune_attitude_control_status__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__autotune_attitude_control_status__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[77];
{
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("px4_msgs.msg._autotune_attitude_control_status.AutotuneAttitudeControlStatus", full_classname_dest, 76) == 0);
}
px4_msgs__msg__AutotuneAttitudeControlStatus * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // coeff
PyObject * field = PyObject_GetAttrString(_pymsg, "coeff");
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_FLOAT32);
Py_ssize_t size = 5;
float * dest = ros_message->coeff;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
{ // coeff_var
PyObject * field = PyObject_GetAttrString(_pymsg, "coeff_var");
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_FLOAT32);
Py_ssize_t size = 5;
float * dest = ros_message->coeff_var;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
{ // fitness
PyObject * field = PyObject_GetAttrString(_pymsg, "fitness");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->fitness = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // innov
PyObject * field = PyObject_GetAttrString(_pymsg, "innov");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->innov = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // dt_model
PyObject * field = PyObject_GetAttrString(_pymsg, "dt_model");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->dt_model = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // kc
PyObject * field = PyObject_GetAttrString(_pymsg, "kc");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->kc = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // ki
PyObject * field = PyObject_GetAttrString(_pymsg, "ki");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->ki = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // kd
PyObject * field = PyObject_GetAttrString(_pymsg, "kd");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->kd = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // kff
PyObject * field = PyObject_GetAttrString(_pymsg, "kff");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->kff = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // att_p
PyObject * field = PyObject_GetAttrString(_pymsg, "att_p");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->att_p = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // rate_sp
PyObject * field = PyObject_GetAttrString(_pymsg, "rate_sp");
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_FLOAT32);
Py_ssize_t size = 3;
float * dest = ros_message->rate_sp;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
{ // u_filt
PyObject * field = PyObject_GetAttrString(_pymsg, "u_filt");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->u_filt = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // y_filt
PyObject * field = PyObject_GetAttrString(_pymsg, "y_filt");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->y_filt = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // state
PyObject * field = PyObject_GetAttrString(_pymsg, "state");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->state = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__autotune_attitude_control_status__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of AutotuneAttitudeControlStatus */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._autotune_attitude_control_status");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "AutotuneAttitudeControlStatus");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__AutotuneAttitudeControlStatus * ros_message = (px4_msgs__msg__AutotuneAttitudeControlStatus *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // coeff
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "coeff");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->coeff[0]);
memcpy(dst, src, 5 * sizeof(float));
Py_DECREF(field);
}
{ // coeff_var
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "coeff_var");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->coeff_var[0]);
memcpy(dst, src, 5 * sizeof(float));
Py_DECREF(field);
}
{ // fitness
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->fitness);
{
int rc = PyObject_SetAttrString(_pymessage, "fitness", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // innov
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->innov);
{
int rc = PyObject_SetAttrString(_pymessage, "innov", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // dt_model
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->dt_model);
{
int rc = PyObject_SetAttrString(_pymessage, "dt_model", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // kc
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->kc);
{
int rc = PyObject_SetAttrString(_pymessage, "kc", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // ki
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->ki);
{
int rc = PyObject_SetAttrString(_pymessage, "ki", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // kd
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->kd);
{
int rc = PyObject_SetAttrString(_pymessage, "kd", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // kff
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->kff);
{
int rc = PyObject_SetAttrString(_pymessage, "kff", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // att_p
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->att_p);
{
int rc = PyObject_SetAttrString(_pymessage, "att_p", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // rate_sp
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "rate_sp");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->rate_sp[0]);
memcpy(dst, src, 3 * sizeof(float));
Py_DECREF(field);
}
{ // u_filt
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->u_filt);
{
int rc = PyObject_SetAttrString(_pymessage, "u_filt", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // y_filt
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->y_filt);
{
int rc = PyObject_SetAttrString(_pymessage, "y_filt", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // state
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->state);
{
int rc = PyObject_SetAttrString(_pymessage, "state", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_battery_status.py

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,903 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/BatteryStatus.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 "px4_msgs/msg/detail/battery_status__struct.h"
#include "px4_msgs/msg/detail/battery_status__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__battery_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("px4_msgs.msg._battery_status.BatteryStatus", full_classname_dest, 42) == 0);
}
px4_msgs__msg__BatteryStatus * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(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);
}
{ // voltage_v
PyObject * field = PyObject_GetAttrString(_pymsg, "voltage_v");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->voltage_v = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // voltage_filtered_v
PyObject * field = PyObject_GetAttrString(_pymsg, "voltage_filtered_v");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->voltage_filtered_v = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // current_a
PyObject * field = PyObject_GetAttrString(_pymsg, "current_a");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->current_a = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // current_filtered_a
PyObject * field = PyObject_GetAttrString(_pymsg, "current_filtered_a");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->current_filtered_a = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // current_average_a
PyObject * field = PyObject_GetAttrString(_pymsg, "current_average_a");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->current_average_a = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // discharged_mah
PyObject * field = PyObject_GetAttrString(_pymsg, "discharged_mah");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->discharged_mah = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // remaining
PyObject * field = PyObject_GetAttrString(_pymsg, "remaining");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->remaining = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // scale
PyObject * field = PyObject_GetAttrString(_pymsg, "scale");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->scale = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // time_remaining_s
PyObject * field = PyObject_GetAttrString(_pymsg, "time_remaining_s");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->time_remaining_s = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // temperature
PyObject * field = PyObject_GetAttrString(_pymsg, "temperature");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->temperature = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // cell_count
PyObject * field = PyObject_GetAttrString(_pymsg, "cell_count");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->cell_count = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // source
PyObject * field = PyObject_GetAttrString(_pymsg, "source");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->source = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // priority
PyObject * field = PyObject_GetAttrString(_pymsg, "priority");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->priority = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // capacity
PyObject * field = PyObject_GetAttrString(_pymsg, "capacity");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->capacity = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // cycle_count
PyObject * field = PyObject_GetAttrString(_pymsg, "cycle_count");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->cycle_count = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // average_time_to_empty
PyObject * field = PyObject_GetAttrString(_pymsg, "average_time_to_empty");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->average_time_to_empty = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // serial_number
PyObject * field = PyObject_GetAttrString(_pymsg, "serial_number");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->serial_number = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // manufacture_date
PyObject * field = PyObject_GetAttrString(_pymsg, "manufacture_date");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->manufacture_date = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // state_of_health
PyObject * field = PyObject_GetAttrString(_pymsg, "state_of_health");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->state_of_health = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // max_error
PyObject * field = PyObject_GetAttrString(_pymsg, "max_error");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->max_error = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // id
PyObject * field = PyObject_GetAttrString(_pymsg, "id");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->id = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // interface_error
PyObject * field = PyObject_GetAttrString(_pymsg, "interface_error");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->interface_error = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // voltage_cell_v
PyObject * field = PyObject_GetAttrString(_pymsg, "voltage_cell_v");
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_FLOAT32);
Py_ssize_t size = 14;
float * dest = ros_message->voltage_cell_v;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
{ // max_cell_voltage_delta
PyObject * field = PyObject_GetAttrString(_pymsg, "max_cell_voltage_delta");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->max_cell_voltage_delta = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // is_powering_off
PyObject * field = PyObject_GetAttrString(_pymsg, "is_powering_off");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->is_powering_off = (Py_True == field);
Py_DECREF(field);
}
{ // is_required
PyObject * field = PyObject_GetAttrString(_pymsg, "is_required");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->is_required = (Py_True == field);
Py_DECREF(field);
}
{ // faults
PyObject * field = PyObject_GetAttrString(_pymsg, "faults");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->faults = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // custom_faults
PyObject * field = PyObject_GetAttrString(_pymsg, "custom_faults");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->custom_faults = PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // warning
PyObject * field = PyObject_GetAttrString(_pymsg, "warning");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->warning = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // mode
PyObject * field = PyObject_GetAttrString(_pymsg, "mode");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->mode = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // average_power
PyObject * field = PyObject_GetAttrString(_pymsg, "average_power");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->average_power = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // available_energy
PyObject * field = PyObject_GetAttrString(_pymsg, "available_energy");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->available_energy = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // full_charge_capacity_wh
PyObject * field = PyObject_GetAttrString(_pymsg, "full_charge_capacity_wh");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->full_charge_capacity_wh = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // remaining_capacity_wh
PyObject * field = PyObject_GetAttrString(_pymsg, "remaining_capacity_wh");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->remaining_capacity_wh = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // design_capacity
PyObject * field = PyObject_GetAttrString(_pymsg, "design_capacity");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->design_capacity = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // average_time_to_full
PyObject * field = PyObject_GetAttrString(_pymsg, "average_time_to_full");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->average_time_to_full = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // over_discharge_count
PyObject * field = PyObject_GetAttrString(_pymsg, "over_discharge_count");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->over_discharge_count = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // nominal_voltage
PyObject * field = PyObject_GetAttrString(_pymsg, "nominal_voltage");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->nominal_voltage = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__battery_status__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of BatteryStatus */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._battery_status");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "BatteryStatus");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__BatteryStatus * ros_message = (px4_msgs__msg__BatteryStatus *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", 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;
}
}
}
{ // voltage_v
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->voltage_v);
{
int rc = PyObject_SetAttrString(_pymessage, "voltage_v", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // voltage_filtered_v
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->voltage_filtered_v);
{
int rc = PyObject_SetAttrString(_pymessage, "voltage_filtered_v", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // current_a
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->current_a);
{
int rc = PyObject_SetAttrString(_pymessage, "current_a", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // current_filtered_a
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->current_filtered_a);
{
int rc = PyObject_SetAttrString(_pymessage, "current_filtered_a", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // current_average_a
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->current_average_a);
{
int rc = PyObject_SetAttrString(_pymessage, "current_average_a", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // discharged_mah
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->discharged_mah);
{
int rc = PyObject_SetAttrString(_pymessage, "discharged_mah", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // remaining
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->remaining);
{
int rc = PyObject_SetAttrString(_pymessage, "remaining", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // scale
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->scale);
{
int rc = PyObject_SetAttrString(_pymessage, "scale", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // time_remaining_s
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->time_remaining_s);
{
int rc = PyObject_SetAttrString(_pymessage, "time_remaining_s", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // temperature
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->temperature);
{
int rc = PyObject_SetAttrString(_pymessage, "temperature", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // cell_count
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->cell_count);
{
int rc = PyObject_SetAttrString(_pymessage, "cell_count", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // source
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->source);
{
int rc = PyObject_SetAttrString(_pymessage, "source", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // priority
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->priority);
{
int rc = PyObject_SetAttrString(_pymessage, "priority", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // capacity
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->capacity);
{
int rc = PyObject_SetAttrString(_pymessage, "capacity", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // cycle_count
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->cycle_count);
{
int rc = PyObject_SetAttrString(_pymessage, "cycle_count", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // average_time_to_empty
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->average_time_to_empty);
{
int rc = PyObject_SetAttrString(_pymessage, "average_time_to_empty", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // serial_number
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->serial_number);
{
int rc = PyObject_SetAttrString(_pymessage, "serial_number", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // manufacture_date
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->manufacture_date);
{
int rc = PyObject_SetAttrString(_pymessage, "manufacture_date", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // state_of_health
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->state_of_health);
{
int rc = PyObject_SetAttrString(_pymessage, "state_of_health", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // max_error
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->max_error);
{
int rc = PyObject_SetAttrString(_pymessage, "max_error", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // id
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->id);
{
int rc = PyObject_SetAttrString(_pymessage, "id", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // interface_error
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->interface_error);
{
int rc = PyObject_SetAttrString(_pymessage, "interface_error", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // voltage_cell_v
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "voltage_cell_v");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->voltage_cell_v[0]);
memcpy(dst, src, 14 * sizeof(float));
Py_DECREF(field);
}
{ // max_cell_voltage_delta
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->max_cell_voltage_delta);
{
int rc = PyObject_SetAttrString(_pymessage, "max_cell_voltage_delta", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // is_powering_off
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->is_powering_off ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "is_powering_off", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // is_required
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->is_required ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "is_required", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // faults
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->faults);
{
int rc = PyObject_SetAttrString(_pymessage, "faults", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // custom_faults
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->custom_faults);
{
int rc = PyObject_SetAttrString(_pymessage, "custom_faults", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // warning
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->warning);
{
int rc = PyObject_SetAttrString(_pymessage, "warning", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // mode
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->mode);
{
int rc = PyObject_SetAttrString(_pymessage, "mode", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // average_power
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->average_power);
{
int rc = PyObject_SetAttrString(_pymessage, "average_power", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // available_energy
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->available_energy);
{
int rc = PyObject_SetAttrString(_pymessage, "available_energy", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // full_charge_capacity_wh
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->full_charge_capacity_wh);
{
int rc = PyObject_SetAttrString(_pymessage, "full_charge_capacity_wh", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // remaining_capacity_wh
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->remaining_capacity_wh);
{
int rc = PyObject_SetAttrString(_pymessage, "remaining_capacity_wh", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // design_capacity
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->design_capacity);
{
int rc = PyObject_SetAttrString(_pymessage, "design_capacity", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // average_time_to_full
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->average_time_to_full);
{
int rc = PyObject_SetAttrString(_pymessage, "average_time_to_full", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // over_discharge_count
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->over_discharge_count);
{
int rc = PyObject_SetAttrString(_pymessage, "over_discharge_count", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // nominal_voltage
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->nominal_voltage);
{
int rc = PyObject_SetAttrString(_pymessage, "nominal_voltage", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_button_event.py

View File

@@ -0,0 +1,155 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/ButtonEvent.idl
# generated code does not contain a copyright notice
# Import statements for member types
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_ButtonEvent(type):
"""Metaclass of message 'ButtonEvent'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'ORB_QUEUE_LENGTH': 2,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.ButtonEvent')
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__button_event
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__button_event
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__button_event
cls._TYPE_SUPPORT = module.type_support_msg__msg__button_event
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__button_event
@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 {
'ORB_QUEUE_LENGTH': cls.__constants['ORB_QUEUE_LENGTH'],
}
@property
def ORB_QUEUE_LENGTH(self):
"""Message constant 'ORB_QUEUE_LENGTH'."""
return Metaclass_ButtonEvent.__constants['ORB_QUEUE_LENGTH']
class ButtonEvent(metaclass=Metaclass_ButtonEvent):
"""
Message class 'ButtonEvent'.
Constants:
ORB_QUEUE_LENGTH
"""
__slots__ = [
'_timestamp',
'_triggered',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'triggered': 'boolean',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('boolean'), # 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.timestamp = kwargs.get('timestamp', int())
self.triggered = kwargs.get('triggered', bool())
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.timestamp != other.timestamp:
return False
if self.triggered != other.triggered:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def triggered(self):
"""Message field 'triggered'."""
return self._triggered
@triggered.setter
def triggered(self, value):
if __debug__:
assert \
isinstance(value, bool), \
"The 'triggered' field must be of type 'bool'"
self._triggered = value

View File

@@ -0,0 +1,118 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/ButtonEvent.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 "px4_msgs/msg/detail/button_event__struct.h"
#include "px4_msgs/msg/detail/button_event__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__button_event__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[39];
{
char * class_name = NULL;
char * module_name = NULL;
{
PyObject * class_attr = PyObject_GetAttrString(_pymsg, "__class__");
if (class_attr) {
PyObject * name_attr = PyObject_GetAttrString(class_attr, "__name__");
if (name_attr) {
class_name = (char *)PyUnicode_1BYTE_DATA(name_attr);
Py_DECREF(name_attr);
}
PyObject * module_attr = PyObject_GetAttrString(class_attr, "__module__");
if (module_attr) {
module_name = (char *)PyUnicode_1BYTE_DATA(module_attr);
Py_DECREF(module_attr);
}
Py_DECREF(class_attr);
}
}
if (!class_name || !module_name) {
return false;
}
snprintf(full_classname_dest, sizeof(full_classname_dest), "%s.%s", module_name, class_name);
}
assert(strncmp("px4_msgs.msg._button_event.ButtonEvent", full_classname_dest, 38) == 0);
}
px4_msgs__msg__ButtonEvent * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // triggered
PyObject * field = PyObject_GetAttrString(_pymsg, "triggered");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->triggered = (Py_True == field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__button_event__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of ButtonEvent */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._button_event");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "ButtonEvent");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__ButtonEvent * ros_message = (px4_msgs__msg__ButtonEvent *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // triggered
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->triggered ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "triggered", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_camera_capture.py

View File

@@ -0,0 +1,307 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/CameraCapture.idl
# generated code does not contain a copyright notice
# Import statements for member types
# Member 'q'
import numpy # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_CameraCapture(type):
"""Metaclass of message 'CameraCapture'."""
_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('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.CameraCapture')
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__camera_capture
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__camera_capture
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__camera_capture
cls._TYPE_SUPPORT = module.type_support_msg__msg__camera_capture
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__camera_capture
@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 CameraCapture(metaclass=Metaclass_CameraCapture):
"""Message class 'CameraCapture'."""
__slots__ = [
'_timestamp',
'_timestamp_utc',
'_seq',
'_lat',
'_lon',
'_alt',
'_ground_distance',
'_q',
'_result',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'timestamp_utc': 'uint64',
'seq': 'uint32',
'lat': 'double',
'lon': 'double',
'alt': 'float',
'ground_distance': 'float',
'q': 'float[4]',
'result': 'int8',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint32'), # noqa: E501
rosidl_parser.definition.BasicType('double'), # noqa: E501
rosidl_parser.definition.BasicType('double'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 4), # noqa: E501
rosidl_parser.definition.BasicType('int8'), # 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.timestamp = kwargs.get('timestamp', int())
self.timestamp_utc = kwargs.get('timestamp_utc', int())
self.seq = kwargs.get('seq', int())
self.lat = kwargs.get('lat', float())
self.lon = kwargs.get('lon', float())
self.alt = kwargs.get('alt', float())
self.ground_distance = kwargs.get('ground_distance', float())
if 'q' not in kwargs:
self.q = numpy.zeros(4, dtype=numpy.float32)
else:
self.q = numpy.array(kwargs.get('q'), dtype=numpy.float32)
assert self.q.shape == (4, )
self.result = kwargs.get('result', int())
def __repr__(self):
typename = self.__class__.__module__.split('.')
typename.pop()
typename.append(self.__class__.__name__)
args = []
for s, t in zip(self.__slots__, self.SLOT_TYPES):
field = getattr(self, s)
fieldstr = repr(field)
# We use Python array type for fields that can be directly stored
# in them, and "normal" sequences for everything else. If it is
# a type that we store in an array, strip off the 'array' portion.
if (
isinstance(t, rosidl_parser.definition.AbstractSequence) and
isinstance(t.value_type, rosidl_parser.definition.BasicType) and
t.value_type.typename in ['float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64']
):
if len(field) == 0:
fieldstr = '[]'
else:
assert fieldstr.startswith('array(')
prefix = "array('X', "
suffix = ')'
fieldstr = fieldstr[len(prefix):-len(suffix)]
args.append(s[1:] + '=' + fieldstr)
return '%s(%s)' % ('.'.join(typename), ', '.join(args))
def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
if self.timestamp != other.timestamp:
return False
if self.timestamp_utc != other.timestamp_utc:
return False
if self.seq != other.seq:
return False
if self.lat != other.lat:
return False
if self.lon != other.lon:
return False
if self.alt != other.alt:
return False
if self.ground_distance != other.ground_distance:
return False
if all(self.q != other.q):
return False
if self.result != other.result:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def timestamp_utc(self):
"""Message field 'timestamp_utc'."""
return self._timestamp_utc
@timestamp_utc.setter
def timestamp_utc(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp_utc' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp_utc' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp_utc = value
@property
def seq(self):
"""Message field 'seq'."""
return self._seq
@seq.setter
def seq(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'seq' field must be of type 'int'"
assert value >= 0 and value < 4294967296, \
"The 'seq' field must be an unsigned integer in [0, 4294967295]"
self._seq = value
@property
def lat(self):
"""Message field 'lat'."""
return self._lat
@lat.setter
def lat(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'lat' field must be of type 'float'"
self._lat = value
@property
def lon(self):
"""Message field 'lon'."""
return self._lon
@lon.setter
def lon(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'lon' field must be of type 'float'"
self._lon = value
@property
def alt(self):
"""Message field 'alt'."""
return self._alt
@alt.setter
def alt(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'alt' field must be of type 'float'"
self._alt = value
@property
def ground_distance(self):
"""Message field 'ground_distance'."""
return self._ground_distance
@ground_distance.setter
def ground_distance(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'ground_distance' field must be of type 'float'"
self._ground_distance = value
@property
def q(self):
"""Message field 'q'."""
return self._q
@q.setter
def q(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'q' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 4, \
"The 'q' numpy.ndarray() must have a size of 4"
self._q = value
return
if __debug__:
from collections.abc import Sequence
from collections.abc import Set
from collections import UserList
from collections import UserString
assert \
((isinstance(value, Sequence) or
isinstance(value, Set) or
isinstance(value, UserList)) and
not isinstance(value, str) and
not isinstance(value, UserString) and
len(value) == 4 and
all(isinstance(v, float) for v in value) and
True), \
"The 'q' field must be a set or sequence with length 4 and each value of type 'float'"
self._q = numpy.array(value, dtype=numpy.float32)
@property
def result(self):
"""Message field 'result'."""
return self._result
@result.setter
def result(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'result' field must be of type 'int'"
assert value >= -128 and value < 128, \
"The 'result' field must be an integer in [-128, 127]"
self._result = value

View File

@@ -0,0 +1,283 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/CameraCapture.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 "px4_msgs/msg/detail/camera_capture__struct.h"
#include "px4_msgs/msg/detail/camera_capture__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__camera_capture__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("px4_msgs.msg._camera_capture.CameraCapture", full_classname_dest, 42) == 0);
}
px4_msgs__msg__CameraCapture * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // timestamp_utc
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp_utc");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp_utc = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // seq
PyObject * field = PyObject_GetAttrString(_pymsg, "seq");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->seq = PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // lat
PyObject * field = PyObject_GetAttrString(_pymsg, "lat");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->lat = PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // lon
PyObject * field = PyObject_GetAttrString(_pymsg, "lon");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->lon = PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // alt
PyObject * field = PyObject_GetAttrString(_pymsg, "alt");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->alt = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // ground_distance
PyObject * field = PyObject_GetAttrString(_pymsg, "ground_distance");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->ground_distance = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // q
PyObject * field = PyObject_GetAttrString(_pymsg, "q");
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_FLOAT32);
Py_ssize_t size = 4;
float * dest = ros_message->q;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
{ // result
PyObject * field = PyObject_GetAttrString(_pymsg, "result");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->result = (int8_t)PyLong_AsLong(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__camera_capture__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of CameraCapture */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._camera_capture");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "CameraCapture");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__CameraCapture * ros_message = (px4_msgs__msg__CameraCapture *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // timestamp_utc
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp_utc);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp_utc", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // seq
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->seq);
{
int rc = PyObject_SetAttrString(_pymessage, "seq", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // lat
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->lat);
{
int rc = PyObject_SetAttrString(_pymessage, "lat", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // lon
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->lon);
{
int rc = PyObject_SetAttrString(_pymessage, "lon", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // alt
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->alt);
{
int rc = PyObject_SetAttrString(_pymessage, "alt", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // ground_distance
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->ground_distance);
{
int rc = PyObject_SetAttrString(_pymessage, "ground_distance", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // q
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "q");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->q[0]);
memcpy(dst, src, 4 * sizeof(float));
Py_DECREF(field);
}
{ // result
PyObject * field = NULL;
field = PyLong_FromLong(ros_message->result);
{
int rc = PyObject_SetAttrString(_pymessage, "result", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_camera_status.py

View File

@@ -0,0 +1,166 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/CameraStatus.idl
# generated code does not contain a copyright notice
# Import statements for member types
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_CameraStatus(type):
"""Metaclass of message 'CameraStatus'."""
_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('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.CameraStatus')
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__camera_status
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__camera_status
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__camera_status
cls._TYPE_SUPPORT = module.type_support_msg__msg__camera_status
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__camera_status
@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 CameraStatus(metaclass=Metaclass_CameraStatus):
"""Message class 'CameraStatus'."""
__slots__ = [
'_timestamp',
'_active_sys_id',
'_active_comp_id',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'active_sys_id': 'uint8',
'active_comp_id': 'uint8',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
)
def __init__(self, **kwargs):
assert all('_' + key in self.__slots__ for key in kwargs.keys()), \
'Invalid arguments passed to constructor: %s' % \
', '.join(sorted(k for k in kwargs.keys() if '_' + k not in self.__slots__))
self.timestamp = kwargs.get('timestamp', int())
self.active_sys_id = kwargs.get('active_sys_id', int())
self.active_comp_id = kwargs.get('active_comp_id', int())
def __repr__(self):
typename = self.__class__.__module__.split('.')
typename.pop()
typename.append(self.__class__.__name__)
args = []
for s, t in zip(self.__slots__, self.SLOT_TYPES):
field = getattr(self, s)
fieldstr = repr(field)
# We use Python array type for fields that can be directly stored
# in them, and "normal" sequences for everything else. If it is
# a type that we store in an array, strip off the 'array' portion.
if (
isinstance(t, rosidl_parser.definition.AbstractSequence) and
isinstance(t.value_type, rosidl_parser.definition.BasicType) and
t.value_type.typename in ['float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64']
):
if len(field) == 0:
fieldstr = '[]'
else:
assert fieldstr.startswith('array(')
prefix = "array('X', "
suffix = ')'
fieldstr = fieldstr[len(prefix):-len(suffix)]
args.append(s[1:] + '=' + fieldstr)
return '%s(%s)' % ('.'.join(typename), ', '.join(args))
def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
if self.timestamp != other.timestamp:
return False
if self.active_sys_id != other.active_sys_id:
return False
if self.active_comp_id != other.active_comp_id:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def active_sys_id(self):
"""Message field 'active_sys_id'."""
return self._active_sys_id
@active_sys_id.setter
def active_sys_id(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'active_sys_id' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'active_sys_id' field must be an unsigned integer in [0, 255]"
self._active_sys_id = value
@property
def active_comp_id(self):
"""Message field 'active_comp_id'."""
return self._active_comp_id
@active_comp_id.setter
def active_comp_id(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'active_comp_id' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'active_comp_id' field must be an unsigned integer in [0, 255]"
self._active_comp_id = value

View File

@@ -0,0 +1,138 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/CameraStatus.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 "px4_msgs/msg/detail/camera_status__struct.h"
#include "px4_msgs/msg/detail/camera_status__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__camera_status__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("px4_msgs.msg._camera_status.CameraStatus", full_classname_dest, 40) == 0);
}
px4_msgs__msg__CameraStatus * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // active_sys_id
PyObject * field = PyObject_GetAttrString(_pymsg, "active_sys_id");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->active_sys_id = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // active_comp_id
PyObject * field = PyObject_GetAttrString(_pymsg, "active_comp_id");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->active_comp_id = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__camera_status__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of CameraStatus */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._camera_status");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "CameraStatus");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__CameraStatus * ros_message = (px4_msgs__msg__CameraStatus *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // active_sys_id
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->active_sys_id);
{
int rc = PyObject_SetAttrString(_pymessage, "active_sys_id", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // active_comp_id
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->active_comp_id);
{
int rc = PyObject_SetAttrString(_pymessage, "active_comp_id", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_camera_trigger.py

View File

@@ -0,0 +1,197 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/CameraTrigger.idl
# generated code does not contain a copyright notice
# Import statements for member types
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_CameraTrigger(type):
"""Metaclass of message 'CameraTrigger'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'ORB_QUEUE_LENGTH': 2,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.CameraTrigger')
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__camera_trigger
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__camera_trigger
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__camera_trigger
cls._TYPE_SUPPORT = module.type_support_msg__msg__camera_trigger
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__camera_trigger
@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 {
'ORB_QUEUE_LENGTH': cls.__constants['ORB_QUEUE_LENGTH'],
}
@property
def ORB_QUEUE_LENGTH(self):
"""Message constant 'ORB_QUEUE_LENGTH'."""
return Metaclass_CameraTrigger.__constants['ORB_QUEUE_LENGTH']
class CameraTrigger(metaclass=Metaclass_CameraTrigger):
"""
Message class 'CameraTrigger'.
Constants:
ORB_QUEUE_LENGTH
"""
__slots__ = [
'_timestamp',
'_timestamp_utc',
'_seq',
'_feedback',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'timestamp_utc': 'uint64',
'seq': 'uint32',
'feedback': 'boolean',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint32'), # noqa: E501
rosidl_parser.definition.BasicType('boolean'), # 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.timestamp = kwargs.get('timestamp', int())
self.timestamp_utc = kwargs.get('timestamp_utc', int())
self.seq = kwargs.get('seq', int())
self.feedback = kwargs.get('feedback', bool())
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.timestamp != other.timestamp:
return False
if self.timestamp_utc != other.timestamp_utc:
return False
if self.seq != other.seq:
return False
if self.feedback != other.feedback:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def timestamp_utc(self):
"""Message field 'timestamp_utc'."""
return self._timestamp_utc
@timestamp_utc.setter
def timestamp_utc(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp_utc' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp_utc' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp_utc = value
@property
def seq(self):
"""Message field 'seq'."""
return self._seq
@seq.setter
def seq(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'seq' field must be of type 'int'"
assert value >= 0 and value < 4294967296, \
"The 'seq' field must be an unsigned integer in [0, 4294967295]"
self._seq = value
@property
def feedback(self):
"""Message field 'feedback'."""
return self._feedback
@feedback.setter
def feedback(self, value):
if __debug__:
assert \
isinstance(value, bool), \
"The 'feedback' field must be of type 'bool'"
self._feedback = value

View File

@@ -0,0 +1,158 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/CameraTrigger.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 "px4_msgs/msg/detail/camera_trigger__struct.h"
#include "px4_msgs/msg/detail/camera_trigger__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__camera_trigger__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("px4_msgs.msg._camera_trigger.CameraTrigger", full_classname_dest, 42) == 0);
}
px4_msgs__msg__CameraTrigger * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // timestamp_utc
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp_utc");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp_utc = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // seq
PyObject * field = PyObject_GetAttrString(_pymsg, "seq");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->seq = PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // feedback
PyObject * field = PyObject_GetAttrString(_pymsg, "feedback");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->feedback = (Py_True == field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__camera_trigger__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of CameraTrigger */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._camera_trigger");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "CameraTrigger");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__CameraTrigger * ros_message = (px4_msgs__msg__CameraTrigger *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // timestamp_utc
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp_utc);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp_utc", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // seq
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->seq);
{
int rc = PyObject_SetAttrString(_pymessage, "seq", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // feedback
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->feedback ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "feedback", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_cellular_status.py

View File

@@ -0,0 +1,411 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/CellularStatus.idl
# generated code does not contain a copyright notice
# Import statements for member types
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_CellularStatus(type):
"""Metaclass of message 'CellularStatus'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'CELLULAR_STATUS_FLAG_UNKNOWN': 0,
'CELLULAR_STATUS_FLAG_FAILED': 1,
'CELLULAR_STATUS_FLAG_INITIALIZING': 2,
'CELLULAR_STATUS_FLAG_LOCKED': 3,
'CELLULAR_STATUS_FLAG_DISABLED': 4,
'CELLULAR_STATUS_FLAG_DISABLING': 5,
'CELLULAR_STATUS_FLAG_ENABLING': 6,
'CELLULAR_STATUS_FLAG_ENABLED': 7,
'CELLULAR_STATUS_FLAG_SEARCHING': 8,
'CELLULAR_STATUS_FLAG_REGISTERED': 9,
'CELLULAR_STATUS_FLAG_DISCONNECTING': 10,
'CELLULAR_STATUS_FLAG_CONNECTING': 11,
'CELLULAR_STATUS_FLAG_CONNECTED': 12,
'CELLULAR_NETWORK_FAILED_REASON_NONE': 0,
'CELLULAR_NETWORK_FAILED_REASON_UNKNOWN': 1,
'CELLULAR_NETWORK_FAILED_REASON_SIM_MISSING': 2,
'CELLULAR_NETWORK_FAILED_REASON_SIM_ERROR': 3,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.CellularStatus')
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__cellular_status
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__cellular_status
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__cellular_status
cls._TYPE_SUPPORT = module.type_support_msg__msg__cellular_status
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__cellular_status
@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 {
'CELLULAR_STATUS_FLAG_UNKNOWN': cls.__constants['CELLULAR_STATUS_FLAG_UNKNOWN'],
'CELLULAR_STATUS_FLAG_FAILED': cls.__constants['CELLULAR_STATUS_FLAG_FAILED'],
'CELLULAR_STATUS_FLAG_INITIALIZING': cls.__constants['CELLULAR_STATUS_FLAG_INITIALIZING'],
'CELLULAR_STATUS_FLAG_LOCKED': cls.__constants['CELLULAR_STATUS_FLAG_LOCKED'],
'CELLULAR_STATUS_FLAG_DISABLED': cls.__constants['CELLULAR_STATUS_FLAG_DISABLED'],
'CELLULAR_STATUS_FLAG_DISABLING': cls.__constants['CELLULAR_STATUS_FLAG_DISABLING'],
'CELLULAR_STATUS_FLAG_ENABLING': cls.__constants['CELLULAR_STATUS_FLAG_ENABLING'],
'CELLULAR_STATUS_FLAG_ENABLED': cls.__constants['CELLULAR_STATUS_FLAG_ENABLED'],
'CELLULAR_STATUS_FLAG_SEARCHING': cls.__constants['CELLULAR_STATUS_FLAG_SEARCHING'],
'CELLULAR_STATUS_FLAG_REGISTERED': cls.__constants['CELLULAR_STATUS_FLAG_REGISTERED'],
'CELLULAR_STATUS_FLAG_DISCONNECTING': cls.__constants['CELLULAR_STATUS_FLAG_DISCONNECTING'],
'CELLULAR_STATUS_FLAG_CONNECTING': cls.__constants['CELLULAR_STATUS_FLAG_CONNECTING'],
'CELLULAR_STATUS_FLAG_CONNECTED': cls.__constants['CELLULAR_STATUS_FLAG_CONNECTED'],
'CELLULAR_NETWORK_FAILED_REASON_NONE': cls.__constants['CELLULAR_NETWORK_FAILED_REASON_NONE'],
'CELLULAR_NETWORK_FAILED_REASON_UNKNOWN': cls.__constants['CELLULAR_NETWORK_FAILED_REASON_UNKNOWN'],
'CELLULAR_NETWORK_FAILED_REASON_SIM_MISSING': cls.__constants['CELLULAR_NETWORK_FAILED_REASON_SIM_MISSING'],
'CELLULAR_NETWORK_FAILED_REASON_SIM_ERROR': cls.__constants['CELLULAR_NETWORK_FAILED_REASON_SIM_ERROR'],
}
@property
def CELLULAR_STATUS_FLAG_UNKNOWN(self):
"""Message constant 'CELLULAR_STATUS_FLAG_UNKNOWN'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_UNKNOWN']
@property
def CELLULAR_STATUS_FLAG_FAILED(self):
"""Message constant 'CELLULAR_STATUS_FLAG_FAILED'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_FAILED']
@property
def CELLULAR_STATUS_FLAG_INITIALIZING(self):
"""Message constant 'CELLULAR_STATUS_FLAG_INITIALIZING'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_INITIALIZING']
@property
def CELLULAR_STATUS_FLAG_LOCKED(self):
"""Message constant 'CELLULAR_STATUS_FLAG_LOCKED'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_LOCKED']
@property
def CELLULAR_STATUS_FLAG_DISABLED(self):
"""Message constant 'CELLULAR_STATUS_FLAG_DISABLED'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_DISABLED']
@property
def CELLULAR_STATUS_FLAG_DISABLING(self):
"""Message constant 'CELLULAR_STATUS_FLAG_DISABLING'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_DISABLING']
@property
def CELLULAR_STATUS_FLAG_ENABLING(self):
"""Message constant 'CELLULAR_STATUS_FLAG_ENABLING'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_ENABLING']
@property
def CELLULAR_STATUS_FLAG_ENABLED(self):
"""Message constant 'CELLULAR_STATUS_FLAG_ENABLED'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_ENABLED']
@property
def CELLULAR_STATUS_FLAG_SEARCHING(self):
"""Message constant 'CELLULAR_STATUS_FLAG_SEARCHING'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_SEARCHING']
@property
def CELLULAR_STATUS_FLAG_REGISTERED(self):
"""Message constant 'CELLULAR_STATUS_FLAG_REGISTERED'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_REGISTERED']
@property
def CELLULAR_STATUS_FLAG_DISCONNECTING(self):
"""Message constant 'CELLULAR_STATUS_FLAG_DISCONNECTING'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_DISCONNECTING']
@property
def CELLULAR_STATUS_FLAG_CONNECTING(self):
"""Message constant 'CELLULAR_STATUS_FLAG_CONNECTING'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_CONNECTING']
@property
def CELLULAR_STATUS_FLAG_CONNECTED(self):
"""Message constant 'CELLULAR_STATUS_FLAG_CONNECTED'."""
return Metaclass_CellularStatus.__constants['CELLULAR_STATUS_FLAG_CONNECTED']
@property
def CELLULAR_NETWORK_FAILED_REASON_NONE(self):
"""Message constant 'CELLULAR_NETWORK_FAILED_REASON_NONE'."""
return Metaclass_CellularStatus.__constants['CELLULAR_NETWORK_FAILED_REASON_NONE']
@property
def CELLULAR_NETWORK_FAILED_REASON_UNKNOWN(self):
"""Message constant 'CELLULAR_NETWORK_FAILED_REASON_UNKNOWN'."""
return Metaclass_CellularStatus.__constants['CELLULAR_NETWORK_FAILED_REASON_UNKNOWN']
@property
def CELLULAR_NETWORK_FAILED_REASON_SIM_MISSING(self):
"""Message constant 'CELLULAR_NETWORK_FAILED_REASON_SIM_MISSING'."""
return Metaclass_CellularStatus.__constants['CELLULAR_NETWORK_FAILED_REASON_SIM_MISSING']
@property
def CELLULAR_NETWORK_FAILED_REASON_SIM_ERROR(self):
"""Message constant 'CELLULAR_NETWORK_FAILED_REASON_SIM_ERROR'."""
return Metaclass_CellularStatus.__constants['CELLULAR_NETWORK_FAILED_REASON_SIM_ERROR']
class CellularStatus(metaclass=Metaclass_CellularStatus):
"""
Message class 'CellularStatus'.
Constants:
CELLULAR_STATUS_FLAG_UNKNOWN
CELLULAR_STATUS_FLAG_FAILED
CELLULAR_STATUS_FLAG_INITIALIZING
CELLULAR_STATUS_FLAG_LOCKED
CELLULAR_STATUS_FLAG_DISABLED
CELLULAR_STATUS_FLAG_DISABLING
CELLULAR_STATUS_FLAG_ENABLING
CELLULAR_STATUS_FLAG_ENABLED
CELLULAR_STATUS_FLAG_SEARCHING
CELLULAR_STATUS_FLAG_REGISTERED
CELLULAR_STATUS_FLAG_DISCONNECTING
CELLULAR_STATUS_FLAG_CONNECTING
CELLULAR_STATUS_FLAG_CONNECTED
CELLULAR_NETWORK_FAILED_REASON_NONE
CELLULAR_NETWORK_FAILED_REASON_UNKNOWN
CELLULAR_NETWORK_FAILED_REASON_SIM_MISSING
CELLULAR_NETWORK_FAILED_REASON_SIM_ERROR
"""
__slots__ = [
'_timestamp',
'_status',
'_failure_reason',
'_type',
'_quality',
'_mcc',
'_mnc',
'_lac',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'status': 'uint16',
'failure_reason': 'uint8',
'type': 'uint8',
'quality': 'uint8',
'mcc': 'uint16',
'mnc': 'uint16',
'lac': 'uint16',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint16'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint16'), # noqa: E501
rosidl_parser.definition.BasicType('uint16'), # noqa: E501
rosidl_parser.definition.BasicType('uint16'), # 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.timestamp = kwargs.get('timestamp', int())
self.status = kwargs.get('status', int())
self.failure_reason = kwargs.get('failure_reason', int())
self.type = kwargs.get('type', int())
self.quality = kwargs.get('quality', int())
self.mcc = kwargs.get('mcc', int())
self.mnc = kwargs.get('mnc', int())
self.lac = kwargs.get('lac', int())
def __repr__(self):
typename = self.__class__.__module__.split('.')
typename.pop()
typename.append(self.__class__.__name__)
args = []
for s, t in zip(self.__slots__, self.SLOT_TYPES):
field = getattr(self, s)
fieldstr = repr(field)
# We use Python array type for fields that can be directly stored
# in them, and "normal" sequences for everything else. If it is
# a type that we store in an array, strip off the 'array' portion.
if (
isinstance(t, rosidl_parser.definition.AbstractSequence) and
isinstance(t.value_type, rosidl_parser.definition.BasicType) and
t.value_type.typename in ['float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64']
):
if len(field) == 0:
fieldstr = '[]'
else:
assert fieldstr.startswith('array(')
prefix = "array('X', "
suffix = ')'
fieldstr = fieldstr[len(prefix):-len(suffix)]
args.append(s[1:] + '=' + fieldstr)
return '%s(%s)' % ('.'.join(typename), ', '.join(args))
def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
if self.timestamp != other.timestamp:
return False
if self.status != other.status:
return False
if self.failure_reason != other.failure_reason:
return False
if self.type != other.type:
return False
if self.quality != other.quality:
return False
if self.mcc != other.mcc:
return False
if self.mnc != other.mnc:
return False
if self.lac != other.lac:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def status(self):
"""Message field 'status'."""
return self._status
@status.setter
def status(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'status' field must be of type 'int'"
assert value >= 0 and value < 65536, \
"The 'status' field must be an unsigned integer in [0, 65535]"
self._status = value
@property
def failure_reason(self):
"""Message field 'failure_reason'."""
return self._failure_reason
@failure_reason.setter
def failure_reason(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'failure_reason' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'failure_reason' field must be an unsigned integer in [0, 255]"
self._failure_reason = value
@property # noqa: A003
def type(self): # noqa: A003
"""Message field 'type'."""
return self._type
@type.setter # noqa: A003
def type(self, value): # noqa: A003
if __debug__:
assert \
isinstance(value, int), \
"The 'type' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'type' field must be an unsigned integer in [0, 255]"
self._type = value
@property
def quality(self):
"""Message field 'quality'."""
return self._quality
@quality.setter
def quality(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'quality' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'quality' field must be an unsigned integer in [0, 255]"
self._quality = value
@property
def mcc(self):
"""Message field 'mcc'."""
return self._mcc
@mcc.setter
def mcc(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'mcc' field must be of type 'int'"
assert value >= 0 and value < 65536, \
"The 'mcc' field must be an unsigned integer in [0, 65535]"
self._mcc = value
@property
def mnc(self):
"""Message field 'mnc'."""
return self._mnc
@mnc.setter
def mnc(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'mnc' field must be of type 'int'"
assert value >= 0 and value < 65536, \
"The 'mnc' field must be an unsigned integer in [0, 65535]"
self._mnc = value
@property
def lac(self):
"""Message field 'lac'."""
return self._lac
@lac.setter
def lac(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'lac' field must be of type 'int'"
assert value >= 0 and value < 65536, \
"The 'lac' field must be an unsigned integer in [0, 65535]"
self._lac = value

View File

@@ -0,0 +1,238 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/CellularStatus.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 "px4_msgs/msg/detail/cellular_status__struct.h"
#include "px4_msgs/msg/detail/cellular_status__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__cellular_status__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("px4_msgs.msg._cellular_status.CellularStatus", full_classname_dest, 44) == 0);
}
px4_msgs__msg__CellularStatus * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // status
PyObject * field = PyObject_GetAttrString(_pymsg, "status");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->status = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // failure_reason
PyObject * field = PyObject_GetAttrString(_pymsg, "failure_reason");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->failure_reason = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // type
PyObject * field = PyObject_GetAttrString(_pymsg, "type");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->type = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // quality
PyObject * field = PyObject_GetAttrString(_pymsg, "quality");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->quality = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // mcc
PyObject * field = PyObject_GetAttrString(_pymsg, "mcc");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->mcc = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // mnc
PyObject * field = PyObject_GetAttrString(_pymsg, "mnc");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->mnc = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // lac
PyObject * field = PyObject_GetAttrString(_pymsg, "lac");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->lac = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__cellular_status__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of CellularStatus */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._cellular_status");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "CellularStatus");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__CellularStatus * ros_message = (px4_msgs__msg__CellularStatus *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // status
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->status);
{
int rc = PyObject_SetAttrString(_pymessage, "status", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // failure_reason
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->failure_reason);
{
int rc = PyObject_SetAttrString(_pymessage, "failure_reason", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // type
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->type);
{
int rc = PyObject_SetAttrString(_pymessage, "type", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // quality
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->quality);
{
int rc = PyObject_SetAttrString(_pymessage, "quality", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // mcc
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->mcc);
{
int rc = PyObject_SetAttrString(_pymessage, "mcc", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // mnc
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->mnc);
{
int rc = PyObject_SetAttrString(_pymessage, "mnc", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // lac
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->lac);
{
int rc = PyObject_SetAttrString(_pymessage, "lac", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_collision_constraints.py

View File

@@ -0,0 +1,210 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/CollisionConstraints.idl
# generated code does not contain a copyright notice
# Import statements for member types
# Member 'original_setpoint'
# Member 'adapted_setpoint'
import numpy # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_CollisionConstraints(type):
"""Metaclass of message 'CollisionConstraints'."""
_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('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.CollisionConstraints')
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__collision_constraints
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__collision_constraints
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__collision_constraints
cls._TYPE_SUPPORT = module.type_support_msg__msg__collision_constraints
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__collision_constraints
@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 CollisionConstraints(metaclass=Metaclass_CollisionConstraints):
"""Message class 'CollisionConstraints'."""
__slots__ = [
'_timestamp',
'_original_setpoint',
'_adapted_setpoint',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'original_setpoint': 'float[2]',
'adapted_setpoint': 'float[2]',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 2), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 2), # 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.timestamp = kwargs.get('timestamp', int())
if 'original_setpoint' not in kwargs:
self.original_setpoint = numpy.zeros(2, dtype=numpy.float32)
else:
self.original_setpoint = numpy.array(kwargs.get('original_setpoint'), dtype=numpy.float32)
assert self.original_setpoint.shape == (2, )
if 'adapted_setpoint' not in kwargs:
self.adapted_setpoint = numpy.zeros(2, dtype=numpy.float32)
else:
self.adapted_setpoint = numpy.array(kwargs.get('adapted_setpoint'), dtype=numpy.float32)
assert self.adapted_setpoint.shape == (2, )
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.timestamp != other.timestamp:
return False
if all(self.original_setpoint != other.original_setpoint):
return False
if all(self.adapted_setpoint != other.adapted_setpoint):
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def original_setpoint(self):
"""Message field 'original_setpoint'."""
return self._original_setpoint
@original_setpoint.setter
def original_setpoint(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'original_setpoint' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 2, \
"The 'original_setpoint' numpy.ndarray() must have a size of 2"
self._original_setpoint = 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) == 2 and
all(isinstance(v, float) for v in value) and
True), \
"The 'original_setpoint' field must be a set or sequence with length 2 and each value of type 'float'"
self._original_setpoint = numpy.array(value, dtype=numpy.float32)
@property
def adapted_setpoint(self):
"""Message field 'adapted_setpoint'."""
return self._adapted_setpoint
@adapted_setpoint.setter
def adapted_setpoint(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'adapted_setpoint' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 2, \
"The 'adapted_setpoint' numpy.ndarray() must have a size of 2"
self._adapted_setpoint = 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) == 2 and
all(isinstance(v, float) for v in value) and
True), \
"The 'adapted_setpoint' field must be a set or sequence with length 2 and each value of type 'float'"
self._adapted_setpoint = numpy.array(value, dtype=numpy.float32)

View File

@@ -0,0 +1,185 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/CollisionConstraints.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 "px4_msgs/msg/detail/collision_constraints__struct.h"
#include "px4_msgs/msg/detail/collision_constraints__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__collision_constraints__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[57];
{
char * class_name = NULL;
char * module_name = NULL;
{
PyObject * class_attr = PyObject_GetAttrString(_pymsg, "__class__");
if (class_attr) {
PyObject * name_attr = PyObject_GetAttrString(class_attr, "__name__");
if (name_attr) {
class_name = (char *)PyUnicode_1BYTE_DATA(name_attr);
Py_DECREF(name_attr);
}
PyObject * module_attr = PyObject_GetAttrString(class_attr, "__module__");
if (module_attr) {
module_name = (char *)PyUnicode_1BYTE_DATA(module_attr);
Py_DECREF(module_attr);
}
Py_DECREF(class_attr);
}
}
if (!class_name || !module_name) {
return false;
}
snprintf(full_classname_dest, sizeof(full_classname_dest), "%s.%s", module_name, class_name);
}
assert(strncmp("px4_msgs.msg._collision_constraints.CollisionConstraints", full_classname_dest, 56) == 0);
}
px4_msgs__msg__CollisionConstraints * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // original_setpoint
PyObject * field = PyObject_GetAttrString(_pymsg, "original_setpoint");
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_FLOAT32);
Py_ssize_t size = 2;
float * dest = ros_message->original_setpoint;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
{ // adapted_setpoint
PyObject * field = PyObject_GetAttrString(_pymsg, "adapted_setpoint");
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_FLOAT32);
Py_ssize_t size = 2;
float * dest = ros_message->adapted_setpoint;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__collision_constraints__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of CollisionConstraints */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._collision_constraints");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "CollisionConstraints");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__CollisionConstraints * ros_message = (px4_msgs__msg__CollisionConstraints *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // original_setpoint
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "original_setpoint");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->original_setpoint[0]);
memcpy(dst, src, 2 * sizeof(float));
Py_DECREF(field);
}
{ // adapted_setpoint
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "adapted_setpoint");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->adapted_setpoint[0]);
memcpy(dst, src, 2 * sizeof(float));
Py_DECREF(field);
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_collision_report.py

View File

@@ -0,0 +1,265 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/CollisionReport.idl
# generated code does not contain a copyright notice
# Import statements for member types
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_CollisionReport(type):
"""Metaclass of message 'CollisionReport'."""
_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('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.CollisionReport')
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__collision_report
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__collision_report
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__collision_report
cls._TYPE_SUPPORT = module.type_support_msg__msg__collision_report
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__collision_report
@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 CollisionReport(metaclass=Metaclass_CollisionReport):
"""Message class 'CollisionReport'."""
__slots__ = [
'_timestamp',
'_src',
'_id',
'_action',
'_threat_level',
'_time_to_minimum_delta',
'_altitude_minimum_delta',
'_horizontal_minimum_delta',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'src': 'uint8',
'id': 'uint32',
'action': 'uint8',
'threat_level': 'uint8',
'time_to_minimum_delta': 'float',
'altitude_minimum_delta': 'float',
'horizontal_minimum_delta': 'float',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint32'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('uint8'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
)
def __init__(self, **kwargs):
assert all('_' + key in self.__slots__ for key in kwargs.keys()), \
'Invalid arguments passed to constructor: %s' % \
', '.join(sorted(k for k in kwargs.keys() if '_' + k not in self.__slots__))
self.timestamp = kwargs.get('timestamp', int())
self.src = kwargs.get('src', int())
self.id = kwargs.get('id', int())
self.action = kwargs.get('action', int())
self.threat_level = kwargs.get('threat_level', int())
self.time_to_minimum_delta = kwargs.get('time_to_minimum_delta', float())
self.altitude_minimum_delta = kwargs.get('altitude_minimum_delta', float())
self.horizontal_minimum_delta = kwargs.get('horizontal_minimum_delta', 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.timestamp != other.timestamp:
return False
if self.src != other.src:
return False
if self.id != other.id:
return False
if self.action != other.action:
return False
if self.threat_level != other.threat_level:
return False
if self.time_to_minimum_delta != other.time_to_minimum_delta:
return False
if self.altitude_minimum_delta != other.altitude_minimum_delta:
return False
if self.horizontal_minimum_delta != other.horizontal_minimum_delta:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def src(self):
"""Message field 'src'."""
return self._src
@src.setter
def src(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'src' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'src' field must be an unsigned integer in [0, 255]"
self._src = value
@property # noqa: A003
def id(self): # noqa: A003
"""Message field 'id'."""
return self._id
@id.setter # noqa: A003
def id(self, value): # noqa: A003
if __debug__:
assert \
isinstance(value, int), \
"The 'id' field must be of type 'int'"
assert value >= 0 and value < 4294967296, \
"The 'id' field must be an unsigned integer in [0, 4294967295]"
self._id = value
@property
def action(self):
"""Message field 'action'."""
return self._action
@action.setter
def action(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'action' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'action' field must be an unsigned integer in [0, 255]"
self._action = value
@property
def threat_level(self):
"""Message field 'threat_level'."""
return self._threat_level
@threat_level.setter
def threat_level(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'threat_level' field must be of type 'int'"
assert value >= 0 and value < 256, \
"The 'threat_level' field must be an unsigned integer in [0, 255]"
self._threat_level = value
@property
def time_to_minimum_delta(self):
"""Message field 'time_to_minimum_delta'."""
return self._time_to_minimum_delta
@time_to_minimum_delta.setter
def time_to_minimum_delta(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'time_to_minimum_delta' field must be of type 'float'"
self._time_to_minimum_delta = value
@property
def altitude_minimum_delta(self):
"""Message field 'altitude_minimum_delta'."""
return self._altitude_minimum_delta
@altitude_minimum_delta.setter
def altitude_minimum_delta(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'altitude_minimum_delta' field must be of type 'float'"
self._altitude_minimum_delta = value
@property
def horizontal_minimum_delta(self):
"""Message field 'horizontal_minimum_delta'."""
return self._horizontal_minimum_delta
@horizontal_minimum_delta.setter
def horizontal_minimum_delta(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'horizontal_minimum_delta' field must be of type 'float'"
self._horizontal_minimum_delta = value

View File

@@ -0,0 +1,238 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/CollisionReport.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 "px4_msgs/msg/detail/collision_report__struct.h"
#include "px4_msgs/msg/detail/collision_report__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__collision_report__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[47];
{
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("px4_msgs.msg._collision_report.CollisionReport", full_classname_dest, 46) == 0);
}
px4_msgs__msg__CollisionReport * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // src
PyObject * field = PyObject_GetAttrString(_pymsg, "src");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->src = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // id
PyObject * field = PyObject_GetAttrString(_pymsg, "id");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->id = PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // action
PyObject * field = PyObject_GetAttrString(_pymsg, "action");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->action = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // threat_level
PyObject * field = PyObject_GetAttrString(_pymsg, "threat_level");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->threat_level = (uint8_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // time_to_minimum_delta
PyObject * field = PyObject_GetAttrString(_pymsg, "time_to_minimum_delta");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->time_to_minimum_delta = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // altitude_minimum_delta
PyObject * field = PyObject_GetAttrString(_pymsg, "altitude_minimum_delta");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->altitude_minimum_delta = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // horizontal_minimum_delta
PyObject * field = PyObject_GetAttrString(_pymsg, "horizontal_minimum_delta");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->horizontal_minimum_delta = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__collision_report__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of CollisionReport */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._collision_report");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "CollisionReport");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__CollisionReport * ros_message = (px4_msgs__msg__CollisionReport *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // src
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->src);
{
int rc = PyObject_SetAttrString(_pymessage, "src", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // id
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->id);
{
int rc = PyObject_SetAttrString(_pymessage, "id", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // action
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->action);
{
int rc = PyObject_SetAttrString(_pymessage, "action", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // threat_level
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->threat_level);
{
int rc = PyObject_SetAttrString(_pymessage, "threat_level", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // time_to_minimum_delta
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->time_to_minimum_delta);
{
int rc = PyObject_SetAttrString(_pymessage, "time_to_minimum_delta", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // altitude_minimum_delta
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->altitude_minimum_delta);
{
int rc = PyObject_SetAttrString(_pymessage, "altitude_minimum_delta", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // horizontal_minimum_delta
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->horizontal_minimum_delta);
{
int rc = PyObject_SetAttrString(_pymessage, "horizontal_minimum_delta", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_commander_state.py

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_control_allocator_status.py

View File

@@ -0,0 +1,355 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/ControlAllocatorStatus.idl
# generated code does not contain a copyright notice
# Import statements for member types
# Member 'unallocated_torque'
# Member 'unallocated_thrust'
# Member 'actuator_saturation'
import numpy # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_ControlAllocatorStatus(type):
"""Metaclass of message 'ControlAllocatorStatus'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'ACTUATOR_SATURATION_OK': 0,
'ACTUATOR_SATURATION_UPPER_DYN': 1,
'ACTUATOR_SATURATION_UPPER': 2,
'ACTUATOR_SATURATION_LOWER_DYN': -1,
'ACTUATOR_SATURATION_LOWER': -2,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.ControlAllocatorStatus')
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__control_allocator_status
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__control_allocator_status
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__control_allocator_status
cls._TYPE_SUPPORT = module.type_support_msg__msg__control_allocator_status
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__control_allocator_status
@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 {
'ACTUATOR_SATURATION_OK': cls.__constants['ACTUATOR_SATURATION_OK'],
'ACTUATOR_SATURATION_UPPER_DYN': cls.__constants['ACTUATOR_SATURATION_UPPER_DYN'],
'ACTUATOR_SATURATION_UPPER': cls.__constants['ACTUATOR_SATURATION_UPPER'],
'ACTUATOR_SATURATION_LOWER_DYN': cls.__constants['ACTUATOR_SATURATION_LOWER_DYN'],
'ACTUATOR_SATURATION_LOWER': cls.__constants['ACTUATOR_SATURATION_LOWER'],
}
@property
def ACTUATOR_SATURATION_OK(self):
"""Message constant 'ACTUATOR_SATURATION_OK'."""
return Metaclass_ControlAllocatorStatus.__constants['ACTUATOR_SATURATION_OK']
@property
def ACTUATOR_SATURATION_UPPER_DYN(self):
"""Message constant 'ACTUATOR_SATURATION_UPPER_DYN'."""
return Metaclass_ControlAllocatorStatus.__constants['ACTUATOR_SATURATION_UPPER_DYN']
@property
def ACTUATOR_SATURATION_UPPER(self):
"""Message constant 'ACTUATOR_SATURATION_UPPER'."""
return Metaclass_ControlAllocatorStatus.__constants['ACTUATOR_SATURATION_UPPER']
@property
def ACTUATOR_SATURATION_LOWER_DYN(self):
"""Message constant 'ACTUATOR_SATURATION_LOWER_DYN'."""
return Metaclass_ControlAllocatorStatus.__constants['ACTUATOR_SATURATION_LOWER_DYN']
@property
def ACTUATOR_SATURATION_LOWER(self):
"""Message constant 'ACTUATOR_SATURATION_LOWER'."""
return Metaclass_ControlAllocatorStatus.__constants['ACTUATOR_SATURATION_LOWER']
class ControlAllocatorStatus(metaclass=Metaclass_ControlAllocatorStatus):
"""
Message class 'ControlAllocatorStatus'.
Constants:
ACTUATOR_SATURATION_OK
ACTUATOR_SATURATION_UPPER_DYN
ACTUATOR_SATURATION_UPPER
ACTUATOR_SATURATION_LOWER_DYN
ACTUATOR_SATURATION_LOWER
"""
__slots__ = [
'_timestamp',
'_torque_setpoint_achieved',
'_unallocated_torque',
'_thrust_setpoint_achieved',
'_unallocated_thrust',
'_actuator_saturation',
'_handled_motor_failure_mask',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'torque_setpoint_achieved': 'boolean',
'unallocated_torque': 'float[3]',
'thrust_setpoint_achieved': 'boolean',
'unallocated_thrust': 'float[3]',
'actuator_saturation': 'int8[16]',
'handled_motor_failure_mask': 'uint16',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 3), # noqa: E501
rosidl_parser.definition.BasicType('boolean'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 3), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('int8'), 16), # noqa: E501
rosidl_parser.definition.BasicType('uint16'), # 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.timestamp = kwargs.get('timestamp', int())
self.torque_setpoint_achieved = kwargs.get('torque_setpoint_achieved', bool())
if 'unallocated_torque' not in kwargs:
self.unallocated_torque = numpy.zeros(3, dtype=numpy.float32)
else:
self.unallocated_torque = numpy.array(kwargs.get('unallocated_torque'), dtype=numpy.float32)
assert self.unallocated_torque.shape == (3, )
self.thrust_setpoint_achieved = kwargs.get('thrust_setpoint_achieved', bool())
if 'unallocated_thrust' not in kwargs:
self.unallocated_thrust = numpy.zeros(3, dtype=numpy.float32)
else:
self.unallocated_thrust = numpy.array(kwargs.get('unallocated_thrust'), dtype=numpy.float32)
assert self.unallocated_thrust.shape == (3, )
if 'actuator_saturation' not in kwargs:
self.actuator_saturation = numpy.zeros(16, dtype=numpy.int8)
else:
self.actuator_saturation = numpy.array(kwargs.get('actuator_saturation'), dtype=numpy.int8)
assert self.actuator_saturation.shape == (16, )
self.handled_motor_failure_mask = kwargs.get('handled_motor_failure_mask', int())
def __repr__(self):
typename = self.__class__.__module__.split('.')
typename.pop()
typename.append(self.__class__.__name__)
args = []
for s, t in zip(self.__slots__, self.SLOT_TYPES):
field = getattr(self, s)
fieldstr = repr(field)
# We use Python array type for fields that can be directly stored
# in them, and "normal" sequences for everything else. If it is
# a type that we store in an array, strip off the 'array' portion.
if (
isinstance(t, rosidl_parser.definition.AbstractSequence) and
isinstance(t.value_type, rosidl_parser.definition.BasicType) and
t.value_type.typename in ['float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64']
):
if len(field) == 0:
fieldstr = '[]'
else:
assert fieldstr.startswith('array(')
prefix = "array('X', "
suffix = ')'
fieldstr = fieldstr[len(prefix):-len(suffix)]
args.append(s[1:] + '=' + fieldstr)
return '%s(%s)' % ('.'.join(typename), ', '.join(args))
def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
if self.timestamp != other.timestamp:
return False
if self.torque_setpoint_achieved != other.torque_setpoint_achieved:
return False
if all(self.unallocated_torque != other.unallocated_torque):
return False
if self.thrust_setpoint_achieved != other.thrust_setpoint_achieved:
return False
if all(self.unallocated_thrust != other.unallocated_thrust):
return False
if all(self.actuator_saturation != other.actuator_saturation):
return False
if self.handled_motor_failure_mask != other.handled_motor_failure_mask:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def torque_setpoint_achieved(self):
"""Message field 'torque_setpoint_achieved'."""
return self._torque_setpoint_achieved
@torque_setpoint_achieved.setter
def torque_setpoint_achieved(self, value):
if __debug__:
assert \
isinstance(value, bool), \
"The 'torque_setpoint_achieved' field must be of type 'bool'"
self._torque_setpoint_achieved = value
@property
def unallocated_torque(self):
"""Message field 'unallocated_torque'."""
return self._unallocated_torque
@unallocated_torque.setter
def unallocated_torque(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'unallocated_torque' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 3, \
"The 'unallocated_torque' numpy.ndarray() must have a size of 3"
self._unallocated_torque = 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
True), \
"The 'unallocated_torque' field must be a set or sequence with length 3 and each value of type 'float'"
self._unallocated_torque = numpy.array(value, dtype=numpy.float32)
@property
def thrust_setpoint_achieved(self):
"""Message field 'thrust_setpoint_achieved'."""
return self._thrust_setpoint_achieved
@thrust_setpoint_achieved.setter
def thrust_setpoint_achieved(self, value):
if __debug__:
assert \
isinstance(value, bool), \
"The 'thrust_setpoint_achieved' field must be of type 'bool'"
self._thrust_setpoint_achieved = value
@property
def unallocated_thrust(self):
"""Message field 'unallocated_thrust'."""
return self._unallocated_thrust
@unallocated_thrust.setter
def unallocated_thrust(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'unallocated_thrust' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 3, \
"The 'unallocated_thrust' numpy.ndarray() must have a size of 3"
self._unallocated_thrust = 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
True), \
"The 'unallocated_thrust' field must be a set or sequence with length 3 and each value of type 'float'"
self._unallocated_thrust = numpy.array(value, dtype=numpy.float32)
@property
def actuator_saturation(self):
"""Message field 'actuator_saturation'."""
return self._actuator_saturation
@actuator_saturation.setter
def actuator_saturation(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.int8, \
"The 'actuator_saturation' numpy.ndarray() must have the dtype of 'numpy.int8'"
assert value.size == 16, \
"The 'actuator_saturation' numpy.ndarray() must have a size of 16"
self._actuator_saturation = 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) == 16 and
all(isinstance(v, int) for v in value) and
all(val >= -128 and val < 128 for val in value)), \
"The 'actuator_saturation' field must be a set or sequence with length 16 and each value of type 'int' and each integer in [-128, 127]"
self._actuator_saturation = numpy.array(value, dtype=numpy.int8)
@property
def handled_motor_failure_mask(self):
"""Message field 'handled_motor_failure_mask'."""
return self._handled_motor_failure_mask
@handled_motor_failure_mask.setter
def handled_motor_failure_mask(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'handled_motor_failure_mask' field must be of type 'int'"
assert value >= 0 and value < 65536, \
"The 'handled_motor_failure_mask' field must be an unsigned integer in [0, 65535]"
self._handled_motor_failure_mask = value

View File

@@ -0,0 +1,287 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/ControlAllocatorStatus.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 "px4_msgs/msg/detail/control_allocator_status__struct.h"
#include "px4_msgs/msg/detail/control_allocator_status__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__control_allocator_status__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[62];
{
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("px4_msgs.msg._control_allocator_status.ControlAllocatorStatus", full_classname_dest, 61) == 0);
}
px4_msgs__msg__ControlAllocatorStatus * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // torque_setpoint_achieved
PyObject * field = PyObject_GetAttrString(_pymsg, "torque_setpoint_achieved");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->torque_setpoint_achieved = (Py_True == field);
Py_DECREF(field);
}
{ // unallocated_torque
PyObject * field = PyObject_GetAttrString(_pymsg, "unallocated_torque");
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_FLOAT32);
Py_ssize_t size = 3;
float * dest = ros_message->unallocated_torque;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
{ // thrust_setpoint_achieved
PyObject * field = PyObject_GetAttrString(_pymsg, "thrust_setpoint_achieved");
if (!field) {
return false;
}
assert(PyBool_Check(field));
ros_message->thrust_setpoint_achieved = (Py_True == field);
Py_DECREF(field);
}
{ // unallocated_thrust
PyObject * field = PyObject_GetAttrString(_pymsg, "unallocated_thrust");
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_FLOAT32);
Py_ssize_t size = 3;
float * dest = ros_message->unallocated_thrust;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
{ // actuator_saturation
PyObject * field = PyObject_GetAttrString(_pymsg, "actuator_saturation");
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_INT8);
Py_ssize_t size = 16;
int8_t * dest = ros_message->actuator_saturation;
for (Py_ssize_t i = 0; i < size; ++i) {
int8_t tmp = *(npy_int8 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(int8_t));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
{ // handled_motor_failure_mask
PyObject * field = PyObject_GetAttrString(_pymsg, "handled_motor_failure_mask");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->handled_motor_failure_mask = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__control_allocator_status__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of ControlAllocatorStatus */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._control_allocator_status");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "ControlAllocatorStatus");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__ControlAllocatorStatus * ros_message = (px4_msgs__msg__ControlAllocatorStatus *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // torque_setpoint_achieved
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->torque_setpoint_achieved ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "torque_setpoint_achieved", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // unallocated_torque
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "unallocated_torque");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->unallocated_torque[0]);
memcpy(dst, src, 3 * sizeof(float));
Py_DECREF(field);
}
{ // thrust_setpoint_achieved
PyObject * field = NULL;
field = PyBool_FromLong(ros_message->thrust_setpoint_achieved ? 1 : 0);
{
int rc = PyObject_SetAttrString(_pymessage, "thrust_setpoint_achieved", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // unallocated_thrust
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "unallocated_thrust");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->unallocated_thrust[0]);
memcpy(dst, src, 3 * sizeof(float));
Py_DECREF(field);
}
{ // actuator_saturation
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "actuator_saturation");
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_INT8);
assert(sizeof(npy_int8) == sizeof(int8_t));
npy_int8 * dst = (npy_int8 *)PyArray_GETPTR1(seq_field, 0);
int8_t * src = &(ros_message->actuator_saturation[0]);
memcpy(dst, src, 16 * sizeof(int8_t));
Py_DECREF(field);
}
{ // handled_motor_failure_mask
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->handled_motor_failure_mask);
{
int rc = PyObject_SetAttrString(_pymessage, "handled_motor_failure_mask", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_cpuload.py

View File

@@ -0,0 +1,162 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/Cpuload.idl
# generated code does not contain a copyright notice
# Import statements for member types
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_Cpuload(type):
"""Metaclass of message 'Cpuload'."""
_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('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.Cpuload')
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__cpuload
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__cpuload
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__cpuload
cls._TYPE_SUPPORT = module.type_support_msg__msg__cpuload
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__cpuload
@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 Cpuload(metaclass=Metaclass_Cpuload):
"""Message class 'Cpuload'."""
__slots__ = [
'_timestamp',
'_load',
'_ram_usage',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'load': 'float',
'ram_usage': 'float',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
rosidl_parser.definition.BasicType('float'), # noqa: E501
)
def __init__(self, **kwargs):
assert all('_' + key in self.__slots__ for key in kwargs.keys()), \
'Invalid arguments passed to constructor: %s' % \
', '.join(sorted(k for k in kwargs.keys() if '_' + k not in self.__slots__))
self.timestamp = kwargs.get('timestamp', int())
self.load = kwargs.get('load', float())
self.ram_usage = kwargs.get('ram_usage', 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.timestamp != other.timestamp:
return False
if self.load != other.load:
return False
if self.ram_usage != other.ram_usage:
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property
def load(self):
"""Message field 'load'."""
return self._load
@load.setter
def load(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'load' field must be of type 'float'"
self._load = value
@property
def ram_usage(self):
"""Message field 'ram_usage'."""
return self._ram_usage
@ram_usage.setter
def ram_usage(self, value):
if __debug__:
assert \
isinstance(value, float), \
"The 'ram_usage' field must be of type 'float'"
self._ram_usage = value

View File

@@ -0,0 +1,138 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/Cpuload.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 "px4_msgs/msg/detail/cpuload__struct.h"
#include "px4_msgs/msg/detail/cpuload__functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__cpuload__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[30];
{
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("px4_msgs.msg._cpuload.Cpuload", full_classname_dest, 29) == 0);
}
px4_msgs__msg__Cpuload * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // load
PyObject * field = PyObject_GetAttrString(_pymsg, "load");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->load = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
{ // ram_usage
PyObject * field = PyObject_GetAttrString(_pymsg, "ram_usage");
if (!field) {
return false;
}
assert(PyFloat_Check(field));
ros_message->ram_usage = (float)PyFloat_AS_DOUBLE(field);
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__cpuload__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of Cpuload */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._cpuload");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "Cpuload");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__Cpuload * ros_message = (px4_msgs__msg__Cpuload *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // load
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->load);
{
int rc = PyObject_SetAttrString(_pymessage, "load", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // ram_usage
PyObject * field = NULL;
field = PyFloat_FromDouble(ros_message->ram_usage);
{
int rc = PyObject_SetAttrString(_pymessage, "ram_usage", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_debug_array.py

View File

@@ -0,0 +1,243 @@
# generated from rosidl_generator_py/resource/_idl.py.em
# with input from px4_msgs:msg/DebugArray.idl
# generated code does not contain a copyright notice
# Import statements for member types
# Member 'name'
# Member 'data'
import numpy # noqa: E402, I100
import rosidl_parser.definition # noqa: E402, I100
class Metaclass_DebugArray(type):
"""Metaclass of message 'DebugArray'."""
_CREATE_ROS_MESSAGE = None
_CONVERT_FROM_PY = None
_CONVERT_TO_PY = None
_DESTROY_ROS_MESSAGE = None
_TYPE_SUPPORT = None
__constants = {
'ARRAY_SIZE': 58,
}
@classmethod
def __import_type_support__(cls):
try:
from rosidl_generator_py import import_type_support
module = import_type_support('px4_msgs')
except ImportError:
import logging
import traceback
logger = logging.getLogger(
'px4_msgs.msg.DebugArray')
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__debug_array
cls._CONVERT_FROM_PY = module.convert_from_py_msg__msg__debug_array
cls._CONVERT_TO_PY = module.convert_to_py_msg__msg__debug_array
cls._TYPE_SUPPORT = module.type_support_msg__msg__debug_array
cls._DESTROY_ROS_MESSAGE = module.destroy_ros_message_msg__msg__debug_array
@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 {
'ARRAY_SIZE': cls.__constants['ARRAY_SIZE'],
}
@property
def ARRAY_SIZE(self):
"""Message constant 'ARRAY_SIZE'."""
return Metaclass_DebugArray.__constants['ARRAY_SIZE']
class DebugArray(metaclass=Metaclass_DebugArray):
"""
Message class 'DebugArray'.
Constants:
ARRAY_SIZE
"""
__slots__ = [
'_timestamp',
'_id',
'_name',
'_data',
]
_fields_and_field_types = {
'timestamp': 'uint64',
'id': 'uint16',
'name': 'uint8[10]',
'data': 'float[58]',
}
SLOT_TYPES = (
rosidl_parser.definition.BasicType('uint64'), # noqa: E501
rosidl_parser.definition.BasicType('uint16'), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('uint8'), 10), # noqa: E501
rosidl_parser.definition.Array(rosidl_parser.definition.BasicType('float'), 58), # 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.timestamp = kwargs.get('timestamp', int())
self.id = kwargs.get('id', int())
if 'name' not in kwargs:
self.name = numpy.zeros(10, dtype=numpy.uint8)
else:
self.name = numpy.array(kwargs.get('name'), dtype=numpy.uint8)
assert self.name.shape == (10, )
if 'data' not in kwargs:
self.data = numpy.zeros(58, dtype=numpy.float32)
else:
self.data = numpy.array(kwargs.get('data'), dtype=numpy.float32)
assert self.data.shape == (58, )
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.timestamp != other.timestamp:
return False
if self.id != other.id:
return False
if all(self.name != other.name):
return False
if all(self.data != other.data):
return False
return True
@classmethod
def get_fields_and_field_types(cls):
from copy import copy
return copy(cls._fields_and_field_types)
@property
def timestamp(self):
"""Message field 'timestamp'."""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
if __debug__:
assert \
isinstance(value, int), \
"The 'timestamp' field must be of type 'int'"
assert value >= 0 and value < 18446744073709551616, \
"The 'timestamp' field must be an unsigned integer in [0, 18446744073709551615]"
self._timestamp = value
@property # noqa: A003
def id(self): # noqa: A003
"""Message field 'id'."""
return self._id
@id.setter # noqa: A003
def id(self, value): # noqa: A003
if __debug__:
assert \
isinstance(value, int), \
"The 'id' field must be of type 'int'"
assert value >= 0 and value < 65536, \
"The 'id' field must be an unsigned integer in [0, 65535]"
self._id = value
@property
def name(self):
"""Message field 'name'."""
return self._name
@name.setter
def name(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.uint8, \
"The 'name' numpy.ndarray() must have the dtype of 'numpy.uint8'"
assert value.size == 10, \
"The 'name' numpy.ndarray() must have a size of 10"
self._name = 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) == 10 and
all(isinstance(v, int) for v in value) and
all(val >= 0 and val < 256 for val in value)), \
"The 'name' field must be a set or sequence with length 10 and each value of type 'int' and each unsigned integer in [0, 255]"
self._name = numpy.array(value, dtype=numpy.uint8)
@property
def data(self):
"""Message field 'data'."""
return self._data
@data.setter
def data(self, value):
if isinstance(value, numpy.ndarray):
assert value.dtype == numpy.float32, \
"The 'data' numpy.ndarray() must have the dtype of 'numpy.float32'"
assert value.size == 58, \
"The 'data' numpy.ndarray() must have a size of 58"
self._data = 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) == 58 and
all(isinstance(v, float) for v in value) and
True), \
"The 'data' field must be a set or sequence with length 58 and each value of type 'float'"
self._data = numpy.array(value, dtype=numpy.float32)

View File

@@ -0,0 +1,205 @@
// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from px4_msgs:msg/DebugArray.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 "px4_msgs/msg/detail/debug_array__struct.h"
#include "px4_msgs/msg/detail/debug_array__functions.h"
#include "rosidl_runtime_c/primitives_sequence.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
ROSIDL_GENERATOR_C_EXPORT
bool px4_msgs__msg__debug_array__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
// check that the passed message is of the expected Python class
{
char full_classname_dest[37];
{
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("px4_msgs.msg._debug_array.DebugArray", full_classname_dest, 36) == 0);
}
px4_msgs__msg__DebugArray * ros_message = _ros_message;
{ // timestamp
PyObject * field = PyObject_GetAttrString(_pymsg, "timestamp");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->timestamp = PyLong_AsUnsignedLongLong(field);
Py_DECREF(field);
}
{ // id
PyObject * field = PyObject_GetAttrString(_pymsg, "id");
if (!field) {
return false;
}
assert(PyLong_Check(field));
ros_message->id = (uint16_t)PyLong_AsUnsignedLong(field);
Py_DECREF(field);
}
{ // name
PyObject * field = PyObject_GetAttrString(_pymsg, "name");
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_UINT8);
Py_ssize_t size = 10;
uint8_t * dest = ros_message->name;
for (Py_ssize_t i = 0; i < size; ++i) {
uint8_t tmp = *(npy_uint8 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(uint8_t));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
{ // data
PyObject * field = PyObject_GetAttrString(_pymsg, "data");
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_FLOAT32);
Py_ssize_t size = 58;
float * dest = ros_message->data;
for (Py_ssize_t i = 0; i < size; ++i) {
float tmp = *(npy_float32 *)PyArray_GETPTR1(seq_field, i);
memcpy(&dest[i], &tmp, sizeof(float));
}
Py_DECREF(seq_field);
}
Py_DECREF(field);
}
return true;
}
ROSIDL_GENERATOR_C_EXPORT
PyObject * px4_msgs__msg__debug_array__convert_to_py(void * raw_ros_message)
{
/* NOTE(esteve): Call constructor of DebugArray */
PyObject * _pymessage = NULL;
{
PyObject * pymessage_module = PyImport_ImportModule("px4_msgs.msg._debug_array");
assert(pymessage_module);
PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "DebugArray");
assert(pymessage_class);
Py_DECREF(pymessage_module);
_pymessage = PyObject_CallObject(pymessage_class, NULL);
Py_DECREF(pymessage_class);
if (!_pymessage) {
return NULL;
}
}
px4_msgs__msg__DebugArray * ros_message = (px4_msgs__msg__DebugArray *)raw_ros_message;
{ // timestamp
PyObject * field = NULL;
field = PyLong_FromUnsignedLongLong(ros_message->timestamp);
{
int rc = PyObject_SetAttrString(_pymessage, "timestamp", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // id
PyObject * field = NULL;
field = PyLong_FromUnsignedLong(ros_message->id);
{
int rc = PyObject_SetAttrString(_pymessage, "id", field);
Py_DECREF(field);
if (rc) {
return NULL;
}
}
}
{ // name
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "name");
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_UINT8);
assert(sizeof(npy_uint8) == sizeof(uint8_t));
npy_uint8 * dst = (npy_uint8 *)PyArray_GETPTR1(seq_field, 0);
uint8_t * src = &(ros_message->name[0]);
memcpy(dst, src, 10 * sizeof(uint8_t));
Py_DECREF(field);
}
{ // data
PyObject * field = NULL;
field = PyObject_GetAttrString(_pymessage, "data");
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_FLOAT32);
assert(sizeof(npy_float32) == sizeof(float));
npy_float32 * dst = (npy_float32 *)PyArray_GETPTR1(seq_field, 0);
float * src = &(ros_message->data[0]);
memcpy(dst, src, 58 * sizeof(float));
Py_DECREF(field);
}
// ownership of _pymessage is transferred to the caller
return _pymessage;
}

View File

@@ -1 +0,0 @@
/home/ubuntu/ros2_ws/build/px4_msgs/rosidl_generator_py/px4_msgs/msg/_debug_key_value.py

Some files were not shown because too many files have changed in this diff Show More