<jupyter_start><jupyter_text>VisualsThe `` element specifies the shape of the geometry for rendering. It is a child element from `` and a link can have multiple visual elements.<jupyter_code># Import the element creator
from pcg_gazebo.parsers.sdf import create_sdf_element
# The visual element is created with an empty geometry by default
visual = create_sdf_element('visual')
print(visual)
# To see the optional elements, use the method reset()
visual.reset(with_optional_elements=True)
print(visual)
# Setting the parameters for the visual element

# Each visual in a link should have an unique name
visual.name = 'custom_visual'
# If cast_shadows is true, the geometry will cast shadows
visual.cast_shadows = True
# The transparency is a double in the range of [0, 1], 0 being opaque and 1 fully transparent
visual.transparency = 0.2
# Pose of the visual geometry with respect to a frame
visual.pose = [0, 0.2, 0, 0, 0, 0]
visual.pose.frame = 'base_link'

print(visual)
# Setting different geometries to the visual element
visual.geometry.box = create_sdf_element('box')
print(visual)
visual.geometry.sphere = create_sdf_element('sphere')
print(visual)
visual.geometry.cylinder = create_sdf_element('cylinder')
print(visual)
visual.geometry.plane = create_sdf_element('plane')
print(visual)
visual.geometry.mesh = create_sdf_element('mesh')
visual.geometry.mesh.reset(with_optional_elements=True)
print(visual)
visual.geometry.image = create_sdf_element('image')
print(visual)
visual.geometry.polyline = create_sdf_element('polyline')
print(visual)
# Optional elements can also be created dynamically
visual = create_sdf_element('visual')
print(visual)
visual.cast_shadows = True
print(visual)

visual.pose = [0, 0.2, 0, 0, 0, 0]
print(visual)
# The geometry entity can be set with a dictionary with all the child parameters
visual.geometry.box = dict(size=[2, 3, 4])
print(visual)
# The pose, as other variables, can be set using a dictionary
# For SDF elements with no child elements, only values, the dictionary must always have a key 'value'
#      d = {value=[0, 0, 0, 0, 0, 0]}
# If the element contains attributes, as the attribute 'frame' in the element 'pose', there should be a key
# 'attributes' with a dictionary containing all the attributes
#      d = {value=[0, 0, 0, 0, 0, 0], attributes=dict(frame='new_frame')}
visual.pose = {'value': [0, 0.2, 0, 0, 0, 0], 'attributes': {'frame': 'new_frame'}}
print(visual)<jupyter_output><visual name="visual">
  <geometry>
    <box>
      <size>2 3 4</size>
    </box>
  </geometry>
  <cast_shadows>1</cast_shadows>
  <pose frame="new_frame">0 0.2 0 0 0 0</pose>
</visual>
{'fraction_non_alphanumeric': 0.11098441657164576, 'fraction_numerical': 0.020144431774990496, 'mean_word_length': 5.40389294403893, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '2995', 'license': 'ECL-2.0', 'n_tokens_mistral': 901, 'n_tokens_neox': 812, 'n_words': 294, 'path': 'examples/sdf_parser_visuals.ipynb', 'repo_name': 'argenos/pcg_gazebo', 'size': '2631'}