ros / joint_state_publisher

http://wiki.ros.org/joint_state_publisher
50 stars 81 forks source link

encode to utf8 #27

Closed ahoarau closed 4 years ago

ahoarau commented 5 years ago

Fixes by just making sure the description is in utf8 :

  File "/opt/ros/melodic/lib/joint_state_publisher/joint_state_publisher", line 474, in <module>
    jsp = JointStatePublisher()
  File "/opt/ros/melodic/lib/joint_state_publisher/joint_state_publisher", line 149, in __init__
    robot = xml.dom.minidom.parseString(description)
  File "/usr/lib/python2.7/xml/dom/minidom.py", line 1928, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
UnicodeEncodeError: 'ascii' codec can't encode character
sloretz commented 4 years ago

Thanks for the PR! I'm unable to reproduce on the noetic-devel branch.

First I saved the following as pi.urdf:

<?xml version="1.0"?>
<urdf>
  <robot name="π">
    <link name="link1"/>
    <link name="link2"/>

    <joint name="π12" type="revolute">
      <parent link="link1"/>
      <child link="link2"/>
      <limit effort="10" velocity="10" lower="-1" upper="1"/>
    </joint>
  </robot>
</urdf>

Then I set it in the parameter server

$ rosparam set /joint_state_publisher_gui/robot_description -t pi.urdf
$ rosparam get /joint_state_publisher_gui/robot_description
"<?xml version=\"1.0\"?>\n<urdf>\n  <robot name=\"\u03C0\">\n    <link name=\"link1\"\
  />\n    <link name=\"link2\"/>\n\n    <joint name=\"\u03C012\" type=\"revolute\"\
  >\n      <parent link=\"link1\"/>\n      <child link=\"link2\"/>\n      <limit effort=\"\
  10\" velocity=\"10\" lower=\"-1\" upper=\"1\"/>\n    </joint>\n  </robot>\n</urdf>\n"

Finally I loaded the GUI:

$ rosrun joint_state_publisher_gui  joint_state_publisher_gui

It seems to look fine to me. I see π in the joint name in the GUI.

pi_jsp

Since it's been a while and there is a merge conflict, I'll assume this PR is no longer necessary. Would you mind posting steps to reproduce if that's not the case?

ahoarau commented 4 years ago

Sorry I forgot about this one. The issue is when your locales are now all en_US (french and US in my case)

sloretz commented 4 years ago

Sorry I forgot about this one. The issue is when your locales are now all en_US (french and US in my case)

@ahoarau Hmm I'm not sure what this means. Do I need to set any environment variables like LANG or LC_ALL? Would you be willing to open an issue with the steps to reproduce?

chenwenyou commented 4 years ago

urdf01_HelloWorld.urdf.txt

why not run with Chinese?

csj-wenyo@csjwenyo-ThinkPad-T490:~/catkin_ws/src/robotsim/urdf/urdf$ check_urdf urdf01_HelloWorld.urdf.txt robot name is: mycar ---------- Successfully Parsed XML --------------- root Link: base_footprint has 1 child(ren) child(1): base_link child(1): back_wheel child(2): front_wheel child(3): left_wheel child(4): right_wheel csj-wenyo@csjwenyo-ThinkPad-T490:~/catkin_ws/src/robotsim/urdf/urdf$

process[joint_state_publisher_gui-5]: started with pid [17029] Traceback (most recent call last): File "/home/csj-wenyo/catkin_ws/src/joint_state_publisher/joint_state_publisher/scripts/joint_state_publisher", line 42, in jsp = joint_state_publisher.JointStatePublisher() File "/opt/ros/melodic/lib/python2.7/dist-packages/joint_state_publisher/init.py", line 159, in init robot = xml.dom.minidom.parseString(description) File "/usr/lib/python2.7/xml/dom/minidom.py", line 1928, in parseString return expatbuilder.parseString(string) File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString return builder.parseString(string) File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString parser.Parse(string, True) UnicodeEncodeError: 'ascii' codec can't encode characters in position 27-28: ordinal not in range(128) Traceback (most recent call last): File "/home/csj-wenyo/catkin_ws/src/joint_state_publisher/joint_state_publisher_gui/scripts/joint_state_publisher_gui", line 53, in joint_state_publisher.JointStatePublisher(), File "/opt/ros/melodic/lib/python2.7/dist-packages/joint_state_publisher/init.py", line 159, in init robot = xml.dom.minidom.parseString(description) File "/usr/lib/python2.7/xml/dom/minidom.py", line 1928, in parseString return expatbuilder.parseString(string) File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString return builder.parseString(string) File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString parser.Parse(string, True) UnicodeEncodeError: 'ascii' codec can't encode characters in position 27-28: ordinal not in range(128) [joint_state_publisher-4] process has died [pid 17028, exit code 1, cmd /home/csj-wenyo/catkin_ws/src/joint_state_publisher/joint_state_publisher/scripts/joint_state_publisher name:=joint_state_publisher log:=/home/csj-wenyo/.ros/log/83b7df5c-2a2b-11eb-8cfd-58961d963f57/joint_state_publisher-4.log]. log file: /home/csj-wenyo/.ros/log/83b7df5c-2a2b-11eb-8cfd-58961d963f57/joint_state_publisher-4.log [joint_state_publisher_gui-5] process has died [pid 17029, exit code 1, cmd /home/csj-wenyo/catkin_ws/src/joint_state_publisher/joint_state_publisher_gui/scripts/joint_state_publisher_gui __name:=joint_state_publisher_gui __log:=/home/csj-wenyo/.ros/log/83b7df5c-2a2b-11eb-8cfd-58961d963f57/joint_state_publisher_gui-5.log]. log file: /home/csj-wenyo/.ros/log/83b7df5c-2a2b-11eb-8cfd-58961d963f57/joint_state_publisher_gui-5.log