RiCPPMWatcher.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 __author__ = 'tom1231'
00003 import roslib; roslib.load_manifest('ric_board')
00004 import rospy
00005 from rospy import Subscriber
00006 from rospy import Publisher
00007 from ric_board.msg import PPM
00008 import sys
00009 from geometry_msgs.msg import Twist
00010 
00011 
00012 class Program:
00013     def main(self):
00014         if len(sys.argv) >= 3:
00015             rospy.init_node("RiC_PPM")
00016             topicNamePmm = sys.argv[1]
00017             topicNameDiff = sys.argv[2]
00018             # print 'PPM Topic: ' + topicNamePmm + '\n' + 'Diff Topic: ' + topicNameDiff
00019             self.pub = Publisher(topicNameDiff, Twist,queue_size=1)
00020             Subscriber(topicNamePmm, PPM, self.callBack, queue_size=1)
00021             rospy.spin()
00022 
00023     def callBack(self, msg):
00024 
00025         leftAndRight = 0
00026         upAndDown = 0
00027 
00028         if 1450 < msg.channels[0] < 1550: leftAndRight = 0
00029         else: leftAndRight = 0.032 * (float(msg.channels[0])) - 48
00030 
00031         if 1450 < msg.channels[1] < 1550: upAndDown = 0
00032         else: upAndDown = 0.032 * (float(msg.channels[1])) - 48
00033 
00034         msgPub = Twist()
00035         msgPub.angular.z = leftAndRight
00036         msgPub.linear.x = -upAndDown
00037 
00038         self.pub.publish(msgPub)
00039 
00040 if __name__ == '__main__':
00041     Program().main()


ric_board
Author(s): RoboTiCan
autogenerated on Fri Oct 27 2017 03:02:31