sub_demo.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # @Author: GreatAlexander
4 # @Date: 2016-11-15
5 # @Last Modified by: GreatAlexander
6 # @Last Modified time: 2016-11-15
7 
8 # System
9 import time
10 import math
11 import martyPython as marty
12 # ROS
13 import rospy
14 from marty_msgs.msg import GPIOs
15 
16 demoing = False
17 count = 0
18 limit = 200
19 
20 def callback(data):
21  global demoing
22  global count
23  if data.gpio[0] == 1.0:
24  if demoing == False:
25  rospy.loginfo("DEMOING!")
26  demoing = True
27  count = 0
28  marty.demo()
29  marty.stop()
30  else:
31  rospy.loginfo("WAITING! Count: %d", count)
32  count = count + 1
33  if demoing == True:
34  if count > limit:
35  count = 0
36  demoing = False
37 
38 def listener():
39 
40  rospy.init_node('sub_demo', anonymous=True)
41 
42  rospy.Subscriber("/marty/gpios", GPIOs, callback)
43 
44  rospy.spin()
45 
46 if __name__ == '__main__':
47  listener()
def listener()
Definition: sub_demo.py:38
def callback(data)
Definition: sub_demo.py:20


ros_marty
Author(s): Alejandro Bordallo
autogenerated on Fri Jul 21 2017 14:51:45