Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jsk_pepper_startup] add node to play audio stream from Pepper's ROS audio topic #1073

Merged
merged 6 commits into from
May 1, 2019

Conversation

kochigami
Copy link
Contributor

@kochigami kochigami commented Apr 30, 2019

What is this?

This node enables us to play what Pepper hears by using Pepper's audio ROS topic even if the Pepper's location is far away from us.

Subscribed Topic

  • ~audio (naoqi_bridge_msgs/AudioBuffer)

Services

  • start_subscribe_audio_topic (std_srvs/Empty)
    start playing audio stream

  • stop_subscribe_audio_topic (std_srvs/Empty)
    stop playing audio stream

How to use this?

roslaunch jsk_pepper_startup jsk_pepper_startup.launch network_interface:=xxx launch_play_audio_stream:=true
rosservice call /start_subscribe_audio_topic "{}"  # start playing audio stream
rosservice call /stop_subscribe_audio_topic "{}"  # stop playing audio stream

memo

コールバック関数の中で最初の1回だけトピックのデータを読み込んで,チャンネル数,周波数を設定し,
ストリームを作ろうとしたが,以下のエラーが出てしまった.
そのため.クラスの初期化時にチャンネル数と周波数は決め打ちで値を与えて,ストリームを作ることにした.

コード(抜粋)

def __init__(self):
...(略)
    self.stream_configured = False
...(略)
 def topic_cb(self, msg):
       # execute stream configuration once                                                                                                                                                                 
        if not self.stream_configured:
            # open stream                                                                                                                                                                                   
            self.stream = self.p.open(format=pyaudio.paInt16,
                                      channels=len(msg.channelMap),
                                      rate=msg.frequency,
                                      output=True)
            # start the stream                                                                                                                                                                              
            self.stream.start_stream()
            self.device_configured = True
・・・(略)

