robot-msg-irsl 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- robot_msg/__init__.py +39 -0
- robot_msg/__main__.py +14 -0
- robot_msg/_assets/VERSION +1 -0
- robot_msg/_assets/internal/cpp/CMakeLists.txt +38 -0
- robot_msg/_assets/internal/cpp/cmake/RobotMsgBootstrap.cmake +102 -0
- robot_msg/_assets/internal/cpp/cmake/robot_msgConfig.cmake.in +4 -0
- robot_msg/_assets/internal/cpp/cmake/source/robot_msgConfig.cmake +19 -0
- robot_msg/_assets/internal/cpp/cmake/source/robot_msgConfigVersion.cmake +7 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/detail/compat.hpp +221 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/detail/runtime.hpp +341 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/detail/type_codecs.hpp +70 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/detail/wire.hpp +455 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/all.hpp +30 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/common/message_batch.hpp +28 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/meta/controller_input.hpp +41 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/meta/tracking_pose.hpp +31 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/protocol.hpp +13 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/registry.hpp +14 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/arrow2_input.hpp +35 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/arrow_input.hpp +35 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/batch_arrow2_input.hpp +39 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/batch_arrow_input.hpp +39 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/batch_box_input.hpp +34 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/batch_ellipsoid_input.hpp +34 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/batch_frame_input.hpp +35 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/batch_line_input.hpp +39 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/batch_mesh_color_input.hpp +37 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/batch_robot_joint_input.hpp +35 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/batch_sphere_input.hpp +34 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/box_input.hpp +34 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/clear.hpp +27 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/ellipsoid_input.hpp +34 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/frame_input.hpp +35 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/line_input.hpp +35 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/mesh_color_input.hpp +33 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/robot_joint_input.hpp +31 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/robot_viewer/sphere_input.hpp +34 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/smpl/smpl_state.hpp +38 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/switch_controller/contact_info.hpp +34 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/switch_controller/controller_command.hpp +31 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/switch_controller/robot_action.hpp +43 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/messages/switch_controller/robot_state.hpp +35 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/ports.hpp +18 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/robot_msg.hpp +64 -0
- robot_msg/_assets/internal/cpp/include/robot_msg/types.hpp +83 -0
- robot_msg/_assets/internal/cpp/src/generated/messages.cpp +4174 -0
- robot_msg/_assets/internal/cpp/src/generated/registry.cpp +314 -0
- robot_msg/_assets/internal/cpp/src/runtime.cpp +996 -0
- robot_msg/_assets/internal/generator/wire_contract.json +114 -0
- robot_msg/_assets/schemas/envelope.json +15 -0
- robot_msg/_assets/schemas/examples/exmple.json +66 -0
- robot_msg/_assets/schemas/messages/common/message_batch.json +25 -0
- robot_msg/_assets/schemas/messages/meta/controller_input.json +25 -0
- robot_msg/_assets/schemas/messages/meta/tracking_pose.json +15 -0
- robot_msg/_assets/schemas/messages/robot_viewer/arrow2_input.json +19 -0
- robot_msg/_assets/schemas/messages/robot_viewer/arrow_input.json +19 -0
- robot_msg/_assets/schemas/messages/robot_viewer/batch_arrow2_input.json +25 -0
- robot_msg/_assets/schemas/messages/robot_viewer/batch_arrow_input.json +25 -0
- robot_msg/_assets/schemas/messages/robot_viewer/batch_box_input.json +19 -0
- robot_msg/_assets/schemas/messages/robot_viewer/batch_ellipsoid_input.json +19 -0
- robot_msg/_assets/schemas/messages/robot_viewer/batch_frame_input.json +19 -0
- robot_msg/_assets/schemas/messages/robot_viewer/batch_line_input.json +25 -0
- robot_msg/_assets/schemas/messages/robot_viewer/batch_mesh_color_input.json +26 -0
- robot_msg/_assets/schemas/messages/robot_viewer/batch_robot_joint_input.json +22 -0
- robot_msg/_assets/schemas/messages/robot_viewer/batch_sphere_input.json +18 -0
- robot_msg/_assets/schemas/messages/robot_viewer/box_input.json +19 -0
- robot_msg/_assets/schemas/messages/robot_viewer/clear.json +10 -0
- robot_msg/_assets/schemas/messages/robot_viewer/ellipsoid_input.json +19 -0
- robot_msg/_assets/schemas/messages/robot_viewer/frame_input.json +19 -0
- robot_msg/_assets/schemas/messages/robot_viewer/line_input.json +19 -0
- robot_msg/_assets/schemas/messages/robot_viewer/mesh_color_input.json +17 -0
- robot_msg/_assets/schemas/messages/robot_viewer/robot_joint_input.json +15 -0
- robot_msg/_assets/schemas/messages/robot_viewer/sphere_input.json +18 -0
- robot_msg/_assets/schemas/messages/smpl/smpl_state.json +23 -0
- robot_msg/_assets/schemas/messages/switch_controller/contact_info.json +25 -0
- robot_msg/_assets/schemas/messages/switch_controller/controller_command.json +15 -0
- robot_msg/_assets/schemas/messages/switch_controller/robot_action.json +33 -0
- robot_msg/_assets/schemas/messages/switch_controller/robot_state.json +20 -0
- robot_msg/_assets/schemas/ports.json +9 -0
- robot_msg/_assets/schemas/types/color_rgba.json +15 -0
- robot_msg/_assets/schemas/types/frame_pose.json +13 -0
- robot_msg/_assets/schemas/types/lifetime.json +14 -0
- robot_msg/_assets/schemas/types/message_metadata.json +16 -0
- robot_msg/_assets/schemas/types/named_array.json +17 -0
- robot_msg/_assets/schemas/types/pose.json +13 -0
- robot_msg/_assets/schemas/types/quaternion.json +11 -0
- robot_msg/_assets/schemas/types/rotation_vector.json +10 -0
- robot_msg/_assets/schemas/types/timestamp.json +15 -0
- robot_msg/_assets/schemas/types/vec2.json +10 -0
- robot_msg/_assets/schemas/types/vec3.json +10 -0
- robot_msg/_assets/schemas/types/wrench.json +10 -0
- robot_msg/_binary.py +496 -0
- robot_msg/_catalog.py +48 -0
- robot_msg/_paths.py +20 -0
- robot_msg/_protocol.py +3 -0
- robot_msg/_runtime.py +323 -0
- robot_msg/_schemas/catalog.json +6103 -0
- robot_msg/_type_codecs.py +794 -0
- robot_msg/messages/__init__.py +66 -0
- robot_msg/messages/_registry.py +150 -0
- robot_msg/messages/common/__init__.py +6 -0
- robot_msg/messages/common/message_batch.py +65 -0
- robot_msg/messages/meta/__init__.py +8 -0
- robot_msg/messages/meta/controller_input.py +219 -0
- robot_msg/messages/meta/tracking_pose.py +89 -0
- robot_msg/messages/robot_viewer/__init__.py +47 -0
- robot_msg/messages/robot_viewer/arrow2_input.py +166 -0
- robot_msg/messages/robot_viewer/arrow_input.py +166 -0
- robot_msg/messages/robot_viewer/batch_arrow2_input.py +211 -0
- robot_msg/messages/robot_viewer/batch_arrow_input.py +211 -0
- robot_msg/messages/robot_viewer/batch_box_input.py +160 -0
- robot_msg/messages/robot_viewer/batch_ellipsoid_input.py +160 -0
- robot_msg/messages/robot_viewer/batch_frame_input.py +187 -0
- robot_msg/messages/robot_viewer/batch_line_input.py +211 -0
- robot_msg/messages/robot_viewer/batch_mesh_color_input.py +191 -0
- robot_msg/messages/robot_viewer/batch_robot_joint_input.py +161 -0
- robot_msg/messages/robot_viewer/batch_sphere_input.py +162 -0
- robot_msg/messages/robot_viewer/box_input.py +154 -0
- robot_msg/messages/robot_viewer/clear.py +53 -0
- robot_msg/messages/robot_viewer/ellipsoid_input.py +154 -0
- robot_msg/messages/robot_viewer/frame_input.py +181 -0
- robot_msg/messages/robot_viewer/line_input.py +166 -0
- robot_msg/messages/robot_viewer/mesh_color_input.py +138 -0
- robot_msg/messages/robot_viewer/robot_joint_input.py +116 -0
- robot_msg/messages/robot_viewer/sphere_input.py +156 -0
- robot_msg/messages/smpl/__init__.py +6 -0
- robot_msg/messages/smpl/smpl_state.py +218 -0
- robot_msg/messages/switch_controller/__init__.py +15 -0
- robot_msg/messages/switch_controller/contact_info.py +130 -0
- robot_msg/messages/switch_controller/controller_command.py +125 -0
- robot_msg/messages/switch_controller/robot_action.py +306 -0
- robot_msg/messages/switch_controller/robot_state.py +135 -0
- robot_msg/ports.py +12 -0
- robot_msg/py.typed +0 -0
- robot_msg/types.py +199 -0
- robot_msg_irsl-0.3.0.dist-info/METADATA +317 -0
- robot_msg_irsl-0.3.0.dist-info/RECORD +140 -0
- robot_msg_irsl-0.3.0.dist-info/WHEEL +5 -0
- robot_msg_irsl-0.3.0.dist-info/licenses/LICENSE +21 -0
- robot_msg_irsl-0.3.0.dist-info/top_level.txt +1 -0
robot_msg/__init__.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Typed, transport-independent robot messages with binary-first encoding."""
|
|
2
|
+
|
|
3
|
+
from ._runtime import (
|
|
4
|
+
ParseError,
|
|
5
|
+
RobotMsgError,
|
|
6
|
+
UnknownMessageError,
|
|
7
|
+
UnsupportedVersionError,
|
|
8
|
+
ValidationError,
|
|
9
|
+
decode_json,
|
|
10
|
+
encode_json,
|
|
11
|
+
validate,
|
|
12
|
+
)
|
|
13
|
+
from ._binary import decode, encode
|
|
14
|
+
from ._catalog import MessageInfo, get_envelope_schema, get_payload_schema, message_catalog
|
|
15
|
+
from .messages import *
|
|
16
|
+
from .messages import __all__ as _messages_all
|
|
17
|
+
from .types import *
|
|
18
|
+
from .types import __all__ as _types_all
|
|
19
|
+
from . import ports
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"RobotMsgError",
|
|
23
|
+
"ParseError",
|
|
24
|
+
"ValidationError",
|
|
25
|
+
"UnknownMessageError",
|
|
26
|
+
"UnsupportedVersionError",
|
|
27
|
+
"encode",
|
|
28
|
+
"decode",
|
|
29
|
+
"encode_json",
|
|
30
|
+
"decode_json",
|
|
31
|
+
"validate",
|
|
32
|
+
"MessageInfo",
|
|
33
|
+
"message_catalog",
|
|
34
|
+
"get_payload_schema",
|
|
35
|
+
"get_envelope_schema",
|
|
36
|
+
"ports",
|
|
37
|
+
*_messages_all,
|
|
38
|
+
*_types_all,
|
|
39
|
+
]
|
robot_msg/__main__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
from robot_msg._paths import cmake_dir
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def main() -> None:
|
|
7
|
+
parser = argparse.ArgumentParser(description="Locate installed robot_msg build resources")
|
|
8
|
+
parser.add_argument("--cmake-dir", action="store_true", required=True, help="print the source-package CMake config directory")
|
|
9
|
+
parser.parse_args()
|
|
10
|
+
print(cmake_dir())
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
if __name__ == "__main__":
|
|
14
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.3.0
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
add_library(robot_msg STATIC
|
|
2
|
+
src/runtime.cpp
|
|
3
|
+
src/generated/messages.cpp
|
|
4
|
+
src/generated/registry.cpp
|
|
5
|
+
)
|
|
6
|
+
add_library(robot_msg::robot_msg ALIAS robot_msg)
|
|
7
|
+
|
|
8
|
+
set_target_properties(robot_msg PROPERTIES
|
|
9
|
+
CXX_EXTENSIONS OFF
|
|
10
|
+
CXX_STANDARD 14
|
|
11
|
+
CXX_STANDARD_REQUIRED ON
|
|
12
|
+
EXPORT_NAME robot_msg
|
|
13
|
+
POSITION_INDEPENDENT_CODE ON
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
target_compile_features(robot_msg PUBLIC cxx_std_14)
|
|
17
|
+
target_include_directories(robot_msg
|
|
18
|
+
PUBLIC
|
|
19
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
|
20
|
+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
if(MSVC)
|
|
24
|
+
target_compile_options(robot_msg PRIVATE /W4 /permissive-)
|
|
25
|
+
else()
|
|
26
|
+
target_compile_options(robot_msg PRIVATE -Wall -Wextra -Wpedantic)
|
|
27
|
+
endif()
|
|
28
|
+
|
|
29
|
+
if(NOT ROBOT_MSG_SOURCE_PACKAGE)
|
|
30
|
+
install(
|
|
31
|
+
TARGETS robot_msg
|
|
32
|
+
EXPORT robot_msgTargets
|
|
33
|
+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
34
|
+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
35
|
+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
36
|
+
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
37
|
+
)
|
|
38
|
+
endif()
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
function(robot_msg_bootstrap)
|
|
2
|
+
cmake_parse_arguments(RM "OFFLINE" "VERSION;PYTHON;WHEEL;UV" "" ${ARGN})
|
|
3
|
+
if(RM_UNPARSED_ARGUMENTS)
|
|
4
|
+
message(FATAL_ERROR "Unknown robot_msg_bootstrap arguments: ${RM_UNPARSED_ARGUMENTS}")
|
|
5
|
+
endif()
|
|
6
|
+
if(NOT RM_PYTHON)
|
|
7
|
+
message(FATAL_ERROR "robot_msg_bootstrap requires PYTHON pointing to an installed Python >=3.11")
|
|
8
|
+
endif()
|
|
9
|
+
if(NOT RM_VERSION AND NOT RM_WHEEL)
|
|
10
|
+
message(FATAL_ERROR "robot_msg_bootstrap requires an exact VERSION or a local WHEEL")
|
|
11
|
+
endif()
|
|
12
|
+
if(RM_VERSION AND NOT RM_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+([a-zA-Z][a-zA-Z0-9.]*)?$")
|
|
13
|
+
message(FATAL_ERROR "robot_msg_bootstrap VERSION must be an exact release, not a requirement range")
|
|
14
|
+
endif()
|
|
15
|
+
if(NOT RM_UV)
|
|
16
|
+
find_program(RM_UV NAMES uv)
|
|
17
|
+
endif()
|
|
18
|
+
if(NOT RM_UV)
|
|
19
|
+
message(FATAL_ERROR "robot_msg_bootstrap requires uv; install it or pass UV explicitly")
|
|
20
|
+
endif()
|
|
21
|
+
execute_process(
|
|
22
|
+
COMMAND "${RM_PYTHON}" -I -c "import sys; assert sys.version_info >= (3, 11), 'Python >=3.11 required'; print(sys.executable); print(sys.version)"
|
|
23
|
+
RESULT_VARIABLE _python_result OUTPUT_VARIABLE _python_identity ERROR_VARIABLE _python_error
|
|
24
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
25
|
+
)
|
|
26
|
+
if(NOT _python_result EQUAL 0)
|
|
27
|
+
message(FATAL_ERROR "robot_msg host Python is unavailable or too old: ${_python_error}")
|
|
28
|
+
endif()
|
|
29
|
+
if(RM_WHEEL)
|
|
30
|
+
get_filename_component(_wheel "${RM_WHEEL}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
31
|
+
if(NOT EXISTS "${_wheel}")
|
|
32
|
+
message(FATAL_ERROR "robot_msg wheel does not exist: ${_wheel}")
|
|
33
|
+
endif()
|
|
34
|
+
file(SHA256 "${_wheel}" _wheel_hash)
|
|
35
|
+
set(_requirement "${_wheel}")
|
|
36
|
+
else()
|
|
37
|
+
set(_requirement "robot-msg-irsl==${RM_VERSION}")
|
|
38
|
+
set(_wheel_hash "")
|
|
39
|
+
endif()
|
|
40
|
+
|
|
41
|
+
set(_root "${CMAKE_BINARY_DIR}/_robot_msg")
|
|
42
|
+
file(MAKE_DIRECTORY "${_root}")
|
|
43
|
+
file(LOCK "${_root}/bootstrap.lock" GUARD FUNCTION TIMEOUT 120)
|
|
44
|
+
string(SHA256 _identity "${_python_identity}\n${RM_UV}\n${RM_VERSION}\n${_requirement}\n${_wheel_hash}")
|
|
45
|
+
set(_environment "${_root}/venv-${_identity}")
|
|
46
|
+
if(WIN32)
|
|
47
|
+
set(_python "${_environment}/Scripts/python.exe")
|
|
48
|
+
else()
|
|
49
|
+
set(_python "${_environment}/bin/python")
|
|
50
|
+
endif()
|
|
51
|
+
set(_stamp "${_environment}/.robot-msg-irsl-installed")
|
|
52
|
+
set(_uv "${RM_UV}" --no-config --no-python-downloads --cache-dir "${_root}/uv-cache")
|
|
53
|
+
if(RM_OFFLINE)
|
|
54
|
+
list(APPEND _uv --offline)
|
|
55
|
+
endif()
|
|
56
|
+
if(NOT EXISTS "${_stamp}" OR NOT EXISTS "${_python}")
|
|
57
|
+
execute_process(
|
|
58
|
+
COMMAND ${_uv} venv --no-project --allow-existing --python "${RM_PYTHON}" "${_environment}"
|
|
59
|
+
RESULT_VARIABLE _venv_result OUTPUT_VARIABLE _venv_output ERROR_VARIABLE _venv_error
|
|
60
|
+
)
|
|
61
|
+
if(NOT _venv_result EQUAL 0)
|
|
62
|
+
message(FATAL_ERROR "robot_msg environment creation failed:\n${_venv_output}\n${_venv_error}")
|
|
63
|
+
endif()
|
|
64
|
+
set(_install_args --python "${_python}" --no-deps --only-binary :all: --reinstall-package robot-msg-irsl)
|
|
65
|
+
if(RM_WHEEL)
|
|
66
|
+
list(APPEND _install_args --no-index)
|
|
67
|
+
endif()
|
|
68
|
+
execute_process(
|
|
69
|
+
COMMAND ${_uv} pip install ${_install_args} "${_requirement}"
|
|
70
|
+
RESULT_VARIABLE _install_result OUTPUT_VARIABLE _install_output ERROR_VARIABLE _install_error
|
|
71
|
+
)
|
|
72
|
+
if(NOT _install_result EQUAL 0)
|
|
73
|
+
message(FATAL_ERROR "robot_msg installation failed:\n${_install_output}\n${_install_error}")
|
|
74
|
+
endif()
|
|
75
|
+
endif()
|
|
76
|
+
|
|
77
|
+
execute_process(
|
|
78
|
+
COMMAND "${_python}" -I -c "from importlib.metadata import version; print(version('robot-msg-irsl'))"
|
|
79
|
+
RESULT_VARIABLE _version_result OUTPUT_VARIABLE _installed_version ERROR_VARIABLE _version_error
|
|
80
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
81
|
+
)
|
|
82
|
+
if(NOT _version_result EQUAL 0)
|
|
83
|
+
message(FATAL_ERROR "robot_msg installation verification failed: ${_version_error}")
|
|
84
|
+
endif()
|
|
85
|
+
if(RM_VERSION AND NOT _installed_version STREQUAL RM_VERSION)
|
|
86
|
+
message(FATAL_ERROR "robot_msg wheel version ${_installed_version} does not match requested ${RM_VERSION}")
|
|
87
|
+
endif()
|
|
88
|
+
execute_process(
|
|
89
|
+
COMMAND "${_python}" -I -m robot_msg --cmake-dir
|
|
90
|
+
RESULT_VARIABLE _config_result OUTPUT_VARIABLE robot_msg_DIR ERROR_VARIABLE _config_error
|
|
91
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
92
|
+
)
|
|
93
|
+
if(NOT _config_result EQUAL 0 OR NOT EXISTS "${robot_msg_DIR}/robot_msgConfig.cmake")
|
|
94
|
+
message(FATAL_ERROR "robot_msg CMake discovery failed: ${_config_error}")
|
|
95
|
+
endif()
|
|
96
|
+
if(NOT EXISTS "${_stamp}")
|
|
97
|
+
file(WRITE "${_stamp}" "${_identity}\n")
|
|
98
|
+
endif()
|
|
99
|
+
find_package(robot_msg CONFIG REQUIRED PATHS "${robot_msg_DIR}" NO_DEFAULT_PATH)
|
|
100
|
+
set(robot_msg_DIR "${robot_msg_DIR}" PARENT_SCOPE)
|
|
101
|
+
set(robot_msg_VERSION "${_installed_version}" PARENT_SCOPE)
|
|
102
|
+
endfunction()
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
get_filename_component(_robot_msg_cpp_root "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)
|
|
2
|
+
file(STRINGS "${_robot_msg_cpp_root}/../../VERSION" robot_msg_VERSION LIMIT_COUNT 1)
|
|
3
|
+
|
|
4
|
+
if(robot_msg_FIND_COMPONENTS)
|
|
5
|
+
set(robot_msg_FOUND FALSE)
|
|
6
|
+
set(robot_msg_NOT_FOUND_MESSAGE "robot_msg does not define optional components")
|
|
7
|
+
return()
|
|
8
|
+
endif()
|
|
9
|
+
|
|
10
|
+
if(NOT TARGET robot_msg::robot_msg)
|
|
11
|
+
function(_robot_msg_add_source_library source)
|
|
12
|
+
set(ROBOT_MSG_SOURCE_PACKAGE ON)
|
|
13
|
+
add_subdirectory("${source}" "${CMAKE_BINARY_DIR}/_robot_msg/${robot_msg_VERSION}" EXCLUDE_FROM_ALL)
|
|
14
|
+
endfunction()
|
|
15
|
+
_robot_msg_add_source_library("${_robot_msg_cpp_root}")
|
|
16
|
+
endif()
|
|
17
|
+
|
|
18
|
+
set(robot_msg_FOUND TRUE)
|
|
19
|
+
unset(_robot_msg_cpp_root)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/../../../../VERSION" PACKAGE_VERSION LIMIT_COUNT 1)
|
|
2
|
+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
|
3
|
+
set(PACKAGE_VERSION_EXACT FALSE)
|
|
4
|
+
if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
|
|
5
|
+
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
|
6
|
+
set(PACKAGE_VERSION_EXACT TRUE)
|
|
7
|
+
endif()
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <cstddef>
|
|
4
|
+
#include <cstring>
|
|
5
|
+
#include <new>
|
|
6
|
+
#include <stdexcept>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <type_traits>
|
|
9
|
+
#include <utility>
|
|
10
|
+
|
|
11
|
+
namespace robot_msg {
|
|
12
|
+
|
|
13
|
+
struct nullopt_t {
|
|
14
|
+
explicit constexpr nullopt_t(int) {}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
constexpr nullopt_t nullopt{0};
|
|
18
|
+
|
|
19
|
+
template <typename T>
|
|
20
|
+
class optional {
|
|
21
|
+
public:
|
|
22
|
+
optional() noexcept : engaged_(false) {}
|
|
23
|
+
optional(nullopt_t) noexcept : engaged_(false) {}
|
|
24
|
+
optional(const T& value) : engaged_(false) { construct(value); }
|
|
25
|
+
optional(T&& value) : engaged_(false) { construct(std::move(value)); }
|
|
26
|
+
|
|
27
|
+
optional(const optional& other) : engaged_(false) {
|
|
28
|
+
if (other.engaged_) {
|
|
29
|
+
construct(*other);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
optional(optional&& other) noexcept(std::is_nothrow_move_constructible<T>::value)
|
|
34
|
+
: engaged_(false) {
|
|
35
|
+
if (other.engaged_) {
|
|
36
|
+
construct(std::move(*other));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
~optional() { reset(); }
|
|
41
|
+
|
|
42
|
+
optional& operator=(nullopt_t) noexcept {
|
|
43
|
+
reset();
|
|
44
|
+
return *this;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
optional& operator=(const optional& other) {
|
|
48
|
+
if (engaged_ && other.engaged_) {
|
|
49
|
+
**this = *other;
|
|
50
|
+
} else if (other.engaged_) {
|
|
51
|
+
construct(*other);
|
|
52
|
+
} else {
|
|
53
|
+
reset();
|
|
54
|
+
}
|
|
55
|
+
return *this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
optional& operator=(optional&& other) noexcept(
|
|
59
|
+
std::is_nothrow_move_assignable<T>::value &&
|
|
60
|
+
std::is_nothrow_move_constructible<T>::value) {
|
|
61
|
+
if (engaged_ && other.engaged_) {
|
|
62
|
+
**this = std::move(*other);
|
|
63
|
+
} else if (other.engaged_) {
|
|
64
|
+
construct(std::move(*other));
|
|
65
|
+
} else {
|
|
66
|
+
reset();
|
|
67
|
+
}
|
|
68
|
+
return *this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
optional& operator=(const T& value) {
|
|
72
|
+
if (engaged_) {
|
|
73
|
+
**this = value;
|
|
74
|
+
} else {
|
|
75
|
+
construct(value);
|
|
76
|
+
}
|
|
77
|
+
return *this;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
optional& operator=(T&& value) {
|
|
81
|
+
if (engaged_) {
|
|
82
|
+
**this = std::move(value);
|
|
83
|
+
} else {
|
|
84
|
+
construct(std::move(value));
|
|
85
|
+
}
|
|
86
|
+
return *this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
template <typename... Args>
|
|
90
|
+
T& emplace(Args&&... args) {
|
|
91
|
+
reset();
|
|
92
|
+
new (&storage_) T(std::forward<Args>(args)...);
|
|
93
|
+
engaged_ = true;
|
|
94
|
+
return **this;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void reset() noexcept {
|
|
98
|
+
if (engaged_) {
|
|
99
|
+
pointer()->~T();
|
|
100
|
+
engaged_ = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
bool has_value() const noexcept { return engaged_; }
|
|
105
|
+
explicit operator bool() const noexcept { return engaged_; }
|
|
106
|
+
|
|
107
|
+
T& value() {
|
|
108
|
+
require_value();
|
|
109
|
+
return *pointer();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const T& value() const {
|
|
113
|
+
require_value();
|
|
114
|
+
return *pointer();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
template <typename U>
|
|
118
|
+
T value_or(U&& fallback) const {
|
|
119
|
+
return engaged_ ? **this : static_cast<T>(std::forward<U>(fallback));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
T& operator*() { return *pointer(); }
|
|
123
|
+
const T& operator*() const { return *pointer(); }
|
|
124
|
+
T* operator->() { return pointer(); }
|
|
125
|
+
const T* operator->() const { return pointer(); }
|
|
126
|
+
|
|
127
|
+
private:
|
|
128
|
+
using Storage = typename std::aligned_storage<sizeof(T), alignof(T)>::type;
|
|
129
|
+
|
|
130
|
+
template <typename U>
|
|
131
|
+
void construct(U&& value) {
|
|
132
|
+
new (&storage_) T(std::forward<U>(value));
|
|
133
|
+
engaged_ = true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
T* pointer() { return reinterpret_cast<T*>(&storage_); }
|
|
137
|
+
const T* pointer() const { return reinterpret_cast<const T*>(&storage_); }
|
|
138
|
+
|
|
139
|
+
void require_value() const {
|
|
140
|
+
if (!engaged_) {
|
|
141
|
+
throw std::logic_error("accessed an empty robot_msg::optional");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
Storage storage_;
|
|
146
|
+
bool engaged_;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
template <typename T>
|
|
150
|
+
bool operator==(const optional<T>& left, const optional<T>& right) {
|
|
151
|
+
return left.has_value() == right.has_value() &&
|
|
152
|
+
(!left.has_value() || *left == *right);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
template <typename T>
|
|
156
|
+
bool operator!=(const optional<T>& left, const optional<T>& right) {
|
|
157
|
+
return !(left == right);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
class string_view {
|
|
161
|
+
public:
|
|
162
|
+
using const_iterator = const char*;
|
|
163
|
+
static constexpr std::size_t npos = static_cast<std::size_t>(-1);
|
|
164
|
+
|
|
165
|
+
constexpr string_view() noexcept : data_(""), size_(0) {}
|
|
166
|
+
string_view(const char* value) : data_(value), size_(std::strlen(value)) {}
|
|
167
|
+
constexpr string_view(const char* value, std::size_t size) noexcept
|
|
168
|
+
: data_(value), size_(size) {}
|
|
169
|
+
string_view(const std::string& value) noexcept
|
|
170
|
+
: data_(value.data()), size_(value.size()) {}
|
|
171
|
+
|
|
172
|
+
constexpr const char* data() const noexcept { return data_; }
|
|
173
|
+
constexpr std::size_t size() const noexcept { return size_; }
|
|
174
|
+
constexpr bool empty() const noexcept { return size_ == 0; }
|
|
175
|
+
constexpr char operator[](std::size_t index) const { return data_[index]; }
|
|
176
|
+
constexpr const_iterator begin() const noexcept { return data_; }
|
|
177
|
+
constexpr const_iterator end() const noexcept { return data_ + size_; }
|
|
178
|
+
|
|
179
|
+
string_view substr(std::size_t position, std::size_t count = npos) const {
|
|
180
|
+
if (position > size_) {
|
|
181
|
+
throw std::out_of_range("robot_msg::string_view::substr");
|
|
182
|
+
}
|
|
183
|
+
const std::size_t remaining = size_ - position;
|
|
184
|
+
return string_view(data_ + position, count < remaining ? count : remaining);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private:
|
|
188
|
+
const char* data_;
|
|
189
|
+
std::size_t size_;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
inline bool operator==(string_view left, string_view right) {
|
|
193
|
+
return left.size() == right.size() &&
|
|
194
|
+
(left.empty() || std::memcmp(left.data(), right.data(), left.size()) == 0);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
inline bool operator!=(string_view left, string_view right) {
|
|
198
|
+
return !(left == right);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
inline bool operator==(string_view left, const std::string& right) {
|
|
202
|
+
return left == string_view(right);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
inline bool operator==(const std::string& left, string_view right) {
|
|
206
|
+
return string_view(left) == right;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
inline bool operator!=(string_view left, const std::string& right) {
|
|
210
|
+
return !(left == right);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
inline bool operator!=(const std::string& left, string_view right) {
|
|
214
|
+
return !(left == right);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
inline std::string to_string(string_view value) {
|
|
218
|
+
return std::string(value.data(), value.size());
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
} // namespace robot_msg
|