Skip to content

Commit b997aca

Browse files
committed
add teleop handler log
1 parent 6f2f958 commit b997aca

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

formant_ros2_adapter/scripts/components/formant_control/formant_control.py

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,31 @@ def setup_with_config(
4848
self._logger.info("Set up Formant Control")
4949

5050
def _handle_teleop(self, msg):
51-
stream_name = msg.stream
52-
self._logger.info("Teleop message received: %s" % stream_name)
53-
if stream_name == "Buttons":
54-
stream_name = msg.bitset.bits[0].key
55-
self._publisher_coodinator.generic_publisher.publish(stream_name, msg)
56-
57-
if stream_name == self._localization_stream:
58-
try:
59-
self._publisher_coodinator.localization_publisher.publish_goal(msg.pose)
60-
except Exception as e:
61-
self._logger.warn("Error publishing goal: %s" % e)
62-
63-
service_param = None
64-
if msg.HasField("bitset"):
65-
if msg.bitset.bits[0].value is True:
66-
service_param = "True"
67-
elif msg.HasField("numeric"):
68-
service_param = msg.numeric.value
69-
if service_param is not None:
70-
self._service_coordinator.call_service(stream_name, service_param)
51+
try:
52+
stream_name = msg.stream
53+
self._logger.info("Teleop message received: %s" % stream_name)
54+
if stream_name == "Buttons":
55+
stream_name = msg.bitset.bits[0].key
56+
self._publisher_coodinator.generic_publisher.publish(stream_name, msg)
57+
58+
if stream_name == self._localization_stream:
59+
try:
60+
self._publisher_coodinator.localization_publisher.publish_goal(
61+
msg.pose
62+
)
63+
except Exception as e:
64+
self._logger.warn("Error publishing goal: %s" % e)
65+
66+
service_param = None
67+
if msg.HasField("bitset"):
68+
if msg.bitset.bits[0].value is True:
69+
service_param = "True"
70+
elif msg.HasField("numeric"):
71+
service_param = msg.numeric.value
72+
if service_param is not None:
73+
self._service_coordinator.call_service(stream_name, service_param)
74+
except Exception as e:
75+
self._logger.warn("Error in teleop callback: %s" % str(e))
7176

7277
def _handle_command(self, msg):
7378
self._logger.info("Command received %s" % str(msg))

0 commit comments

Comments
 (0)