Skip to content

Comments

[roseus_smach] fix T/NIL pickling to visualize userdata with smach_viewer#757

Open
mqcmd196 wants to merge 7 commits intojsk-ros-pkg:masterfrom
mqcmd196:smach-bool-python3-pickle
Open

[roseus_smach] fix T/NIL pickling to visualize userdata with smach_viewer#757
mqcmd196 wants to merge 7 commits intojsk-ros-pkg:masterfrom
mqcmd196:smach-bool-python3-pickle

Conversation

@mqcmd196
Copy link
Member

@mqcmd196 mqcmd196 commented Mar 5, 2025

smach_viewer cannot visualize userdata with T/NIL in current roseus_smach pickle implementation. I don't know whether I should fix roseus_smach or smach_viewer, but at least this patch works with the current smach_viewer .

Is #755 needed to test this?

@mqcmd196
Copy link
Member Author

mqcmd196 commented Mar 6, 2025

You can test this like

terminal 1

roscore

terminal 2

rosrun smach_viewer smach_viewer.py

terminal 3

rosrun roseus_smach state-machine-ros-sample.l --args '(exec-smach-userdata-bool)'

Without 9289e6a,

2025-03-06.134043.mp4

@mqcmd196
Copy link
Member Author

mqcmd196 commented Mar 6, 2025

I'm unsure whether the T/NIL in userdata worked with the current master even in Python2 environment

@knorth55
Copy link
Member

knorth55 commented Mar 6, 2025

@mqcmd196
Copy link
Member Author

mqcmd196 commented Mar 6, 2025

Without 9289e6a and check the topic.

❯ rostopic echo /server_name/smach/container_status
header:
  seq: 1
  stamp:
    secs: 1741250867
    nsecs: 548039983
  frame_id: ''
path: "/SM_ROOT"
initial_states:
  - FOO
active_states:
  - FOO
local_data: "(dS'BAR-EXECUTED'\n(ds."
info: ''
---
header:
  seq: 2
  stamp:
    secs: 1741250868
    nsecs: 548400903
  frame_id: ''
path: "/SM_ROOT"
initial_states:
  - FOO
active_states:
  - BAR
local_data: "(dS'BAR-EXECUTED'\n(ds."
info: ''
---
[ERROR][1741250869.550061][/rostopic_228589_1741250864372:rosout]: Characters replaced when decoding message smach_msgs/SmachContainerStatus (will print only once): 'utf-8' codec can't decode byte 0x88 in position 18: invalid start byte
header:
  seq: 3
  stamp:
    secs: 1741250869
    nsecs: 548414211
  frame_id: ''
path: "/SM_ROOT"
initial_states:
  - FOO
active_states:
  - FOO
local_data: "(dS'BAR-EXECUTED'\n\uFFFDs."
info: ''
---
header:
  seq: 4
  stamp:
    secs: 1741250870
    nsecs: 548487150
  frame_id: ''
path: "/SM_ROOT"
initial_states:
  - FOO
active_states: []
local_data: "(dS'BAR-EXECUTED'\n\uFFFDs."
info: ''
---

The local_data is regarded as invalid when decoded with 'utf-8'.

I confirmed there are no errors in the melodic environment.

@mqcmd196
Copy link
Member Author

mqcmd196 commented Mar 6, 2025

Just note for me and prediction.

Both

2.irteusgl$ #x88
136
3.irteusgl$ #x89
137

overs ASCII range.

I think the message loses the original byte info when converted to a Python ROS message. The error log is generated at https://github.com/ros/genpy/blob/f70658f2200dfb7c98e99e9cf15be61cfaa1a432/src/genpy/message.py#L91 .

Maybe there are two options:
Use base64 in Python3, or merge this PR? (I have confirmed that this PR works in a melodic environment.)

@mqcmd196 mqcmd196 force-pushed the smach-bool-python3-pickle branch from 3b95687 to 68e154e Compare March 12, 2025 07:40
@mqcmd196 mqcmd196 force-pushed the smach-bool-python3-pickle branch from 68e154e to 75f6446 Compare March 12, 2025 07:41
@mqcmd196 mqcmd196 requested a review from Copilot April 6, 2025 04:18

This comment was marked as off-topic.

@mqcmd196
Copy link
Member Author

mqcmd196 commented May 2, 2025

hmm, ?

[roseus_smach:make] Traceback (most recent call last):
  
                                                                                  
  [roseus_smach:make]   File "/opt/ros/indigo/share/rostest/cmake/../../../bin/rostest", line 36, in <module>
  
                                                                                  
  [roseus_smach:make]     rostestmain()
  
                                                                                  
  [roseus_smach:make]   File "/opt/ros/indigo/lib/python2.7/dist-packages/rostest/__init__.py", line 274, in rostestmain
  
  
                                                                                  
  [roseus_smach:make]     _main()
  
                                                                                  
  [roseus_smach:make]   File "/opt/ros/indigo/lib/python2.7/dist-packages/rostest/rostest_main.py", line 159, in rostestmain
  
                                                                                  
  [roseus_smach:make]     testCase = rostest.runner.createUnitTest(pkg, test_file, options.reuse_master, options.clear, options.results_base_dir)
  
                                                                                  
  [roseus_smach:make]   File "/opt/ros/indigo/lib/python2.7/dist-packages/rostest/runner.py", line 229, in createUnitTest
  
                                                                                  
  [roseus_smach:make]     config = roslaunch.parent.load_config_default([test_file], None)
  
                                                                                  
  [roseus_smach:make]   File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/config.py", line 453, in load_config_default
  
  
                                                                                  
  [roseus_smach:make]     raise RLException(e)
  
  
                                                                                  
  [roseus_smach:make] roslaunch.core.RLException: Invalid <arg> tag: environment variable 'ROS_PYTHON_VERSION' is not set. 
  
                                                                                  
  [roseus_smach:make] 
  
                                                                                  
  [roseus_smach:make] Arg xml is <arg default="$(env ROS_PYTHON_VERSION)" name="_python_version"/>
  
  
                                                                                  
  [roseus_smach:make] Cannot find results, writing failure results to '/github/home/ros/ws_jsk_roseus/build/roseus_smach/test_results/roseus_smach/MISSING-rostest-test_test_unpickle_userdata.xml'

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.

2 participants