# anonymous=True flag means that rospy will choose a unique # name for our 'talker' node so that multiple talkers can # run simultaenously. rospy.init_node('listener', anonymous=True) #rospy.init_node('kinect_listener', anonymous=True) rospy.Subscriber(topic, SonarArray, sonarCallback) # spin() simply keeps python from exiting until this node is stopped rospy.spin() if __name__ == '__main__': count = 0 topic='' recorded = False global collection collection = mongohelper.startDatabase("test_database", "sonarTest") # startValue='' # endValue='' ############################### # o == option # a == argument passed to the o ############################### # Cache an error with try..except # Note: options is the string of option letters that the script wants to recognize, with # options that require an argument followed by a colon (':') i.e. -i fileName # # try: # myopts, args = getopt.getopt(sys.argv[1:],"t:s:e:") # except getopt.GetoptError as e: # print (str(e))
def setup(): global p p = pyaudio.PyAudio() global stream stream = p.open(format = FORMAT, channels = CHANNELS, rate = RATE, input = True, output = True, frames_per_buffer = chunk) while(True): listen(silence,Time) if __name__ == '__main__': global pub global collection global cmd cmd = Twist() collection = mongohelper.startDatabase("test_database", "AudioTest") rospy.init_node('audio_to_cmd_vel') pub = rospy.Publisher('cmd_vel', Twist) while(True): setup()
rospy.init_node('listener', anonymous=True) #rospy.init_node('kinect_listener', anonymous=True) rospy.Subscriber(topic, MotorState, bump_callback) # spin() simply keeps python from exiting until this node is stopped rospy.spin() if __name__ == '__main__': global count global recorded recorded = False count = 0 topic='' t = 0 global collection collection = mongohelper.startDatabase("test_database", "BumpTest") # startValue='' # endValue='' ############################### # o == option # a == argument passed to the o ############################### # Cache an error with try..except # Note: options is the string of option letters that the script wants to recognize, with # options that require an argument followed by a colon (':') i.e. -i fileName # # try: # myopts, args = getopt.getopt(sys.argv[1:],"t:s:e:")