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

Fix spawn_model for Python 3 #810

Merged
merged 2 commits into from
Oct 10, 2019
Merged

Fix spawn_model for Python 3 #810

merged 2 commits into from
Oct 10, 2019

Conversation

kartikmohta
Copy link
Contributor

@kartikmohta kartikmohta commented Aug 30, 2018

A recent fix (#449) seems to have broken the spawn_model script when using Python 3. This is caused due to the xml.etree.ElementTree.tostring function returning a bytestring in Python 3 while the following code expects a string.

Here is the error I received:

Traceback (most recent call last):
  File "/opt/ros/melodic/lib/gazebo_ros/spawn_model", line 233, in <module>
    exit_code = sm.run()
  File "/opt/ros/melodic/lib/gazebo_ros/spawn_model", line 179, in run
    self.args.gazebo_namespace)
  File "/opt/ros/melodic/lib/python3.7/site-packages/gazebo_ros/gazebo_interface.py", line 33, in spawn_urdf_model_client
    resp = spawn_urdf_model(model_name, model_xml, robot_namespace, initial_pose, reference_frame)
  File "/opt/ros/melodic/lib/python3.7/site-packages/rospy/impl/tcpros_service.py", line 439, in __call__
    return self.call(*args, **kwds)
  File "/opt/ros/melodic/lib/python3.7/site-packages/rospy/impl/tcpros_service.py", line 516, in call
    transport.send_message(request, self.seq)
  File "/opt/ros/melodic/lib/python3.7/site-packages/rospy/impl/tcpros_base.py", line 668, in send_message
    serialize_message(self.write_buff, seq, msg)
  File "/opt/ros/melodic/lib/python3.7/site-packages/rospy/msg.py", line 152, in serialize_message
    msg.serialize(b)
  File "/opt/ros/melodic/lib/python3.7/site-packages/gazebo_msgs/srv/_SpawnModel.py", line 103, in serialize
    _x = _x.encode('utf-8')
AttributeError: 'bytes' object has no attribute 'encode'

@timonegk
Copy link

Regarding the imminent end of life of python 2, could this pull request be merged @j-rivero?

@j-rivero
Copy link
Contributor

@ros-pull-request-builder retest this please

@j-rivero j-rivero merged commit a7a7c08 into ros-simulation:melodic-devel Oct 10, 2019
@j-rivero
Copy link
Contributor

Thanks Kartin for the PR and Timon for the ping at a good moment.

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.

3 participants