parser.add_option ("","--flytriangle",action="store_true",dest="flytriangle",help="Fly triangle with pauses")
parser.add_option ("","--flyindirref",action="store_true",dest="flyindirref",help="Fly in direction according to ref data")
parser.add_option ("","--flyxyrel",action="store_true",dest="flyxyrel",help="Fly straight line from current position to cp+(x,y), y is forward and x to the right of the LQ")
parser.add_option ("","--flyrel",action="store_true",dest="flyrel",help="Fly straight line from current position to cp+(x,y,z), y is forward and x to the right of the LQ and z is up")
parser.add_option ("","--land",action="store_true",dest="land",help="Land by flying to alt z with speed")
parser.add_option ("","--takeoff",action="store_true",dest="takeoff",help="Take off by flying to alt z with speed")
parser.add_option ("","--useyaw",action="store_true",dest="useyaw",help="Fly with yaw towards a waypoint. Otherwise, keep the current yaw",default=False)
parser.add_option ("","--yaw",action="store_true",dest="yaw",help="Yaw to heading")
parser.add_option ("","--yawrel",action="store_true",dest="yawrel",help="Yaw to current_heading+heading")
parser.add_option ("","--climb",action="store_true",dest="climb",help="Climb to z")
parser.add_option ("","--climbrel",action="store_true",dest="climbrel",help="Climb to current_alt+z")
parser.add_option ("","--lqreal",action="store_true",dest="lqreal",help="Fly the real LQ")
parser.add_option ("","--manual",action="store_true",dest="manual",help="Go to manual in the simulator")
parser.add_option ("","--heading",action="store",type="float",dest="heading",default=45,help="In degree between 0-360 (negative angles currently do not work)")
parser.add_option ("","--state",action="store",type="int",dest="state",default=0,help="0 (default) is sim/real outside, 1 is vicon room")
parser.add_option ("","--joystick",action="store_true",dest="joystick",help="Set ext config and exit")
parser.add_option ("","--safenav",action="store_true",dest="safenav",help="Set ext config and exit")
(options,args)=parser.parse_args()
rospy.init_node('lqsimple',anonymous=True)
ns=rospy.get_namespace ()
qc=QCon(ns,10000)
sim=QSim(ns)
ifoptions.joystick:
qc.set_ext_config_joystick()
sys.exit(0)
ifoptions.safenav:
qc.set_ext_config_safenav()
sys.exit(0)
ifoptions.set:
sim.set_loop_rate (options.looprate)
sys.exit(0)
ifoptions.lqreal:
ifoptions.takeoff:
options.z=1.7
options.speed=1.0
# options.speed = 1.5
# outdoor gps
# options.z = 10
# options.speed = 2.0
ifoptions.land:
options.z=-100
options.speed=0.3
# outdoor gps
# options.z = -100
# options.speed = 1.0
ifoptions.limits:
ifoptions.speed>max_speed:print"Speed {0} is too high (limit: {1}).".format (options.speed,max_speed);sys.exit (1)
ifoptions.y>max_forwardoroptions.y<min_forward:
print"Forward {0} is outside limits: <{1},{2}>.".format (options.y,min_forward,max_forward);sys.exit (1)
ifoptions.x>max_rightoroptions.x<min_right:
print"Right {0} is outside limits: <{1},{2}>.".format (options.x,min_right,max_right);sys.exit (1)
ifoptions.z>max_uporoptions.z<min_up:
print"Up {0} is outside limits: <{1},{2}>.".format (options.z,min_up,max_up);sys.exit (1)
ifoptions.manual:
sim.to_manual ()
time.sleep (1)
sim.to_auto ()
sys.exit(0)
ifoptions.logfile!="":
print"ENABLE LOGGING"
sim.start_logging (options.logfile+".lgdat")
# Make sure the motor is on in the simulator
ifnotoptions.lqreal:
sim.set_use_sticks (0),
sim.set_motor (1)
sim.to_auto ()
####### VICON
# print "Setting UAV state source: {0:1d} ".format(options.state)