def main(): global bumper print("Lancement test servo") rospy.init_node('test_servo') rospy.sleep(0.5) pub = rospy.Publisher("/mobile_base/commands/digital_output", DigitalOutput) cmd=DigitalOutput() cmd.values= [True, True, True, True] cmd.mask=[True, False, False, False] while not rospy.is_shutdown(): print(cmd) pub.publish(cmd) cmd.values=[False, False, False, False] rospy.sleep(5) print(cmd) pub.publish(cmd) rospy.sleep(5) cmd.values= [True, True, True, True] print("je suis desole, je n'ai pas de servo") rospy.spin() #boucle infinie tant qu'on quitte pas proprement
def main(): global bumper print("Lancement test servo") rospy.init_node('test_servo') rospy.sleep(0.5) pub = rospy.Publisher("/mobile_base/commands/digital_output", DigitalOutput) cmd = DigitalOutput() cmd.values = [True, True, True, True] cmd.mask = [True, False, False, False] while not rospy.is_shutdown(): print(cmd) pub.publish(cmd) cmd.values = [False, False, False, False] rospy.sleep(5) print(cmd) pub.publish(cmd) rospy.sleep(5) cmd.values = [True, True, True, True] print("je suis desole, je n'ai pas de servo") rospy.spin() #boucle infinie tant qu'on quitte pas proprement
def main(): global bumper print("Lancement navigation aleatoire") rospy.init_node('navigation_aleatoire') rospy.sleep(0.5) rospy.Subscriber("/mobile_base/events/bumper", BumperEvent, bumper) rospy.Subscriber("/facedetector/faces", Detection, image) pub = rospy.Publisher("/mobile_base/commands/velocity", Twist) # pub2 = rospy.Publisher("/robotsound", SoundRequest) pub3 = rospy.Publisher("/mobile_base/commands/sound", Sound) pub4 = rospy.Publisher("/mobile_base/commands/digital_output", DigitalOutput) cmd = Twist() # sound = SoundRequest() sonnerie = Sound() # sound.arg = "/opt/ros/indigo/share/sound_play/sounds/R2D2a.wav" # sound.sound = -2 # sound.command = 1 sonnerie.value = 6 digOut = DigitalOutput() digOut.values = [False, False, False, False] digOut.mask = [True, False, False, False] flag = 0 rospy.sleep(1) indiana_jones.main() while not rospy.is_shutdown(): duree = 1 + random.random() * 5 tempsActuel = rospy.get_time() stop = rospy.get_time() + duree while (rospy.get_time() < stop): if bumper == 0: cmd.linear.x = 0 cmd.angular.z = -2 pub.publish(cmd) rospy.sleep(0.5) bumper = 3 elif bumper == 1: cmd.linear.x = -0.2 cmd.angular.z = 0 digOut.values[0] = True pub.publish(cmd) vador2.main() # pub2.publish(sound) pub4.publish(digOut) rospy.sleep(5) while (NbGens > 0): rospy.sleep(2.5) flag = 1 digOut.values[0] = False if flag == 1: pub3.publish(sonnerie) rospy.sleep(0.5) flag = 0 pub4.publish(digOut) rospy.sleep(0.5) cmd.linear.x = -0.2 cmd.angular.z = 2 pub.publish(cmd) rospy.sleep(0.5) bumper = 3 elif bumper == 2: cmd.linear.x = 0 cmd.angular.z = 2 pub.publish(cmd) rospy.sleep(0.5) bumper = 3 else: cmd.linear.x = 0.2 cmd.angular.z = 0 pub.publish(cmd) if bumper > 2: bumper = math.floor(random.random() * 10) if bumper == 1: bumper = 3 print("fin navigation autonome") rospy.spin() #boucle infinie tant qu'on quitte pas proprement
# rospy initial setup rospy.init_node("test_output") rospy.on_shutdown(clearing) rate = rospy.Rate(10) pub_ext_pwr = rospy.Publisher("/mobile_base/commands/external_power", DigitalOutput) pub_dgt_out = rospy.Publisher("/mobile_base/commands/digital_output", DigitalOutput) pub = [] pub.append(rospy.Publisher("/mobile_base/commands/led1", Led)) pub.append(rospy.Publisher("/mobile_base/commands/led2", Led)) pub_sounds = rospy.Publisher("/mobile_base/commands/sound", Sound) # initial values external_power = DigitalOutput() external_power.values = [True, True, True, True] external_power.mask = [True, True, True, True] digital_output = DigitalOutput() digital_output.values = [True, True, True, True] digital_output.mask = [True, True, True, True] leds = [] leds.append(Led()) leds.append(Led()) leds[0].value = Led.GREEN leds[1].value = Led.GREEN # initialize outputs while not pub_ext_pwr.get_num_connections(): rate.sleep()
settings = termios.tcgetattr(sys.stdin) def clearing(): sys.stdout.write('\r\n') sys.stdout.flush() termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings) rospy.init_node("test_external_power") rospy.on_shutdown(clearing) pub = rospy.Publisher('/mobile_base/commands/external_power', DigitalOutput) rate = rospy.Rate(10) digital_output = DigitalOutput() digital_output.values = [True, True, True, True] digital_output.mask = [True, True, True, True] print "" #print "If you want to control the timing of publish, uses -p option." #print "" print "Control External Power" print "----------------------" print "1: Toggle the state of 3.3V" print "2: Toggle the state of 5V" print "3: Toggle the state of 12V5A(arm)" print "4: Toggle the state of 12V1A(kinect)" print "" #print "p: publish power on/off status" print "q: quit" print "" print " 3.3V 5.0V 12V5A 12V1A"
'4':3, } settings = termios.tcgetattr(sys.stdin) def clearing(): sys.stdout.write('\r\n') sys.stdout.flush() termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings) rospy.init_node("test_external_power") rospy.on_shutdown(clearing) pub = rospy.Publisher('/mobile_base/commands/external_power',DigitalOutput) rate = rospy.Rate(10) digital_output = DigitalOutput() digital_output.values = [ True, True, True, True ] digital_output.mask = [ True, True, True, True ] print "" #print "If you want to control the timing of publish, uses -p option." #print "" print "Control External Power" print "----------------------" print "1: Toggle the state of 3.3V" print "2: Toggle the state of 5V" print "3: Toggle the state of 12V5A(arm)" print "4: Toggle the state of 12V1A(kinect)" print "" #print "p: publish power on/off status" print "q: quit" print "" print " 3.3V 5.0V 12V5A 12V1A"
rospy.init_node("test_output") rospy.on_shutdown(clearing) rate = rospy.Rate(10) pub_ext_pwr = rospy.Publisher('/mobile_base/commands/external_power', DigitalOutput) pub_dgt_out = rospy.Publisher('/mobile_base/commands/digital_output', DigitalOutput) pub = [] pub.append(rospy.Publisher('/mobile_base/commands/led1', Led)) pub.append(rospy.Publisher('/mobile_base/commands/led2', Led)) pub_sounds = rospy.Publisher('/mobile_base/commands/sound', Sound) # initial values external_power = DigitalOutput() external_power.values = [True, True, True, True] external_power.mask = [True, True, True, True] digital_output = DigitalOutput() digital_output.values = [True, True, True, True] digital_output.mask = [True, True, True, True] leds = [] leds.append(Led()) leds.append(Led()) leds[0].value = Led.GREEN leds[1].value = Led.GREEN # initialize outputs while not pub_ext_pwr.get_num_connections(): rate.sleep()
def main(): global bumper print("Lancement navigation aleatoire") rospy.init_node('navigation_aleatoire') rospy.sleep(0.5) rospy.Subscriber("/mobile_base/events/bumper", BumperEvent, bumper) # rospy.Subscriber("/facedetector/faces",Detection , face) # rospy.Subscriber("/camera/depth/image_rect",Image, image) pub = rospy.Publisher("/mobile_base/commands/velocity", Twist) # pub2 = rospy.Publisher("/robotsound", SoundRequest) pub3 = rospy.Publisher("/mobile_base/commands/sound", Sound) pub4 = rospy.Publisher("/mobile_base/commands/digital_output", DigitalOutput) ic=image_converter() cmd = Twist() # sound = SoundRequest() sonnerie = Sound() # sound.arg = "/opt/ros/indigo/share/sound_play/sounds/R2D2a.wav" # sound.sound = -2 # sound.command = 1 sonnerie.value= 6 digOut=DigitalOutput() digOut.values= [False, False, False, False] digOut.mask=[True, False, False, False] flag=0 while not rospy.is_shutdown(): duree= 1+random.random()*5 tempsActuel = rospy.get_time() stop = rospy.get_time() + duree while (rospy.get_time() < stop): if bumper==0 or bumper1 ==0 : cmd.linear.x = 0 cmd.angular.z = -2 pub.publish(cmd) rospy.sleep(0.5) bumper=3 elif bumper==1 or bumper1==1: cmd.linear.x = -0.2 cmd.angular.z = 0 digOut.values[0]=True pub.publish(cmd) # pub2.publish(sound) pub4.publish(digOut) rospy.sleep(5) while (NbGens>0): rospy.sleep(2.5) flag=1 digOut.values[0]=False if flag==1: pub3.publish(sonnerie) rospy.sleep(0.5) flag=0 pub4.publish(digOut) rospy.sleep(0.5) cmd.linear.x = -0.2 cmd.angular.z = 2 pub.publish(cmd) rospy.sleep(0.5) bumper=3 elif bumper==2 or bumper1==2: cmd.linear.x = 0 cmd.angular.z = 2 pub.publish(cmd) rospy.sleep(0.5) bumper=3 else: cmd.linear.x = 0.2 cmd.angular.z = 0 pub.publish(cmd) rospy.sleep(0.5) # if bumper>2: # bumper = math.floor(random.random()*10) # if bumper == 1: # bumper=3 print("fin navigation autonome") rospy.spin() #boucle infinie tant qu'on quitte pas proprement
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import roslib; roslib.load_manifest('kobuki_testsuite') import rospy from kobuki_msgs.msg import DigitalOutput rospy.init_node("test_digital_output") pub = rospy.Publisher('/mobile_base/commands/digital_output',DigitalOutput) rate = rospy.Rate(1) digital_output = DigitalOutput() digital_output.values = [ False, False, False, False] digital_output.mask = [ True, True, False, True ] print "" print "This program will start sending a variety of digital io signals to the robot." print "It will set all output signals to false, then iteratively turn each one to True" print "In doing so, it will cycle through a mask that will negate the setting for one" print "of the outputs. The process then repeats itself masking the next output in the" print "sequence instead." print "" while not rospy.is_shutdown(): # incrementally convert a false, to true and then reset them all to false. try: index = digital_output.values.index(False) for i in range(0,4): if not digital_output.values[i]: digital_output.values[i] = True