|
145 | 145 | # Seconds
|
146 | 146 | SERVICE_CALL_TIMEOUT = 5
|
147 | 147 |
|
| 148 | +BASE_REFERENCE_FRAME = os.getenv("FORMANT_BASE_REFERENCE_FRAME","base_link") |
| 149 | + |
148 | 150 |
|
149 | 151 | class ROS2Adapter:
|
150 | 152 | """
|
@@ -1041,45 +1043,30 @@ def handle_ros2_message(self, msg, subscriber_config):
|
1041 | 1043 | timestamp=msg_timestamp,
|
1042 | 1044 | )
|
1043 | 1045 |
|
1044 |
| - elif msg_type == LaserScan: |
1045 |
| - # Convert LaserScan to a Formant pointcloud |
| 1046 | + elif msg_type == LaserScan or msg_type == PointCloud2: |
1046 | 1047 | try:
|
1047 |
| - self.fclient.agent_stub.PostData( |
1048 |
| - Datapoint( |
1049 |
| - stream=formant_stream, |
1050 |
| - point_cloud=FPointCloud.from_ros_laserscan( |
1051 |
| - msg |
1052 |
| - ).to_proto(), |
1053 |
| - tags=subscriber_config["tags"], |
1054 |
| - timestamp=msg_timestamp, |
1055 |
| - ) |
1056 |
| - ) |
1057 |
| - except grpc.RpcError as e: |
1058 |
| - return |
1059 |
| - except Exception as e: |
1060 |
| - print( |
1061 |
| - "ERROR: Could not ingest " + formant_stream + ": " + str(e) |
| 1048 | + formant_point_cloud = None |
| 1049 | + if msg_type == LaserScan: |
| 1050 | + formant_point_cloud = FPointCloud.from_ros_laserscan( |
| 1051 | + msg |
| 1052 | + ) |
| 1053 | + if msg_type == PointCloud2: |
| 1054 | + formant_point_cloud = FPointCloud.from_ros(msg) |
| 1055 | + |
| 1056 | + if formant_point_cloud is None: |
| 1057 | + raise Exception("%s not PointCloud2 or LaserScan" % msg_type) |
| 1058 | + |
| 1059 | + formant_point_cloud.transform_to_world = self.lookup_transform( |
| 1060 | + msg, BASE_REFERENCE_FRAME |
1062 | 1061 | )
|
1063 |
| - return |
1064 |
| - |
1065 |
| - elif msg_type == PointCloud2: |
1066 |
| - try: |
1067 | 1062 | self.fclient.agent_stub.PostData(
|
1068 | 1063 | Datapoint(
|
1069 | 1064 | stream=formant_stream,
|
1070 |
| - point_cloud=FPointCloud.from_ros(msg).to_proto(), |
| 1065 | + point_cloud=formant_point_cloud.to_proto(), |
1071 | 1066 | tags=subscriber_config["tags"],
|
1072 | 1067 | timestamp=msg_timestamp,
|
1073 | 1068 | )
|
1074 | 1069 | )
|
1075 |
| - except grpc.RpcError as e: |
1076 |
| - return |
1077 |
| - except Exception as e: |
1078 |
| - print( |
1079 |
| - "ERROR: Could not ingest " + formant_stream + ": " + str(e) |
1080 |
| - ) |
1081 |
| - return |
1082 |
| - |
1083 | 1070 | else:
|
1084 | 1071 | # Ingest any messages without a direct mapping to a Formant type as JSON
|
1085 | 1072 | self.fclient.post_json(
|
|
0 commit comments