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

add test to check /smach_viewer/image #62

Merged
merged 3 commits into from
Feb 18, 2025

Conversation

k-okada
Copy link
Contributor

@k-okada k-okada commented Feb 13, 2025

It fails on WSL, but not able to reproduce on native Linux machine...

(smach_viewer.py:5590): Gtk-WARNING **: 14:23:59.439: Error loading theme icon 'document-save' for stock: Icon 'document-save' not present in theme Adwaita
[Testcase: testsmach_viewer_test] ... ok

[ROSTEST]-----------------------------------------------------------------------

[smach_viewer.rosunit-smach_viewer_test/test_publish][FAILURE]------------------
Topic [/smach_viewer/image] is not published
  File "/usr/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
    yield
  File "/usr/lib/python3.8/unittest/case.py", line 676, in run
    self._callTestMethod(testMethod)
  File "/usr/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
    method()
  File "/opt/ros/noetic/share/rostest/nodes/publishtest", line 141, in test_publish
    assert ret, 'Topic [%s] is not published' % (checker.topic_name)
--------------------------------------------------------------------------------


here is workaround

commit e2ee0fdd46ccf1b53e1f01d71ff5d0dc5fe36ef7 (HEAD -> fix_pub_image)
Author: Kei Okada <[email protected]>
Date:   Tue Feb 11 18:02:46 2025 +0900

    scirpt/smach_viewer: fix smach_viewer crashes when subscribe smach_viewer/image

diff --git a/smach_viewer/scripts/smach_viewer.py b/smach_viewer/scripts/smach_viewer.py
index 556de5b..c27afb8 100755
--- a/smach_viewer/scripts/smach_viewer.py
+++ b/smach_viewer/scripts/smach_viewer.py
@@ -642,10 +642,11 @@ class SmachViewerFrame(wx.Frame, SmachViewerBase):
         memory.Blit(0, 0, x, y, context, 0, 0)
         memory.SelectObject(wx.NullBitmap)
         if LooseVersion(wx.__version__) >= LooseVersion('4.0'):
-            buf = bitmap.ConvertToImage().GetDataBuffer()
+            buf = bitmap.ConvertToImage().GetData()
+            img = np.array(buf)
         else:
             buf = wx.ImageFromBitmap(bitmap).GetDataBuffer()
-        img = np.frombuffer(buf, dtype=np.uint8)
+            img = np.frombuffer(buf, dtype=np.uint8)
         bridge = cv_bridge.CvBridge()
         img_msg = bridge.cv2_to_imgmsg(img.reshape((y, x, 3)), encoding='rgb8')
         img_msg.header.stamp = rospy.Time.now()

@k-okada k-okada force-pushed the add_test branch 4 times, most recently from 23fd3e3 to bd08698 Compare February 18, 2025 06:58
@k-okada k-okada merged commit 5588ec2 into ros-visualization:melodic-devel Feb 18, 2025
7 checks passed
@k-okada k-okada deleted the add_test branch February 18, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant