roseus_command_sender.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 # Author: Yuki Furuta <furushchev@jsk.imi.i.u-tokyo.ac.jp>
00004 
00005 import os
00006 import rospy
00007 from roseus_remote.msg import RawCommand
00008 
00009 
00010 def cmd_res_cb(msg):
00011     input_str = str(msg.data).rstrip(' \t\r\n\0')
00012     print input_str
00013 
00014 def on_shutdown():
00015     rospy.logwarn("to exit immediately, press Enter")
00016 
00017 def main():
00018     global cmd_res
00019     rospy.init_node("roseus_remote_command_sender", anonymous=True)
00020     rospy.on_shutdown(on_shutdown)
00021     pub = rospy.Publisher("output", RawCommand)
00022     sub = rospy.Subscriber("input", RawCommand, cmd_res_cb)
00023     while not rospy.is_shutdown():
00024         try:
00025             cmd = raw_input("roseus$ ")
00026             if cmd:
00027                 pub.publish(RawCommand(data=cmd))
00028                 rospy.sleep(0.01)
00029         except Exception as e:
00030             rospy.logwarn("caught exception: " + str(e))
00031             rospy.sleep(1.0)
00032 
00033 if __name__ == '__main__':
00034     main()


roseus_remote
Author(s): Yuki Furuta
autogenerated on Sat Jul 1 2017 02:43:50