エラー

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection terminated

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->playback, alsaApi, outParams, StreamDirection_Out, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2175
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2840
[ERROR] [1556592765.452164]: bad callback: <bound method PlayAudioStream.audio_topic_cb of <PlayAudioStream(Thread-1, initial)>>
Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
    cb(msg)
  File "/home/kanae/catkin_ws/src/xxxxx/scripts/naoqi_play_audio_stream.py", line 41, in audio_topic_cb
    output=True)
  File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 747, in open
    stream = Stream(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 442, in __init__
    self._stream = pa.open(**arguments)
IOError: [Errno Illegal combination of I/O devices] -9993

@kochigami
Copy link
Contributor Author

ログに親しみたいのでメモ.
バクちゃんのmoveitのテストが時間切れで失敗した?
その理由はモデルの読み込みの失敗・・・?

baxtereus/test_results/baxtereus/rostest-test_baxter-moveit.xml: 1 tests, 1 errors, 0 failures, 0 skipped
�[1;31mException [ODELink.cc:376]�[0m Setting custom link baxter::right_upper_forearmmass to zero!

                                                                                
�[1;31mError [World.cc:1666]�[0m Loading model from factory message failed
                                                                                
Segmentation fault (core dumped)
                                                                                
unittest-sigint-handler 2
                                                                                
Traceback (most recent call last):
                                                                                
  File "/home/travis/ros/ws_jsk_robot/src/jsk_robot/jsk_baxter_robot/jsk_baxter_startup/jsk_baxter_tools/initialize_baxter.py", line 41, in <module>
                                                                                
    main()
                                                                                
  File "/home/travis/ros/ws_jsk_robot/src/jsk_robot/jsk_baxter_robot/jsk_baxter_startup/jsk_baxter_tools/initialize_baxter.py", line 27, in main
                                                                                
    baxter_interface.RobotEnable(CHECK_VERSION).enable()
                                                                              
  File "/opt/ros/indigo/lib/python2.7/dist-packages/baxter_interface/robot_enable.py", line 89, in __init__
                                                                                
    (state_topic,)),
                                                                                
  File "/opt/ros/indigo/lib/python2.7/dist-packages/baxter_dataflow/wait_for.py", line 59, in wait_for
                                                                                
    rate.sleep()
                                                                                
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/timer.py", line 99, in sleep
                                                                                
    sleep(self._remaining(curr_time))
                                                                                
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/timer.py", line 157, in sleep
                                                                                
    raise rospy.exceptions.ROSInterruptException("ROS shutdown request")
                                                                                
rospy.exceptions.ROSInterruptException: ROS shutdown request

[0m[ INFO] [1556605917.725812074, 0.317000000]: adding joint: [left_e1]�[0m
                                                                                
�[0m[ INFO] [1556605917.726703322, 0.317000000]: adding joint: [left_e0]�[0m
                                                                                
�[0m[ INFO] [1556605917.727020317, 0.317000000]: adding joint: [left_s1]�[0m
                                                                                
�[0m[ INFO] [1556605917.727546181, 0.317000000]: adding joint: [left_s0]�[0m
                                                                                
�[0m[ INFO] [1556605917.728006559, 0.317000000]: getting bounds for joint: [left_w2]�[0m
                                                                                
�[0m[ INFO] [1556605917.728312719, 0.317000000]: getting bounds for joint: [left_w1]�[0m
                                                                                
�[0m[ INFO] [1556605917.728931055, 0.317000000]: getting bounds for joint: [left_w0]�[0m
                                                                                
�[0m[ INFO] [1556605917.729381795, 0.317000000]: getting bounds for joint: [left_e1]�[0m
                                                                                
�[0m[ INFO] [1556605917.729726074, 0.317000000]: getting bounds for joint: [left_e0]�[0m
                                                                                
�[0m[ INFO] [1556605917.730307727, 0.317000000]: getting bounds for joint: [left_s1]�[0m
                                                                                
�[0m[ INFO] [1556605917.730758314, 0.317000000]: getting bounds for joint: [left_s0]�[0m
                                                                                
[INFO] [WallTime: 1556605918.667731] [0.318000] Calling service /gazebo/set_model_configuration
                                                                                
Service call failed: unable to connect to service: [Errno 111] Connection refused
                                                                                
�[0m[ INFO] [1556605953.149061201, 0.318000000]: Simulator is loaded and started successfully�[0m
                                                                                
[INFO] [WallTime: 1556605953.157742] [0.318000] found /clock & /robot/state
                                                                                
testbaxter_moveit_test ... ERROR!
                                                                                
ERROR: max time [360.0s] allotted for test [baxter_moveit_test] of type [baxtereus/test-baxter-moveit.l]
                                                                                
  File "/usr/lib/python2.7/unittest/case.py", line 331, in run
                                                                                
    testMethod()
                                                                                
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rostest/runner.py", line 148, in fn
                                                                                
    self.test_parent.run_test(test)
                                                                                
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rostest/rostest_parent.py", line 132, in run_test
                                                                                
    return self.runner.run_test(test)
                                                                                
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/launch.py", line 681, in run_test
                                                                                
    (test.time_limit, test.test_name, test.package, test.type))

<?xml version="1.0" encoding="utf-8"?>

<testsuite errors="1" failures="0" name="unittest.suite.TestSuite" tests="1" time="968.369">

  <testcase classname="rostest.runner.RosTest" name="testbaxter_moveit_test" time="968.3685">

    <error type="RLTestTimeoutException">max time [360.0s] allotted for test [baxter_moveit_test] of type [baxtereus/test-baxter-moveit.l]

  File "/usr/lib/python2.7/unittest/case.py", line 331, in run

    testMethod()

  File "/opt/ros/indigo/lib/python2.7/dist-packages/rostest/runner.py", line 148, in fn

    self.test_parent.run_test(test)

  File "/opt/ros/indigo/lib/python2.7/dist-packages/rostest/rostest_parent.py", line 132, in run_test

    return self.runner.run_test(test)

  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/launch.py", line 681, in run_test

    (test.time_limit, test.test_name, test.package, test.type))

    </error>

  </testcase>

  <system-out><![CDATA[[ROSTEST]setup[/home/travis/ros/ws_jsk_robot/src/jsk_robot/jsk_baxter_robot/baxtereus/test/baxter-moveit.test] run_id[f5552f20-6b0f-11e9-aeec-0242ac110002] starting

?[1mstarted roslaunch server http://7b8fad01cc8b:33274/?[0m

@pazeshun
Copy link
Contributor

First try dies due to the following error:

Traceback (most recent call last):



                                                                                
  File "/opt/ros/indigo/lib/baxter_interface/joint_trajectory_action_server.py", line 110, in <module>



                                                                                
    main()



                                                                                
  File "/opt/ros/indigo/lib/baxter_interface/joint_trajectory_action_server.py", line 106, in main




                                                                                
    start_server(args.limb, args.rate, args.mode)



                                                                                
  File "/opt/ros/indigo/lib/baxter_interface/joint_trajectory_action_server.py", line 73, in start_server



                                                                                
    rate, mode))



                                                                                
  File "/opt/ros/indigo/lib/python2.7/dist-packages/joint_trajectory_action/joint_trajectory_action.py", line 72, in __init__




                                                                                
    self._limb = baxter_interface.Limb(limb)



                                                                                
  File "/opt/ros/indigo/lib/python2.7/dist-packages/baxter_interface/limb.py", line 121, in __init__




                                                                                
    timeout_msg=err_msg)



                                                                                
  File "/opt/ros/indigo/lib/python2.7/dist-packages/baxter_dataflow/wait_for.py", line 55, in wait_for



                                                                                
    raise OSError(errno.ETIMEDOUT, timeout_msg)



                                                                                
OSError: [Errno 110] Right limb init failed to get current joint_states from robot/joint_states

I don't know the reason of this error, and I'm not sure why the tries followed failed...
@kochigami Could you restart test?

@kochigami kochigami closed this Apr 30, 2019
@kochigami kochigami reopened this Apr 30, 2019
@kochigami kochigami changed the title [jsk_pepper_startup] add node to play audio stream from Pepper's ROS audio topic [WIP] [jsk_pepper_startup] add node to play audio stream from Pepper's ROS audio topic Apr 30, 2019
@k-okada k-okada merged commit afe25cf into jsk-ros-pkg:master May 1, 2019
@kochigami kochigami deleted the add-play-audio-stream branch May 1, 2019 07:54
@kochigami kochigami changed the title [WIP] [jsk_pepper_startup] add node to play audio stream from Pepper's ROS audio topic [jsk_pepper_startup] add node to play audio stream from Pepper's ROS audio topic May 1, 2019
@kochigami
Copy link
Contributor Author

メモ:

音声のストリーミングは,勝手にやると良くないと思うので,rvizで該当のノードが立ち上がっている時に分かるようにした.(写真の赤字)
rvizの設定ファイルは準備中.

jsk_rviz_plugins/OverlayText.msg を使って,
Screenshot from 2019-05-01 11-22-39

# nodelist_tmp: ('/pepper_1556630474468299832\n/rosout\n', None)
nodelist=nodelist_tmp[0]
# nodelist: '/pepper_1556630474468299832\n/rosout\n'
nodelist=nodelist.split("\n")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このnodelistの中にnaoqi_driver_nodeが含まれていなかったら、/pepper_robot/pose/pose_controllerを落とす
#1077 が解決する

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants