Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: aimrt_py support ros2 protocol interface #95

Merged
merged 55 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
5a79b74
feat: add checks for ROS 2 message type support
zhangyi1357 Nov 7, 2024
11ac735
build: update file globbing to include configure dependencies
zhangyi1357 Nov 7, 2024
455a2fc
feat: add ROS2 message support and enhance publishing functionality
Nov 8, 2024
67e98c8
feat: add HTTP and ROS2 example configurations and applications
Nov 8, 2024
cdb8924
chore: disable unimplemented copy and move functions
Nov 8, 2024
0650f44
feat: enhance message publishing with iteration and logging
Nov 8, 2024
f7691c8
refactor: reorganize and encapsulate ROS2 message handling functionality
Nov 8, 2024
6aa08bb
refactor: streamline protobuf and ROS2 message publishing
Nov 11, 2024
3751ed1
refactor: streamline messaging functions
Nov 11, 2024
079306b
refactor: simplify message subscription handling and reduce publish f…
Nov 11, 2024
219a300
fix: remove unnecessary error message for ROS 1 type detection
Nov 11, 2024
ab6521e
docs: update README and add ros2 channel examples
Nov 11, 2024
605cf09
feat: support ros2 message types in aimrt_py channel
Nov 11, 2024
78a4425
fix: improve error handling during ROS2 message serialization and des…
Nov 11, 2024
f53d338
fix: correct argument validation and formatting
Nov 11, 2024
ccc44ba
refactor: streamline message conversion logic
Nov 11, 2024
39aa0ab
feat: add ROS2 support to Python runtime
Nov 12, 2024
b9a0016
feat: enhance message type handling for publishers and subscribers
Nov 12, 2024
ae64f1c
feat: update message types to use RosTestMsg for better compatibility
Nov 12, 2024
780864c
chore: consolidate pybind11 includes
Nov 12, 2024
8a67e4b
docs: add ROS2 message support details and example links
Nov 12, 2024
c794cf4
chore: update copyright information to reflect new authorship
Nov 12, 2024
60011e4
feat: add ROS2 RPC client and server examples with configurations
zhangyi1357 Nov 14, 2024
e75460d
feat: update RPC request and response handling
zhangyi1357 Nov 14, 2024
95ad436
refactor: simplify RPC response handling
zhangyi1357 Nov 14, 2024
95d26b8
refactor: streamline publisher and subscriber method names
zhangyi1357 Nov 14, 2024
475b6af
chore: update configuration file paths for gRPC client and server exa…
zhangyi1357 Nov 14, 2024
31cb039
refactor: rename internal methods for clarity
zhangyi1357 Nov 14, 2024
7076dd3
feat: add service type validation and improve bash scripts
zhangyi1357 Nov 15, 2024
4585e11
feat: extend RPC response data structure and improve logging
zhangyi1357 Nov 15, 2024
14274d9
feat: add support for static and dynamic arrays in RPC service
zhangyi1357 Nov 18, 2024
aa85968
feat: add support for new ROS message types
zhangyi1357 Nov 18, 2024
6ad0e57
refactor: improve type mapping and message copy functions
zhangyi1357 Nov 18, 2024
f97f3c0
refactor: improve message copying and moving functions
zhangyi1357 Nov 19, 2024
068716e
refactor: simplify message type support functions
zhangyi1357 Nov 19, 2024
b76018f
refactor: streamline ROS message handling and improve introspection s…
zhangyi1357 Nov 19, 2024
5e6ae7f
fix: ensure pointers for ROS message creation and destruction are valid
zhangyi1357 Nov 19, 2024
b8fd122
feat: enhance RosTestRpc method signature for better type safety
zhangyi1357 Nov 19, 2024
97e362e
refactor: simplify parameter naming in RPC proxy function
zhangyi1357 Nov 19, 2024
5542a83
fix: restrict static array sizes in RosTestRpc service
zhangyi1357 Nov 19, 2024
079c0c1
feat: enhance python runtime generation for ROS2 services
zhangyi1357 Nov 19, 2024
bb37ded
refactor: update RPC service and client implementations to use ROS2 n…
zhangyi1357 Nov 19, 2024
a5372b6
chore: update .gitignore to exclude generated files
zhangyi1357 Nov 19, 2024
f250378
refactor: streamline response structure for RosTestRpc
zhangyi1357 Nov 19, 2024
42811d0
chore: update log level to INFO for consistency
zhangyi1357 Nov 19, 2024
bcfa9c0
docs: add README for ros2 rpc examples
zhangyi1357 Nov 19, 2024
b5625ec
feat: enhance aimrt_py channel with rpc support for ros2 message types
zhangyi1357 Nov 19, 2024
059d5e7
docs: add ros2_rpc example to Python interface section
zhangyi1357 Nov 19, 2024
116dc13
chore: add spacing for improved readability in service proxy class
zhangyi1357 Nov 19, 2024
d107f4f
chore: standardize argument names for RPC generator
zhangyi1357 Nov 19, 2024
3cb5d3f
docs: update RPC documentation to include ROS2 Srv support
zhangyi1357 Nov 19, 2024
f341fc0
style: standardize whitespace in RosTestRpc.srv
zhangyi1357 Nov 19, 2024
a5cea2c
build: exclude ROS2 specific files from the build if not using ROS2
zhangyi1357 Nov 19, 2024
1fd6b4c
style: add missing newline at end of file for consistency
zhangyi1357 Nov 19, 2024
9bf6eb8
refactor: rename copy function to improve clarity
zhangyi1357 Nov 19, 2024
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
Prev Previous commit
Next Next commit
feat: update message types to use RosTestMsg for better compatibility
Register new message type RosTestMsg in both publisher and subscriber applications. Update data format for publishing events to improve clarity and consistency in message handling. Ensure proper setup in the shell scripts for localization configuration.
  • Loading branch information
