Skip to content

Commit

Permalink
Merge pull request #62 from FormantIO/add-joy
Browse files Browse the repository at this point in the history
Add Joy support to ros2 adapter
  • Loading branch information
fvolcic authored Jul 24, 2024
2 parents 890aa5a + 0027c46 commit 5cac23e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@

class GenericPublisher:
def __init__(
self, fclient: Client, node: Node, topic_type_provider: TopicTypeProvider
self,
fclient: Client,
node: Node,
topic_type_provider: TopicTypeProvider,
):
self._logger = get_logger()
self._fclient = fclient
Expand All @@ -92,8 +95,12 @@ def publish_command(self, formant_stream, msg: str):
ros2_msg = String()
ros2_msg.data = msg
publisher.publish(ros2_msg)
elif (ros2_msg_type in ROS2_NUMERIC_TYPES) and msg.isnumeric():
self._publish_ros2_numeric(publisher, ros2_msg_type, msg)
elif (
ros2_msg_type in ROS2_NUMERIC_TYPES
) and msg.isnumeric():
self._publish_ros2_numeric(
publisher, ros2_msg_type, msg
)
else:
self._logger.warn(
"Unsupported ROS2 message type for command: %s"
Expand Down Expand Up @@ -128,7 +135,8 @@ def publish(self, formant_stream, msg):
ros2_msg.data = str(msg_value)
else:
self._logger.warn(
"Unsupported ROS2 message type for bitset: %s" % ros2_msg_type
"Unsupported ROS2 message type for bitset: %s"
% ros2_msg_type
)
continue

Expand All @@ -145,7 +153,9 @@ def publish(self, formant_stream, msg):
elif ros2_msg == "PointStamped":
ros2_msg = PointStamped(point=point)
else:
self._logger.warn("Unsupported Point Type: %s" % ros2_msg_type)
self._logger.warn(
"Unsupported Point Type: %s" % ros2_msg_type
)
publisher.publish(ros2_msg)

elif msg.HasField("pose"):
Expand Down Expand Up @@ -183,10 +193,16 @@ def publish(self, formant_stream, msg):
]
else:
self._logger.warn(
"Unsupported ROS2 message type for twist: %s" % ros2_msg_type
"Unsupported ROS2 message type for twist: %s"
% ros2_msg_type
)
continue

publisher.publish(ros2_msg)
elif msg.HasField("joy"):
ros2_msg = Joy()
ros2_msg.header = Header()
ros2_msg.axes = msg.joy.axes
ros2_msg.buttons = msg.joy.buttons
publisher.publish(ros2_msg)

def _publish_ros2_numeric(
Expand Down
2 changes: 1 addition & 1 deletion formant_ros2_adapter/scripts/converters/pointcloud2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
DOUBLE_DATA_TYPE = 8

logger = logging.getLogger("formant_ros2_adapter")
logger.setLevel(logging.DEBUG)
logger.setLevel(logging.INFO)


def ros2_pointcloud2_to_formant_pointcloud(message: PointCloud2) -> PointCloud:
Expand Down
2 changes: 1 addition & 1 deletion formant_ros2_adapter/scripts/ros2_utils/message_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


logger = logging.getLogger("formant_ros2_adapter")
logger.setLevel(logging.DEBUG)
logger.setLevel(logging.INFO)


def get_ros2_type_from_string(message_type_string: str):
Expand Down
2 changes: 1 addition & 1 deletion formant_ros2_adapter/scripts/utils/logger.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

logger = logging.getLogger("formant_ros2_adapter")
logger.setLevel(logging.DEBUG)
logger.setLevel(logging.INFO)


def get_logger():
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
numpy>=1.19.3
formant>=1.114.39
formant>=1.177.11
jsonschema
python-lzf
opencv-python

0 comments on commit 5cac23e

Please sign in to comment.