jsk-ros-pkg / jsk_3rdparty

42 stars 60 forks source link

[respeaker_ros] importing does not succeed #477

Closed soonhyo closed 1 year ago

soonhyo commented 1 year ago

Currently, roslaunch respeaker_ros sample_respeaker.launch does not work on melodic, Python 2.7.17:

$ roslaunch respeaker_ros sample_respeaker.launch
... logging to /home/s-kim/.ros/log/527508b6-08f4-11ee-be1d-8cdcd433896d/roslaunch-hirovision-29439.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://133.11.216.127:37411/

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.13
 * /speech_to_text/language: en-US
 * /speech_to_text/self_cancellation: True
 * /speech_to_text/tts_tolerance: 0.5

NODES
  /
    respeaker_node (respeaker_ros/respeaker_node.py)
    sound_play (sound_play/soundplay_node.py)
    speech_to_text (respeaker_ros/speech_to_text.py)
    static_transformer (tf/static_transform_publisher)

auto-starting new master
process[master]: started with pid [29451]
ROS_MASTER_URI=http://hirovision:11311

setting /run_id to 527508b6-08f4-11ee-be1d-8cdcd433896d
process[rosout-1]: started with pid [29463]
started core service [/rosout]
process[static_transformer-2]: started with pid [29467]
process[respeaker_node-3]: started with pid [29476]
process[sound_play-4]: started with pid [29477]
process[speech_to_text-5]: started with pid [29478]
Traceback (most recent call last):
  File "/home/s-kim/hiro_ws/src/jsk_3rdparty/respeaker_ros/scripts/respeaker_node.py", line 201, in <module>
    n = RespeakerNode()
  File "/home/s-kim/hiro_ws/src/jsk_3rdparty/respeaker_ros/scripts/respeaker_node.py", line 79, in __init__
    self.respeaker = RespeakerInterface()
  File "<string>", line 55, in __init__
NameError: global name 'usb' is not defined
Traceback (most recent call last):
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/core.py", line 572, in signal_shutdown
    h()
  File "/home/s-kim/hiro_ws/src/jsk_3rdparty/respeaker_ros/scripts/respeaker_node.py", line 106, in on_shutdown
    self.info_timer.shutdown()
AttributeError: 'RespeakerNode' object has no attribute 'info_timer'
Exception in thread Thread-5 (most likely raised during interpreter shutdown):[respeaker_node-3] process has died [pid 29476, exit code 1, cmd /home/s-kim/hiro_ws/devel/lib/respeaker_ros/respeaker_node.py __name:=respeaker_node __log:=/home/s-kim/.ros/log/527508b6-08f4-11ee-be1d-8cdcd433896d/respeaker_node-3.log].
log file: /home/s-kim/.ros/log/527508b6-08f4-11ee-be1d-8cdcd433896d/respeaker_node-3*.log
^C[speech_to_text-5] killing on exit
[sound_play-4] killing on exit
[respeaker_node-3] killing on exit
[static_transformer-2] killing on exit
^C[rosout-1] killing on exit
^C^C[master] killing on exit
^C^Cshutting down processing monitor...
... shutting down processing monitor complete
done

This seems due to https://github.com/jsk-ros-pkg/jsk_3rdparty/commit/4ea7e8bfa5332999628a531c8d3fa0be2ac02601 and this PR fixes the error by moving all import into __init__.py. But I'm not sure this is a correct way to fix.

mqcmd196 commented 1 year ago

Nice catch. Importing modules are missing in __init__.py when migrating.

But I'm not sure this is a correct way to fix.

I think it's the correct way.

mqcmd196 commented 1 year ago

test failes

 Error: ker_ros:make] [respeaker_ros.rosunit-ros_rospy_node/test_rosnode][ERROR]----------------------

  [respeaker_ros:make] cannot import name usb_pixel_ring_v1

  [respeaker_ros:make]   File "/usr/lib/python2.7/unittest/case.py", line 329, in run

  [respeaker_ros:make]     testMethod()

  [respeaker_ros:make]   File "/github/home/ros/ws_jsk_3rdparty/src/jsk_3rdparty/respeaker_ros/test/test_rospy_node.py", line 34, in test_rosnode

  [respeaker_ros:make]     exec(open(filename, encoding='utf-8').read()) in globals(), locals()

  [respeaker_ros:make]   File "<string>", line 5, in <module>

  [respeaker_ros:make]   File "/github/home/ros/ws_jsk_3rdparty/src/jsk_3rdparty/respeaker_ros/src/respeaker_ros/__init__.py", line 25, in <module>

  [respeaker_ros:make]     from pixel_ring import usb_pixel_ring_v2

  [respeaker_ros:make]   File "/github/home/ros/ws_jsk_3rdparty/devel/.private/respeaker_ros/share/respeaker_ros/venv/lib/python2.7/site-packages/pixel_ring/__init__.py", line 3, in <module>

  [respeaker_ros:make]     from . import usb_pixel_ring_v1

  [respeaker_ros:make] --------------------------------------------------------------------------------

  [respeaker_ros:make] 

  [respeaker_ros:make] 

  [respeaker_ros:make] SUMMARY

  [respeaker_ros:make]  * RESULT: FAIL

  [respeaker_ros:make]  * TESTS: 1

  [respeaker_ros:make]  * ERRORS: 1

  [respeaker_ros:make]  * FAILURES: 0
k-okada commented 1 year ago

@soonhyo I am very very sorry to commit wrong code and thanks for your fix. I have cahnged test code and confirmed that they passed CI #478