zhangyi committed Nov 12, 2024
commit ae64f1c63665f20c67ec3827b609934f5ae3b62f
15 changes: 8 additions & 7 deletions src/examples/py/ros2_chn/examples_py_ros2_chn_publisher_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import aimrt_py
import yaml
from std_msgs.msg import String
from example_ros2.msg import RosTestMsg


def main():
Expand Down Expand Up @@ -37,7 +37,7 @@ def main():
publisher = module_handle.GetChannelHandle().GetPublisher(topic_name)
assert publisher, f"Get publisher for topic '{topic_name}' failed."

aimrt_py.RegisterPublishType(publisher, String)
aimrt_py.RegisterPublishType(publisher, RosTestMsg)

# Start
thread = threading.Thread(target=aimrt_core.Start)
Expand All @@ -46,24 +46,25 @@ def main():
# Sleep for seconds
time.sleep(1)

msg = String()
msg = RosTestMsg()
msg.num = 1000

# Publish event
msg.data = "Publish without ctx or serialization_type"
msg.data = [bytes([x]) for x in [1, 2, 3, 4]]
aimrt_py.Publish(publisher, msg)
aimrt_py.info(module_handle.GetLogger(),
f"Publish new ros2 message, data: {msg.data}")

# Publish event with ros2 serialization
msg.data = "Publish with ros2 serialization"
msg.data = [bytes([x]) for x in [5, 6, 7, 8]]
aimrt_py.Publish(publisher, "ros2", msg)
aimrt_py.info(module_handle.GetLogger(),
f"Publish new ros2 message, data: {msg.data}")

