Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.263'
rev: 'v0.14.4'
hooks:
- id: ruff
args: ['--fix', '--config', '.config/ruff.toml']
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 25.11.0
hooks:
- id: black
language_version: python3.10
args: ['--config', '.config/black.toml']
verbose: true
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: check-yaml
args: ['--unsafe'] # details about the unsafe flag:
Expand All @@ -30,7 +30,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/ssciwr/clang-format-hook.git
rev: v14.0.0
rev: v16.0.2
hooks:
- id: clang-format
types_or: [c++, c]
Expand All @@ -39,20 +39,23 @@ repos:
hooks:
- id: cpplint
args: ['--quiet', '--filter=-whitespace/comments', '--linelength=120']

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
rev: v1.18.2
hooks:
- id: mypy
args: ['--config-file', '.config/mypy.ini']
pass_filenames: false
additional_dependencies:
- protobuf
- types-protobuf
- types-pytz
- types-PyYAML
- types-requests
- types-simplejson
- types-ujson
- types-PyYAML
- types-toml
- types-six
- types-toml
- types-ujson
- typing-extensions

- repo: https://github.com/jumanjihouse/pre-commit-hooks
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Boston Dynamics AI Institute
Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.
cmake_minimum_required(VERSION 3.9)
if(POLICY CMP0148)
cmake_policy(SET CMP0148 OLD) # to accommodate rosidl pipeline
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/cmake/proto2ros_generate.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

# Generates Protobuf <-> ROS 2 interoperability interfaces.
#
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/cmake/proto2ros_vendor_package.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

# Vendors a package providing Protobuf messages, adding ROS 2 interoperability interfaces.
#
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/cmake/rosidl_helpers.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

# Adds Python sources to an existing rosidl generated Python package.
#
Expand Down
3 changes: 2 additions & 1 deletion proto2ros/include/proto2ros/conversions.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2024 Boston Dynamics AI Institute LLC. All rights reserved.
// Copyright (c) 2024 Robotics and AI Institute LLC dba RAI Institute. All
// rights reserved.

/// This module provides basic conversion APIs, applicable to any proto2ros
/// generated packages.
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/msg/Any.msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

# A dynamically typed ROS 2 message.

Expand Down
2 changes: 1 addition & 1 deletion proto2ros/msg/AnyProto.msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

# A dynamically typed Protobuf message. Equivalent to the google.protobuf.Any message.
# See https://protobuf.dev/reference/protobuf/google.protobuf/#any for further reference.
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/msg/Bytes.msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

# A binary blob. Equivalent to the google.protobuf.BytesValue message, also used to map repeated bytes fields to
# the ROS 2 domain. See https://protobuf.dev/reference/protobuf/google.protobuf/#bytes-value for further reference.
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/msg/List.msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

# A list of dynamically typed values. Equivalent to the google.protobuf.ListValue message.
# See https://protobuf.dev/reference/protobuf/google.protobuf/#list-value for further reference.
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/msg/Struct.msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

# A structured data value with dynamically typed fields. Equivalent to the google.protobuf.Struct message.
# See https://protobuf.dev/reference/protobuf/google.protobuf/#struct for further reference.
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/msg/StructEntry.msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

# Key-value entries in the proto2ros/Struct ROS 2 message. Equivalent to
# the auxiliary Protobuf message used over-the-wire representation of the
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/msg/Value.msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

# A dynamically typed (scalar or composite) value. Equivalent to the google.protobuf.Value message.
# See https://protobuf.dev/reference/protobuf/google.protobuf/#value for further reference.
Expand Down
4 changes: 2 additions & 2 deletions proto2ros/package.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.
-->
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>proto2ros</name>
<version>1.0.0</version>
<description>Protobuf to ROS 2 interoperability interfaces</description>
<maintainer email="opensource@theaiinstitute.com">Boston Dynamics AI Institute</maintainer>
<maintainer email="opensource@theaiinstitute.com">Robotics and AI Institute LLC dba RAI Institute</maintainer>
<license>MIT</license>

