Esempio n. 1
0
def main():
  """
  This is the main program that runs the simulator.
  """
  # Assign signal handlers
  signal.signal(signal.SIGINT, interrupt_handler)
  global running
  running = True

  print "Starting simulator."
  sim = FuriousSim()

  # Process command line arguments
  arguments = sys.argv[1:]  # shallow copy
  while len(arguments) > 0:
    arg = arguments.pop(0).strip()
    if arg == "-d":
      # Enable debugging output
      sim.set_debugger(sys.stdout)
    else:
      # Print usage and exit
      print __doc__
      exit(1)

  # Run the simulator
  sim.open_pty()
  print "Listening on %s." % sim.slave_ttyname()
  sim.connect()
  logic_batt = 150
  motor_batt = 150
  try:
    while running and sim.is_ready():
      # make up some analog values
      for x in range(6):
        sim.set_analog(x, random.randint(0, 1023))
      sim.set_odometer(random.randint(0, 3))
      # deplete the batteries slowly
      logic_batt -= random.randint(0,101) // 100
      motor_batt -= random.randint(0,101) // 100
      sim.set_logic_battery(logic_batt)
      sim.set_motor_battery(motor_batt)
      # Set the sonar value to 10 times the id, for debugging purposes
      sim.set_sonar_value(sim.get_sonar_request() * 10)

      # send/receive
      sim.step()

  except OSError, e:
    print >>sys.stderr, "Lost connection to driver: %s" % e
Esempio n. 2
0
def main():
    """
  This is the main program that runs the simulator.
  """
    # Assign signal handlers
    signal.signal(signal.SIGINT, interrupt_handler)
    global running
    running = True

    print "Starting simulator."
    sim = FuriousSim()

    # Process command line arguments
    arguments = sys.argv[1:]  # shallow copy
    while len(arguments) > 0:
        arg = arguments.pop(0).strip()
        if arg == "-d":
            # Enable debugging output
            sim.set_debugger(sys.stdout)
        else:
            # Print usage and exit
            print __doc__
            exit(1)

    # Run the simulator
    sim.open_pty()
    print "Listening on %s." % sim.slave_ttyname()
    sim.connect()
    logic_batt = 150
    motor_batt = 150
    try:
        while running and sim.is_ready():
            # make up some analog values
            for x in range(6):
                sim.set_analog(x, random.randint(0, 1023))
            sim.set_odometer(random.randint(0, 3))
            # deplete the batteries slowly
            logic_batt -= random.randint(0, 101) // 100
            motor_batt -= random.randint(0, 101) // 100
            sim.set_logic_battery(logic_batt)
            sim.set_motor_battery(motor_batt)
            # Set the sonar value to 10 times the id, for debugging purposes
            sim.set_sonar_value(sim.get_sonar_request() * 10)

            # send/receive
            sim.step()

    except OSError, e:
        print >> sys.stderr, "Lost connection to driver: %s" % e
Esempio n. 3
0
def main():
  """ 
  This is the main program that runs the simulator. 
  """

  rospy.init_node(NODE_NAME)

  # Run the simulator
  rospy.loginfo("Initializing simulator.")
  sim = FuriousSim()
  sim.set_debugger(sys.stdout)
  sim.open_pty()
  port = sim.slave_ttyname()
  rospy.set_param(PARAM_NAME, port)
  rospy.loginfo("Furious simulator listening on %s." % port)
  sim.connect()
  logic_batt = 150
  motor_batt = 150
  while not rospy.is_shutdown():
    # make up some analog values
    for x in range(6):
      sim.set_analog(x, random.randint(0, 1023))
    sim.set_odometer(random.randint(0, 3))
    # deplete the batteries slowly
    logic_batt -= random.randint(0,101) // 100
    motor_batt -= random.randint(0,101) // 100
    sim.set_logic_battery(logic_batt)
    sim.set_motor_battery(motor_batt)
    # Set the sonar value to 10 times the id, for debugging purposes
    sim.set_sonar_value(sim.get_sonar_request() * 10)

    # send/receive
    sim.step()

  rospy.loginfo("Disconnecting...")
  sim.disconnect()
  shutdown(0)
Esempio n. 4
0
def main():
    """ 
  This is the main program that runs the simulator. 
  """

    rospy.init_node(NODE_NAME)

    # Run the simulator
    rospy.loginfo("Initializing simulator.")
    sim = FuriousSim()
    sim.set_debugger(sys.stdout)
    sim.open_pty()
    port = sim.slave_ttyname()
    rospy.set_param(PARAM_NAME, port)
    rospy.loginfo("Furious simulator listening on %s." % port)
    sim.connect()
    logic_batt = 150
    motor_batt = 150
    while not rospy.is_shutdown():
        # make up some analog values
        for x in range(6):
            sim.set_analog(x, random.randint(0, 1023))
        sim.set_odometer(random.randint(0, 3))
        # deplete the batteries slowly
        logic_batt -= random.randint(0, 101) // 100
        motor_batt -= random.randint(0, 101) // 100
        sim.set_logic_battery(logic_batt)
        sim.set_motor_battery(motor_batt)
        # Set the sonar value to 10 times the id, for debugging purposes
        sim.set_sonar_value(sim.get_sonar_request() * 10)

        # send/receive
        sim.step()

    rospy.loginfo("Disconnecting...")
    sim.disconnect()
    shutdown(0)