Created
December 15, 2015 01:20
-
-
Save asmodehn/92ff6f9f0cf35a65533c to your computer and use it in GitHub Desktop.
talker with unicode name breaking rospy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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