<buildtool_depend>ament_cmake</buildtool_depend>
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros-extras.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.
include("${proto2ros_DIR}/rosidl_helpers.cmake")
if(POLICY CMP0148)
cmake_policy(SET CMP0148 OLD) # to accommodate rosidl pipeline
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/cli/generate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.
import argparse
import collections
import importlib
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/compatibility.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

# ruff: noqa
# fmt: off
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/configuration/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

"""This module defines configuration data structures for proto2ros generation."""

Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/conversions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.
import multipledispatch

# Overloads entrypoint (via multiple dispatch)
Expand Down
19 changes: 10 additions & 9 deletions proto2ros/proto2ros/conversions/basic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

"""This module provides basic conversion APIs, applicable to any proto2ros generated packages."""

Expand Down Expand Up @@ -353,25 +353,25 @@ def convert_proto2ros_value_message_to_google_protobuf_value_proto(
elif ros_msg.kind == Value.BOOL_VALUE_SET:
proto_msg.bool_value = ros_msg.bool_value
elif ros_msg.kind == Value.STRUCT_VALUE_SET:
if proto_msg.struct_value.type_name != "proto2ros/Struct":
if ros_msg.struct_value.type_name != "proto2ros/Struct":
Comment thread
mhidalgo-rai marked this conversation as resolved.
raise ValueError(
f"expected proto2ros/Struct message for struct_value member, got {proto_msg.struct_value.type}",
f"expected proto2ros/Struct message for struct_value member, got {ros_msg.struct_value.type_name}",
)
typed_field_message = rclpy.serialization.deserialize_message(
proto_msg.struct_value.value.tobytes(),
ros_msg.struct_value.value.tobytes(),
Struct,
)
convert_proto2ros_struct_message_to_google_protobuf_struct_proto(
typed_field_message,
proto_msg.struct_value,
)
elif ros_msg.kind == Value.LIST_VALUE_SET:
if proto_msg.list_value.type_name != "proto2ros/List":
if ros_msg.list_value.type_name != "proto2ros/List":
raise ValueError(
f"expected proto2ros/Struct message for list_value member, got {proto_msg.list_value.type}",
f"expected proto2ros/List message for list_value member, got {ros_msg.list_value.type_name}",
)
typed_field_message = rclpy.serialization.deserialize_message(
proto_msg.list_value.value.tobytes(),
ros_msg.list_value.value.tobytes(),
List,
)
convert_proto2ros_list_message_to_google_protobuf_list_value_proto(
Expand All @@ -393,7 +393,7 @@ def convert_google_protobuf_value_proto_to_proto2ros_value_message(
ros_msg: Value,
) -> None:
"""Converts from google.protobuf.Value Protobuf messages to proto2ros/Value ROS messages."""
which = proto_msg.WhichOneOf("kind")
which = proto_msg.WhichOneof("kind")
if which == "null_value":
ros_msg.kind = Value.NO_VALUE_SET
elif which == "number_value":
Expand Down Expand Up @@ -421,7 +421,8 @@ def convert_google_protobuf_value_proto_to_proto2ros_value_message(
ros_msg.list_value.type_name = "proto2ros/List"
ros_msg.kind = Value.LIST_VALUE_SET
else:
raise ValueError("unexpected one-of field: " + proto_msg.WhichOneOf("kind"))
which_oneof = proto_msg.WhichOneof("kind")
raise ValueError(f"unexpected one-of field: {which_oneof}")


convert_proto_to_proto2ros_value = convert_google_protobuf_value_proto_to_proto2ros_value_message
Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

"""This module provides APIs to manipulate dependencies between Protobuf <-> ROS message equivalences."""

Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/descriptors/sources.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

"""This module provides APIs to work with Protobuf definition sources."""

Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/descriptors/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

"""This module provides Protobuf typing details."""

Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/descriptors/utilities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

"""This module provides utilities to work with Protobuf descriptors.

Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/equivalences.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

"""This module provides APIs to extract Protobuf <-> ROS message equivalences.

Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/output/cpp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2024 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

"""This module provides APIs to write C++ conversion code."""

Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/output/interfaces.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

"""This module provides APIs to write ROS message specifications."""

Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/output/python.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

"""This module provides APIs to write Python conversion code."""

Expand Down
2 changes: 1 addition & 1 deletion proto2ros/proto2ros/utilities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

"""This module provides various utilities used across the proto2ros package."""

Expand Down
2 changes: 1 addition & 1 deletion proto2ros/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.
[options.entry_points]
console_scripts =
generate = proto2ros.cli.generate:main
4 changes: 3 additions & 1 deletion proto2ros/src/conversions.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) 2024 Boston Dynamics AI Institute LLC. All rights reserved.
// Copyright (c) 2024 Robotics and AI Institute LLC dba RAI Institute. All
// rights reserved.

#include "proto2ros/conversions.hpp"

#include <algorithm>
#include <sstream>

#include <rclcpp/serialization.hpp>
Expand Down
2 changes: 1 addition & 1 deletion proto2ros_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.
cmake_minimum_required(VERSION 3.12)
if(POLICY CMP0148)
cmake_policy(SET CMP0148 OLD) # to accommodate rosidl pipeline
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2024 Boston Dynamics AI Institute LLC. All rights reserved.
// Copyright (c) 2024 Robotics and AI Institute LLC dba RAI Institute. All
// rights reserved.

#pragma once

Expand Down
4 changes: 2 additions & 2 deletions proto2ros_tests/package.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.
-->
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>proto2ros_tests</name>
<version>1.0.0</version>
<description>Protobuf to ROS 2 interoperability interfaces tests</description>
<maintainer email="opensource@theaiinstitute.com">Boston Dynamics AI Institute</maintainer>
<maintainer email="opensource@theaiinstitute.com">Robotics and AI Institute LLC dba RAI Institute</maintainer>
<license>MIT</license>

<buildtool_depend>ament_cmake</buildtool_depend>
Expand Down
2 changes: 1 addition & 1 deletion proto2ros_tests/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.
find_package(Protobuf REQUIRED)

file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bosdyn/api")
Expand Down
1 change: 0 additions & 1 deletion proto2ros_tests/proto2ros_tests/manual_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import geometry_msgs.msg
import sensor_msgs.msg
import test_pb2

from proto2ros.conversions import convert


Expand Down
4 changes: 3 additions & 1 deletion proto2ros_tests/src/manual_conversions.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) 2024 Boston Dynamics AI Institute LLC. All rights reserved.
// Copyright (c) 2024 Robotics and AI Institute LLC dba RAI Institute. All
// rights reserved.

#include "proto2ros_tests/manual_conversions.hpp"

#include <cmath>
#include <limits>

namespace proto2ros_tests::conversions {

Expand Down
3 changes: 2 additions & 1 deletion proto2ros_tests/test/test_proto2ros.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2024 Boston Dynamics AI Institute LLC. All rights reserved.
// Copyright (c) 2024 Robotics and AI Institute LLC dba RAI Institute. All
// rights reserved.
// NOLINTBEGIN(readability-magic-numbers,readability-function-cognitive-complexity,cppcoreguidelines-pro-type-reinterpret-cast)
#include <bosdyn/api/geometry.pb.h>
#include <gtest/gtest.h>
Expand Down
6 changes: 3 additions & 3 deletions proto2ros_tests/test/test_proto2ros.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.
# Copyright (c) 2023 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

import filecmp
import math
Expand All @@ -8,11 +8,11 @@
import bosdyn.api.geometry_pb2
import geometry_msgs.msg
import google.protobuf.type_pb2
import proto2ros_tests.msg
import test_pb2
from proto2ros_tests.conversions import convert

import proto2ros_tests.msg
from proto2ros.msg import Any, AnyProto # type: ignore
from proto2ros_tests.conversions import convert


def test_message_generation() -> None:
Expand Down
Loading