Skip to content

Commit

Permalink
Merge branch 'ros2' into fix-list-tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-bass authored Aug 15, 2024
2 parents c0202c8 + 8b0b4c5 commit f4edfb6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5.0.0
- uses: actions/setup-python@v5.1.0
with:
python-version: '3.8'
python-version: '3.10'

- uses: pre-commit/[email protected]

Expand All @@ -21,12 +21,13 @@ jobs:
include:
# Test supported ROS 2 distributions
# https://docs.ros.org/en/rolling/Releases.html
- ros: humble
os: ubuntu-22.04
# NOTE: Humble does not work on the `ros2` branch, so it is tested in its own branch.
- ros: iron
os: ubuntu-22.04
- ros: jazzy
os: ubuntu-24.04
- ros: rolling
os: ubuntu-22.04
os: ubuntu-24.04

name: ROS 2 ${{ matrix.ros }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
Expand All @@ -36,7 +37,7 @@ jobs:
with:
path: ros_ws/src

- uses: ros-tooling/setup-ros@0.7.1
- uses: ros-tooling/setup-ros@v0.7

- uses: ros-tooling/[email protected]
with:
Expand Down
7 changes: 5 additions & 2 deletions rosapi/src/rosapi/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
import rclpy
from rcl_interfaces.msg import Parameter, ParameterType, ParameterValue
from rcl_interfaces.srv import ListParameters
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, get_parameter_value
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 @@ -74,7 +75,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
12 changes: 6 additions & 6 deletions rosbridge_library/src/rosbridge_library/internal/ros_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

import importlib
from threading import Lock
from typing import Any
from typing import Any, Dict, Tuple

""" ros_loader contains methods for dynamically loading ROS message classes at
runtime. It's achieved by using roslib to load the manifest files for the
Expand Down Expand Up @@ -129,7 +129,7 @@ def get_action_result_instance(typestring: str) -> Any:


def _get_interface_class(
typestring: str, intf_type: str, loaded_intfs: dict[str, Any], intf_lock: Lock
typestring: str, intf_type: str, loaded_intfs: Dict[str, Any], intf_lock: Lock
) -> Any:
"""
If not loaded, loads the specified ROS interface class then returns an instance of it.
Expand All @@ -152,7 +152,7 @@ def _get_interface_class(
return _get_class(typestring, intf_type, loaded_intfs, intf_lock)


def _get_class(typestring: str, subname: str, cache: dict[str, Any], lock: Lock) -> Any:
def _get_class(typestring: str, subname: str, cache: Dict[str, Any], lock: Lock) -> Any:
"""If not loaded, loads the specified class then returns an instance
of it.
Expand Down Expand Up @@ -206,7 +206,7 @@ def _load_class(modname: str, subname: str, classname: str) -> None:
raise InvalidClassException(modname, subname, classname, exc)


def _splittype(typestring: str) -> tuple[str, str]:
def _splittype(typestring: str) -> Tuple[str, str]:
"""Split the string the / delimiter and strip out empty strings
Performs similar logic to roslib.names.package_resource_name but is a bit
Expand All @@ -220,13 +220,13 @@ def _splittype(typestring: str) -> tuple[str, str]:
raise InvalidTypeStringException(typestring)


def _add_to_cache(cache: dict[str, Any], lock: Lock, key: str, value: any) -> None:
def _add_to_cache(cache: Dict[str, Any], lock: Lock, key: str, value: any) -> None:
lock.acquire()
cache[key] = value
lock.release()


def _get_from_cache(cache: dict[str, Any], lock: Lock, key: str) -> Any:
def _get_from_cache(cache: Dict[str, Any], lock: Lock, key: str) -> Any:
"""Returns the value for the specified key from the cache.
Locks the lock before doing anything. Returns None if key not in cache"""
lock.acquire()
Expand Down
8 changes: 7 additions & 1 deletion rosbridge_server/scripts/rosbridge_websocket.py
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

0 comments on commit f4edfb6

Please sign in to comment.