Skip to content

Instantly share code, notes, and snippets.

@asmodehn
Created December 15, 2015 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asmodehn/92ff6f9f0cf35a65533c to your computer and use it in GitHub Desktop.
Save asmodehn/92ff6f9f0cf35a65533c to your computer and use it in GitHub Desktop.
talker with unicode name breaking rospy
#! /usr/bin/env python
import os
import sys
import pprint
import subprocess
command = ['bash', '-c', 'source /opt/ros/indigo/setup.bash && env']
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
for line in proc.stdout:
(key, _, value) = line.partition("=")
os.environ[key] = value.rstrip()
if key == 'PYTHONPATH':
for newp in [p for p in value.split(':') if p not in sys.path]:
sys.path.append(newp)
proc.communicate()
pprint.pprint(dict(os.environ))
import rospy
from std_msgs.msg import String
def talker():
rospy.init_node('talker', argv={u'__name:=talker_name'}, anonymous=True)
rate = rospy.Rate(10) # 10hz
pub = rospy.Publisher('chatter', String, queue_size=10)
while not rospy.is_shutdown():
hello_str = "hello world %s" % rospy.get_time()
rospy.loginfo(hello_str)
pub.publish(hello_str)
rate.sleep()
if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment