5 from sensor_msgs.msg
import CompressedImage, Image, CameraInfo
6 from sensor_msgs.msg
import Range
7 from sensor_msgs.msg
import Imu
8 from std_msgs.msg
import String
9 from audio_common_msgs.msg
import AudioData, AudioDataStamped, AudioInfo
10 from cv_bridge
import CvBridge, CvBridgeError
13 from nicla_vision_ros
import NiclaReceiverUDP, NiclaReceiverTCP
22 nicla_name = rospy.get_param(
"~nicla_name",
"nicla")
26 ip = rospy.get_param(
"~receiver_ip")
27 port = rospy.get_param(
"~receiver_port",
"8002")
28 connection_type = rospy.get_param(
"~connection_type",
"udp")
33 "~enable_camera_compressed",
False
37 "~enable_audio_stamped",
False
40 "~enable_audio_recognition_vosk",
False
43 "~audio_recognition_model_path",
""
46 "~audio_recognition_grammar",
""
49 "~audio_recognition_listen_seconds", 2
52 "~audio_recognition_wave_output_filename",
""
57 range_topic = nicla_name +
"/tof"
58 self.
range_pub = rospy.Publisher(range_topic, Range, queue_size=5)
60 self.
range_msg.header.frame_id = nicla_name +
"_tof"
61 self.
range_msg.radiation_type = Range.INFRARED
79 nicla_name +
"/camera/image_raw/compressed"
92 camera_info_topic = nicla_name +
"/camera/camera_info"
131 camera_info_topic, CameraInfo, queue_size=5
135 audio_topic = nicla_name +
"/audio"
138 audio_topic, AudioData, queue_size=10
142 audio_stamped_topic = nicla_name +
"/audio_stamped"
145 audio_stamped_topic, AudioDataStamped, queue_size=10
149 audio_info_topic = nicla_name +
"/audio_info"
157 audio_info_topic, AudioInfo, queue_size=1
161 imu_topic = nicla_name +
"/imu"
163 self.
imu_msg.header.frame_id = nicla_name +
"_imu"
168 self.
imu_pub = rospy.Publisher(imu_topic, Imu, queue_size=5)
170 if connection_type ==
"udp":
180 elif connection_type ==
"tcp":
192 rospy.logerr(
"Connection type ", connection_type,
" not known")
193 raise Exception(
"Connection type not known")
198 "Path for VOSK recognizer model is an empty string! Please provide 'audio_recognition_model_path' arg"
202 from nicla_vision_ros
import SpeechRecognizer
211 nicla_name +
"/audio_recognized", String, queue_size=10
222 self.
range_msg.header.stamp = rospy.Time.from_sec(range[0])
223 self.
range_msg.range = int.from_bytes(range[1],
"little") / 1000
242 rospy.Time.from_sec(image[0])
248 img_raw, dst_format=
"jpg"
251 except CvBridgeError
as e:
276 img_raw, encoding=
"bgr8"
278 except CvBridgeError
as e:
319 self.
imu_msg.header.stamp = rospy.Time.from_sec(imu[0])
322 acc_x, acc_y, acc_z, gyro_x, gyro_y, gyro_z = struct.unpack(
325 except Exception
as e:
326 rospy.logerr(
"imu pack has ", len(imu[1]),
" bytes")
329 self.
imu_msg.angular_velocity.x = 0.017453 * gyro_x
330 self.
imu_msg.angular_velocity.y = 0.017453 * gyro_y
331 self.
imu_msg.angular_velocity.z = 0.017453 * gyro_z
332 self.
imu_msg.linear_acceleration.x = 9.80665 * acc_x
333 self.
imu_msg.linear_acceleration.y = 9.80665 * acc_y
334 self.
imu_msg.linear_acceleration.z = 9.80665 * acc_z