Stretch-robot not working with ros_respeaker package

Following the instructions here (ROS Index), I installed the respeaker_ros package. However, whenever I run

   roslaunch respeaker_ros sample_respeaker.launch

I get this error

**process[respeaker_node-2]: started with pid [12862]**

[WARN] [1619819447.432986]: Failed to find respeaker device by name. Using default input

[WARN] [1619819447.434782]: 32 channel is found for respeaker

[WARN] [1619819447.436162]: You may have to update firmware.

**[respeaker_node-2] process has finished cleanly**

**log file: /home/hello-robot/.ros/log/d97c2426-a9fa-11eb-86ad-94e6f7b7f4ad/respeaker_node-2*.log**

[respeaker_node-2] restarting process

**process[respeaker_node-2]: started with pid [13088]**

Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1736

Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1904

Expression 'PaAlsaStreamComponent_Initialize( &self->capture, alsaApi, inParams, StreamDirection_In, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2171

Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2840

Traceback (most recent call last):

File "/opt/ros/melodic/share/respeaker_ros/scripts/respeaker_node.py", line 428, in <module>

n = RespeakerNode()

File "/opt/ros/melodic/share/respeaker_ros/scripts/respeaker_node.py", line 323, in __init__

self.respeaker_audio = RespeakerAudio(self.on_audio, suppress_error=suppress_pyaudio_error)

File "/opt/ros/melodic/share/respeaker_ros/scripts/respeaker_node.py", line 259, in __init__

input_device_index=self.device_index,

File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 750, in open

stream = Stream(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 441, in __init__

self._stream = pa.open(**arguments)

IOError: [Errno -9985] Device unavailable

[respeaker_node-2] process has died [pid 13088, exit code 1, cmd /opt/ros/melodic/share/respeaker_ros/scripts/respeaker_node.py __name:=respeaker_node __log:=/home/hello-robot/.ros/log/d97c2426-a9fa-11eb-86ad-94e6f7b7f4ad/respeaker_node-2.log].

log file: /home/hello-robot/.ros/log/d97c2426-a9fa-11eb-86ad-94e6f7b7f4ad/respeaker_node-2*.log

[respeaker_node-2] restarting process

I’m not sure why this is happening - I’ve updated the firmware multiple times. What makes this more curious is that the first time I ran this it worked but it no longer works now.

Hi @Robot_Lover, thank you for reporting the issue. Would you provide me with the respeaker_ros installation, and firmware upgrade steps you’ve used? Additionally, let me know if the Respeaker tool described in “Using the stretch-robot speaker - #2 by bshah” works for you (which lets us know if we can use the Respeaker outside of ROS).

Hi! I’ll get back to you on testing the speaker outside ROS but this is what I did to test the speaker in ROS.
I followed the instructions on this link: ROS Index

Specifically, I installed it with

    sudo apt-get install ros-$ROS_DISTRO-respeaker-ros

then ran the following lines of code

roscd respeaker_ros
    sudo cp -f $(rospack find respeaker_ros)/config/60-respeaker.rules /etc/udev/rules.d/60-respeaker.rules
    sudo systemctl restart udev

to install the setting file and then to update the firmware I ran this:

 git clone https://github.com/respeaker/usb_4_mic_array.git
 cd usb_4_mic_array
 sudo python dfu.py --download 6_channels_firmware.bin  # The 6 channels version 

Hello @Robot_Lover, I believe the issue comes from the USB rules you’ve installed. Stretch comes with all the Respeaker installation set up, including installing the respeaker-ros package, flashing the firmware, and copying over USB rules. In your set up, installing the ROS package and flashing the firmware again should have no adverse effect. However, having two sets of Respeaker USB rules in the /etc/udev/rules.d/ folder might be the reason why the Respeaker is unable to be found. Please remove the “60-respeaker.rules” file from that folder. Then restart the robot.

$ sudo rm /etc/udev/rules.d/60-respeaker.rules
$ sudo reboot

If this does not resolve the issue you’re facing with running the “sample_respeaker.launch” file, please report what is returned as output from the following commands:

$ cat /proc/asound/cards
$ ll /dev/hello-respeaker