# Publish event with context
ctx = aimrt_py.Context()
ctx.SetMetaValue("key1", "value1")
msg.data = "Publish with context"
msg.data = [bytes([x]) for x in [9, 10, 11, 12]]
aimrt_py.Publish(publisher, ctx, msg)
aimrt_py.info(module_handle.GetLogger(),
f"Publish new ros2 message, data: {msg.data}")
Expand All @@ -73,7 +74,7 @@ def main():
ctx_ref = aimrt_py.ContextRef(ctx)
ctx_ref.SetMetaValue("key2", "value2")
ctx_ref.SetSerializationType("ros2")
msg.data = "Publish with context ref"
msg.data = [bytes([x]) for x in [13, 14, 15, 16]]
aimrt_py.Publish(publisher, ctx_ref, msg)
aimrt_py.info(module_handle.GetLogger(),
f"Publish new ros2 message, data: {msg.data}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import aimrt_py
import yaml
from std_msgs.msg import String
from example_ros2.msg import RosTestMsg

global_aimrt_core = None

Expand Down Expand Up @@ -58,13 +58,13 @@ def main():

count = 0

def EventHandle(ctx_ref: aimrt_py.ContextRef, msg: String):
def EventHandle(ctx_ref: aimrt_py.ContextRef, msg: RosTestMsg):
nonlocal count
count += 1
aimrt_py.info(module_handle.GetLogger(),
f"Get new ros2 message, ctx: {ctx_ref.ToString()}, data: {msg.data}, count: {count}")

aimrt_py.Subscribe(subscriber, String, EventHandle)
aimrt_py.Subscribe(subscriber, RosTestMsg, EventHandle)

# Start
thread = threading.Thread(target=aimrt_core.Start)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

export AIMRT_PLUGIN_DIR=$(pip show aimrt_py | grep Location | awk '{print $2}')/aimrt_py
source $AIMRT_PLUGIN_DIR/share/example_ros2/local_setup.bash

python3 ./examples_py_ros2_chn_publisher_app.py --cfg_file_path=./cfg/examples_py_ros2_chn_http_pub_cfg.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

export AIMRT_PLUGIN_DIR=$(pip show aimrt_py | grep Location | awk '{print $2}')/aimrt_py
source $AIMRT_PLUGIN_DIR/share/example_ros2/local_setup.bash

python3 ./examples_py_ros2_chn_subscriber_app.py --cfg_file_path=./cfg/examples_py_ros2_chn_http_sub_cfg.yaml
8 changes: 4 additions & 4 deletions src/runtime/python_runtime/aimrt_py_chn.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ def _CreateContextRef(ctx_or_type, default_serialization_type: str) -> aimrt_pyt


def _GetRos2MessageTypeName(msg_type: Ros2MsgType) -> str:
return "ros2:" + ".".join([msg_type.__module__, msg_type.__name__])
module_parts = msg_type.__module__.split('.')
module_name = '/'.join(module_parts[:-1])
return "ros2:" + "/".join([module_name, msg_type.__name__])


def _GetPbMessageTypeName(msg: google.protobuf.message.Message | google._upb._message.MessageMeta) -> str:
def _GetPbMessageTypeName(msg: google._upb._message.MessageMeta) -> str:
return f"pb:{msg.DESCRIPTOR.full_name}"


Expand All @@ -74,13 +76,11 @@ def RegisterPublishType(publisher: aimrt_python_runtime.PublisherRef,
bool: True if success, False otherwise
"""
if isinstance(msg_type, google._upb._message.MessageMeta):
print(f"_GetPbMessageTypeName(msg_type): {_GetPbMessageTypeName(msg_type)}")
py_pb_ts = aimrt_python_runtime.PyPbTypeSupport()
py_pb_ts.SetTypeName(_GetPbMessageTypeName(msg_type))
py_pb_ts.SetSerializationTypesSupportedList(["pb", "json"])
return publisher.RegisterPbPublishType(py_pb_ts)
elif check_is_valid_ros2_msg_type(msg_type):
print(f"_GetRos2MessageTypeName(msg_type): {_GetRos2MessageTypeName(msg_type)}")
py_ros2_ts = aimrt_python_runtime.PyRos2TypeSupport(msg_type)
py_ros2_ts.SetTypeName(_GetRos2MessageTypeName(msg_type))
py_ros2_ts.SetSerializationTypesSupportedList(["ros2"])
Expand Down