Skip to content

Commit

Permalink
Rebase from 'upstream'
Browse files Browse the repository at this point in the history
  • Loading branch information
aleph-ra committed Jan 7, 2025
1 parent f49c5e2 commit 5229e51
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 63 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/release_mirror.yml

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog for package automatika_ros_sugar
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.2.5 (2025-01-07)
------------------
* (fix) Gets imports and default values based on installed distro
* (fix) Fix launch and launch_ros imports based on ros distro
* Contributors: ahr, mkabtoul

0.2.4 (2024-12-27)
------------------
* (fix) Adds algorithm auto re-configuration from YAML file
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>automatika_ros_sugar</name>
<version>0.2.4</version>
<version>0.2.5</version>
<description>Syntactic sugar for ROS2 nodes creation and management</description>
<maintainer email="[email protected]">Automatika Robotics</maintainer>
<url type="website">https://github.com/automatika/ros-sugar</url>
Expand Down
18 changes: 3 additions & 15 deletions ros_sugar/config/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ class QoSConfig(BaseAttrs):
history: int = field(
converter=_get_enum_value,
default=qos.HistoryPolicy.KEEP_LAST,
validator=base_validators.in_([
qos.HistoryPolicy.KEEP_LAST,
qos.HistoryPolicy.KEEP_ALL,
]),
validator=base_validators.in_(list(qos.HistoryPolicy)),
)

# used only if the “history” policy was set to “keep last”
Expand All @@ -45,24 +42,15 @@ class QoSConfig(BaseAttrs):
reliability: int = field(
converter=_get_enum_value,
default=qos.ReliabilityPolicy.RELIABLE,
validator=base_validators.in_([
qos.ReliabilityPolicy.BEST_EFFORT,
qos.ReliabilityPolicy.RELIABLE,
]),
validator=base_validators.in_(list(qos.ReliabilityPolicy)),
)

# Transient local: the publisher becomes responsible for persisting samples for “late-joining” subscriptions
# Volatile: no attempt is made to persist samples
durability: int = field(
converter=_get_enum_value,
default=qos.DurabilityPolicy.VOLATILE,
validator=base_validators.in_([
qos.DurabilityPolicy.TRANSIENT_LOCAL,
qos.DurabilityPolicy.VOLATILE,
# qos.DurabilityPolicy.BEST_AVAILABLE, # Only available in iron -> TODO: Get values from rclpy
qos.DurabilityPolicy.UNKNOWN,
qos.DurabilityPolicy.SYSTEM_DEFAULT,
]),
validator=base_validators.in_(list(qos.DurabilityPolicy)),
)

# TODO: Fix default values
Expand Down
4 changes: 2 additions & 2 deletions ros_sugar/core/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _reparse_inputs_callbacks(self, inputs: Sequence[Topic]) -> Sequence[Topic]:
:rtype: List[Topic]
"""
for inp in inputs:
if not isinstance(inp.msg_type.callback, List):
if not inp or not isinstance(inp.msg_type.callback, List):
continue
module_name = (
self.__module__[: self.__module__.index(".")]
Expand Down Expand Up @@ -217,7 +217,7 @@ def _reparse_outputs_converts(self, outputs: Sequence[Topic]) -> Sequence[Topic]
:rtype: List[Topic]
"""
for out in outputs:
if not isinstance(out.msg_type.convert, List):
if not out or not isinstance(out.msg_type.convert, List):
continue
module_name = self.__module__
# Get first callback by default
Expand Down
15 changes: 3 additions & 12 deletions ros_sugar/core/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,7 @@

from ..io.topic import Topic
from .action import Action

# Get ROS distro
__installed_distro = os.environ.get("ROS_DISTRO", "").lower()

if __installed_distro == "foxy":
from launch.some_actions_type import SomeActionsType as SomeType
else:
from launch.some_entities_type import SomeEntitiesType as SomeType

SomeEntitiesType = SomeType
from ..utils import SomeEntitiesType


class Timer:
Expand Down Expand Up @@ -380,12 +371,12 @@ def __init__(

# Check if given trigger is of valid type
if trigger_value and not _check_attribute(
self.event_topic.msg_type._ros_type,
self.event_topic.msg_type.get_ros_type(),
type(self.trigger_ref_value),
self._attrs,
):
raise TypeError(
f"Cannot initiate with trigger of type {type(trigger_value)} for a data of type {_get_attribute_type(self.event_topic.msg_type._ros_type, self._attrs)}"
f"Cannot initiate with trigger of type {type(trigger_value)} for a data of type {_get_attribute_type(self.event_topic.msg_type.get_ros_type(), self._attrs)}"
)

# Init trigger as False
Expand Down
13 changes: 12 additions & 1 deletion ros_sugar/io/supported_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def add_additional_datatypes(types: List[type]) -> None:

_update_supportedtype_callback(existing_class, new_type)

if not existing_class._ros_type:
if hasattr(new_type, "_ros_type") and (
not hasattr(existing_class, "_ros_type") or not existing_class._ros_type
):
existing_class._ros_type = new_type._ros_type

_update_supportedtype_conversion(existing_class, new_type)
Expand Down Expand Up @@ -154,6 +156,15 @@ def convert(cls, output, **_) -> Any:
"""
return output

@classmethod
def get_ros_type(cls) -> type:
"""Getter of the ROS2 message type
:return: ROS2 type
:rtype: type
"""
return cls._ros_type


class String(SupportedType):
"""String."""
Expand Down
2 changes: 1 addition & 1 deletion ros_sugar/io/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def _msg_type_validator(self, _, val):
f"Got value of 'msg_type': {val}, which is not in available datatypes. Topics can only be created with one of the following types: { {msg_t.__name__: msg_t for msg_t in msg_types} }"
)
# Set ros type
self.ros_msg_type = self.msg_type._ros_type
self.ros_msg_type = self.msg_type.get_ros_type()


@define(kw_only=True)
Expand Down
Loading

0 comments on commit 5229e51

Please sign in to comment.