0

Pretty sure this is a question where I'm missing something simple/basic.

I recently upgraded pydrake to 1.32. When exporting the Diagram to SVG, it marks deprecated ports with the tombstone emoji, '\U0001faa6' . Something in the pydot pipeline is choosing to use ascii instead of unicode, and it's crashing my script.

Here's the offending line:

pydot.graph_from_dot_data(diagram.GetGraphvizString())[0].create_svg("diagram.svg")

I'm getting this UnicodeEncodeError:

'ascii' codec can't encode character '\U0001faa6' in position 1087: ordinal not in range(128)
  File [redacted], line 114, in make_diagram
    pydot.graph_from_dot_data(diagram.GetGraphvizString())[0].create_svg("diagram.svg")
  File [redacted], line 188, in <module>
    diagram, diagram_context, loggers = make_diagram()
                                        ^^^^^^^^^^^^^^
UnicodeEncodeError: 'ascii' codec can't encode character '\U0001faa6' in position 1087: ordinal not in range(128)

I've looked around to see if pydot has arguments where I can ask it to use unicode instead of ascii, but wasn't able to find anything.

I'm on Mac OS Sonoma 14.5. I've seen the tombstones appear previously on my linux machine, but not on my Mac, so I suspected it was something with my install. I updated pydot,graphviz on pip , but that hasn't fixed the problem.

Other stackoverflow posts I looked at:

2 Answers 2

0

Running the following code

from pydrake.all import MultibodyPlant
import pydot

plant = MultibodyPlant(0.0)
plant.Finalize()

pydot.graph_from_dot_data(plant.GetGraphvizString())[0].write_svg("test.svg")
  • linux, Drake master branch, pydot v2.0.0: works fine. I see the warning and the tombstones.
  • mac, Drake v1.32.0, pydot v3.0.1: works fine. I see the warning and the tombstones.
6
  • Thanks for the quick reply. I can confirm that your MWE works on my end exactly as you describe. I've narrowed the culprit down to something in my robot's SDF file - swapping it out for a different robot SDF file makes this unicode problem disappear.
    – fhk
    Commented Aug 18 at 3:43
  • Update: the problem disappears and reappears when i un/comment out my .vtk tetmeshes for rigid hydroelastic contact from my SDF. There are other compliant hydroelastic collision bodies in the scene, but they don't use .vtk files.
    – fhk
    Commented Aug 18 at 4:22
  • Please share a MWE with the issue if you have it. Commented Aug 18 at 12:30
  • Yep! I've put up an MWE with data here: github.com/felix-h-kong/drake-1.32-unicode-issue-mwe. I've also found that the error occurs when using AddMultibodySceneGraph, but not with the MultibodyPlant constructor. See the repo. Thanks for having a look :) EDIT: sorry for the re-comment, I'm new to stackoverflow!
    – fhk
    Commented Aug 19 at 6:52
  • I am able to reproduce the bug using your reproduction (even on ubuntu using Drake's master branch). Thank you. Can you please open an issue with that reproduction? Commented Aug 19 at 11:19
0

The following "raw" Graphviz code & the svg:cairo driver produce the desired result. Note the different encoding.
dot -T svg:cairo myFile.gv >myFile.svg

digraph U {

/******************************************************************
see also:
https://forum.graphviz.org/t/how-to-enter-certain-utf-8-characters/1352/2
******************************************************************/
  test  [label=<&#x01faa6;>]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.