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

Use ament_python to build packages rather than ament_cmake #939

Open
wants to merge 38 commits into
base: ros2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7bdecc1
Changed type hints in ros_loader.py to use imports from Typing, resto…
EricGallimore Jul 16, 2024
3f44e5f
Reordered imports alphabetically to fix isort linting CI error.
EricGallimore Jul 16, 2024
8b1b597
Change rosapi package to use ament_python rather than ament_cmake.
EricGallimore Jul 16, 2024
e3f823e
Change rosbridge_server to use ament_python rather than ament_cmake.
EricGallimore Jul 16, 2024
81b6172
Fix setup.py formatting.
EricGallimore Jul 16, 2024
a6d28c6
Run pre-commit and commit fixes. (Not sure why this is needed, since…
EricGallimore Jul 16, 2024
75ec314
Revert inadvertent changes to rosbridge_websocket symlink.
EricGallimore Jul 16, 2024
377b9b7
Merge branch '937-type-string-dependency' into ament_python
EricGallimore Jul 16, 2024
609e037
Fix launch files in rosbridge_server.
EricGallimore Jul 16, 2024
f7b258e
Fix setup.cfg paths.
EricGallimore Jul 16, 2024
88534ab
Fix setup.py data_files.
EricGallimore Jul 16, 2024
1617efc
Moved rosapi_node and rosbridge_websocket.py into respective packages.
EricGallimore Jul 16, 2024
b808d1a
Add resource files.
EricGallimore Jul 16, 2024
1876681
Reorganize package to follow ROS2 python convention (and resolve issu…
EricGallimore Jul 16, 2024
24317fc
Run pre-commit and fix linting errors.
EricGallimore Jul 16, 2024
3d81ba8
Merge branch 'ros2' into ament_python
sea-bass Aug 14, 2024
974c6b7
rosapi: Don't start parameter services that aren't spun (#943) (#944)
bmartin427 Aug 15, 2024
8b0b4c5
rosbridge_websocket: Stop websocket server if ROS shuts down (#945) (…
bmartin427 Aug 15, 2024
baa463a
Avoid stale subscription when unsubscribing during resubscription (#9…
bmartin427 Aug 15, 2024
996fddd
docs: update ROSBRIDGE_PROTOCOL.md - correcting indentation (#949)
ManuETR Aug 15, 2024
febe1c4
fix: update new subs with dds from publisher (#940)
dnikitop Aug 15, 2024
677dcae
Fixed executable bit on scripts.
EricGallimore Aug 15, 2024
04aa0d4
Merge branch 'ament_python' of https://github.com/EricGallimore/rosbr…
EricGallimore Aug 15, 2024
55b8fa3
Fix length-limited list types (#840)
EzraBrooks Aug 15, 2024
f7aa27a
Change rosapi package to use ament_python rather than ament_cmake.
EricGallimore Jul 16, 2024
28eb1c0
Change rosbridge_server to use ament_python rather than ament_cmake.
EricGallimore Jul 16, 2024
ad1aa25
Fix setup.py formatting.
EricGallimore Jul 16, 2024
98b4347
Run pre-commit and commit fixes. (Not sure why this is needed, since…
EricGallimore Jul 16, 2024
b9d200d
Revert inadvertent changes to rosbridge_websocket symlink.
EricGallimore Jul 16, 2024
889b229
Fix launch files in rosbridge_server.
EricGallimore Jul 16, 2024
2882d8e
Fix setup.cfg paths.
EricGallimore Jul 16, 2024
407af90
Fix setup.py data_files.
EricGallimore Jul 16, 2024
ce4d937
Moved rosapi_node and rosbridge_websocket.py into respective packages.
EricGallimore Jul 16, 2024
cc00596
Add resource files.
EricGallimore Jul 16, 2024
0cc24db
Reorganize package to follow ROS2 python convention (and resolve issu…
EricGallimore Jul 16, 2024
f017bd7
Run pre-commit and fix linting errors.
EricGallimore Jul 16, 2024
8a72cc6
Fixed executable bit on scripts.
EricGallimore Aug 15, 2024
496dde3
Merge remote-tracking branch 'origin/ament_python' into ament_python
EricGallimore Aug 26, 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
12 changes: 6 additions & 6 deletions ROSBRIDGE_PROTOCOL.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ ROS operations:
* **call_service** - a service call
* **service_response** - a service response
* Actions:
* **advertise_action** - advertise an external action server
* **unadvertise_action** - unadvertise an external action server
* **send_action_goal** - a goal sent to an action server
* **cancel_action_goal** - cancel an in-progress action goal
* **action_feedback** - feedback messages from an action server
* **action_result** - an action result
* **advertise_action** - advertise an external action server
* **unadvertise_action** - unadvertise an external action server
* **send_action_goal** - a goal sent to an action server
* **cancel_action_goal** - cancel an in-progress action goal
* **action_feedback** - feedback messages from an action server
* **action_result** - an action result

In general, actions or operations that the client takes (such as publishing and
subscribing) have opcodes which are verbs (subscribe, call_service, unadvertise
Expand Down
4 changes: 2 additions & 2 deletions rosapi/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<maintainer email="[email protected]">Jihoon Lee</maintainer>
<maintainer email="[email protected]">Foxglove</maintainer>

<buildtool_depend>ament_cmake_ros</buildtool_depend>
<buildtool_depend>ament_python</buildtool_depend>

<exec_depend>rosapi_msgs</exec_depend>
<exec_depend>builtin_interfaces</exec_depend>
Expand All @@ -41,7 +41,7 @@
<test_depend>rmw_dds_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
<build_type>ament_python</build_type>
<ros1_bridge mapping_rules="mapping_rules.yaml"/>
</export>
</package>
File renamed without changes.
Empty file added rosapi/rosapi/__init__.py
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
import logging
import re

from rosapi.stringify_field_types import stringify_field_types
from rosbridge_library.internal import ros_loader

from rosapi.stringify_field_types import stringify_field_types

# Keep track of atomic types and special types
atomics = [
"bool",
Expand Down
5 changes: 4 additions & 1 deletion rosapi/src/rosapi/params.py → rosapi/rosapi/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from rclpy.parameter import get_parameter_value
from ros2node.api import get_absolute_node_name
from ros2param.api import call_get_parameters, call_set_parameters

from rosapi.proxy import get_nodes

""" Methods to interact with the param server. Values have to be passed
Expand Down Expand Up @@ -75,7 +76,9 @@ def init(parent_node_name):
parent_node_basename = parent_node_name.split("/")[-1]
param_node_name = f"{parent_node_basename}_params"
_node = rclpy.create_node(
param_node_name, cli_args=["--ros-args", "-r", f"__node:={param_node_name}"]
param_node_name,
cli_args=["--ros-args", "-r", f"__node:={param_node_name}"],
start_parameter_services=False,
)
_parent_node_name = get_absolute_node_name(parent_node_name)

Expand Down
File renamed without changes.
sea-bass marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
4 changes: 4 additions & 0 deletions rosapi/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script_dir=$base/lib/rosapi
[install]
install_scripts=$base/lib/rosapi
29 changes: 29 additions & 0 deletions rosapi/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os

from setuptools import find_packages, setup

package_name = "rosapi"

setup(
name=package_name,
version="1.3.2",
packages=find_packages(exclude=["test"]),
data_files=[
# Install marker file in the package index
("share/ament_index/resource_index/packages", ["resource/" + package_name]),
# Include our package.xml file
(os.path.join("share", package_name), ["package.xml"]),
],
install_requires=["setuptools"],
zip_safe=True,
author="Jonathan Mace",
author_email="[email protected]",
maintainer="Jihoon Lee, Foxglove",
maintainer_email="[email protected], [email protected]",
description="Provides service calls for getting ros meta-information, like list of topics, services, params, etc.",
license="BSD",
tests_require=["pytest"],
entry_points={
"console_scripts": ["rosapi_node = rosapi.rosapi_node:main"],
},
)
3 changes: 2 additions & 1 deletion rosapi/test/test_stringify_field_types.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env python
import unittest

from rosapi.stringify_field_types import stringify_field_types
from rosbridge_library.internal.ros_loader import InvalidModuleException

from rosapi.stringify_field_types import stringify_field_types


class TestObjectUtils(unittest.TestCase):
def test_stringify_field_types(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
]
ros_header_types = ["Header", "std_msgs/Header", "roslib/Header"]
ros_binary_types = ["uint8[]", "char[]", "sequence<uint8>", "sequence<char>"]
list_tokens = re.compile("<(.+?)>")
# Remove the list type wrapper, and length specifier, from rostypes i.e. sequence<double, 3>
list_tokens = re.compile(r"<(.+?)(, \d+)?>")
bounded_array_tokens = re.compile(r"(.+)\[.*\]")
ros_binary_types_list_braces = [
("uint8[]", re.compile(r"uint8\[[^\]]*\]")),
Expand Down Expand Up @@ -392,7 +393,6 @@ def _to_object_inst(msg, rostype, roottype, clock, inst, stack):
inst.stamp = clock.now().to_msg()

inst_fields = inst.get_fields_and_field_types()

for field_name in msg:
# Add this field to the field stack
field_stack = stack + [field_name]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ def subscribe(self, client_id, callback):
# In any case, the first message is handled using new_sub_callback,
# which adds the new callback to the subscriptions dictionary.
self.new_subscriptions.update({client_id: callback})
infos = self.node_handle.get_publishers_info_by_topic(self.topic)
if any(pub.qos_profile.durability == DurabilityPolicy.TRANSIENT_LOCAL for pub in infos):
self.qos.durability = DurabilityPolicy.TRANSIENT_LOCAL
if any(pub.qos_profile.reliability == ReliabilityPolicy.BEST_EFFORT for pub in infos):
self.qos.reliability = ReliabilityPolicy.BEST_EFFORT
if self.new_subscriber is None:
self.new_subscriber = self.node_handle.create_subscription(
self.msg_class,
Expand All @@ -196,7 +201,7 @@ def unsubscribe(self, client_id):
with self.rlock:
if client_id in self.new_subscriptions:
del self.new_subscriptions[client_id]
else:
if client_id in self.subscriptions:
del self.subscriptions[client_id]

def has_subscribers(self):
Expand Down
18 changes: 18 additions & 0 deletions rosbridge_library/test/internal/test_message_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,21 @@ def test_float32_msg(rostype, data):
ints = list(map(int, range(0, 16)))
ret = test_float32_msg(rostype, ints)
np.testing.assert_array_equal(ret, np.array(ints))

# Test a float32 array with a length with non-numeric characters in it
def test_float32_complexboundedarray(self):
def test_nestedboundedarray_msg(rostype, data):
msg = {"data": {"data": data}}
inst = ros_loader.get_message_instance(rostype)
c.populate_instance(msg, inst)
self.validate_instance(inst)
return inst.data

for msgtype in ["TestNestedBoundedArray"]:
rostype = "rosbridge_test_msgs/" + msgtype

# From List[float]
floats = list(map(float, range(0, 16)))
ret = test_nestedboundedarray_msg(rostype, floats)

self.assertEqual(c._from_inst(ret, rostype), {"data": floats})
5 changes: 2 additions & 3 deletions rosbridge_server/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
<maintainer email="[email protected]">Jihoon Lee</maintainer>
<maintainer email="[email protected]">Foxglove</maintainer>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_ros</buildtool_depend>
<buildtool_depend>ament_python</buildtool_depend>

<exec_depend>python3-tornado</exec_depend>
<exec_depend>python3-twisted</exec_depend>
Expand All @@ -34,6 +33,6 @@
<test_depend>std_srvs</test_depend>

<export>
<build_type>ament_cmake</build_type>
<build_type>ament_python</build_type>
</export>
</package>
Empty file.
sea-bass marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,13 @@ def main(args=None):

executor = rclpy.executors.SingleThreadedExecutor()
executor.add_node(node)
spin_callback = PeriodicCallback(lambda: executor.spin_once(timeout_sec=0.01), 1)

def spin_ros():
executor.spin_once(timeout_sec=0.01)
if not rclpy.ok():
shutdown_hook()

spin_callback = PeriodicCallback(spin_ros, 1)
spin_callback.start()
try:
start_hook()
Expand Down
sea-bass marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
1 change: 0 additions & 1 deletion rosbridge_server/scripts/rosbridge_websocket

This file was deleted.

4 changes: 4 additions & 0 deletions rosbridge_server/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script_dir=$base/lib/rosbridge_server
[install]
install_scripts=$base/lib/rosbridge_server
35 changes: 35 additions & 0 deletions rosbridge_server/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os
from glob import glob

from setuptools import find_packages, setup

package_name = "rosbridge_server"

setup(
name=package_name,
version="1.3.2",
packages=find_packages(exclude=["test"]),
data_files=[
# Install marker file in the package index
("share/ament_index/resource_index/packages", ["resource/" + package_name]),
# Include our package.xml file
(os.path.join("share", package_name), ["package.xml"]),
# Include all launch files.
(
os.path.join("share", package_name, "launch"),
glob(os.path.join("launch", "*launch.[pxy][yma]*")),
),
],
install_requires=["setuptools"],
zip_safe=True,
author="Jonathan Mace",
author_email="[email protected]",
maintainer="Jihoon Lee, Foxglove",
maintainer_email="[email protected], [email protected]",
description="A WebSocket interface to rosbridge.",
license="BSD",
tests_require=["pytest"],
entry_points={
"console_scripts": ["rosbridge_websocket = rosbridge_server.rosbridge_websocket:main"],
},
)
1 change: 1 addition & 0 deletions rosbridge_test_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rosidl_generate_interfaces(${PROJECT_NAME}
msg/TestUInt8FixedSizeArray16.msg
msg/TestFloat32Array.msg
msg/TestFloat32BoundedArray.msg
msg/TestNestedBoundedArray.msg
srv/AddTwoInts.srv
srv/SendBytes.srv
srv/TestArrayRequest.srv
Expand Down
1 change: 1 addition & 0 deletions rosbridge_test_msgs/msg/TestNestedBoundedArray.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TestFloat32BoundedArray data