help= 'Number of times the simulation is reset to its initial conditions (default: 2)', metavar='') ARGS = parser.parse_args() #### Initialize the simulation ##################################################################### env = CtrlAviary(drone_model=DroneModel.CF2X, initial_xyzs=np.array([-.7, -.5, .3]).reshape(1, 3), initial_rpys=np.array([0, -30 * (np.pi / 180), 0]).reshape(1, 3), gui=True, obstacles=True) #### Get PyBullet's and drone's ids ################################################################ PYB_CLIENT = env.getPyBulletClient() DRONE_IDS = env.getDroneIds() #### Make the drone weightless ##################################################################### p.setGravity(0, 0, 0, physicsClientId=PYB_CLIENT) #### Draw base frame ############################################################################### env._showDroneLocalAxes(0) #### Run the simulation ############################################################################ START = time.time() for i in range(ARGS.duration_sec * env.SIM_FREQ): #### Apply x-axis force to the base ################################################################ # p.applyExternalForce(DRONE_IDS[0], linkIndex=-1, forceObj=[1e-4,0.,0,], posObj=[0.,0.,0.], flags=p.WORLD_FRAME, physicsClientId=PYB_CLIENT) # p.applyExternalForce(DRONE_IDS[0], linkIndex=-1, forceObj=[1e-4,0.,0,], posObj=[0.,0.,0.], flags=p.LINK_FRAME, physicsClientId=PYB_CLIENT)
if __name__ == "__main__": #### Define and parse (optional) arguments for the script ########################################## parser = argparse.ArgumentParser(description='Debugging script for PyBullet applyExternalForce() and applyExternalTorque() PyBullet') parser.add_argument('--duration_sec', default=30, type=int, help='Duration of the simulation in seconds (default: 30)', metavar='') parser.add_argument('--num_resets', default=1, type=int, help='Number of times the simulation is reset to its initial conditions (default: 2)', metavar='') ARGS = parser.parse_args() #### Initialize the simulation ##################################################################### env = CtrlAviary(drone_model=DroneModel.CF2X, initial_xyzs=np.array([-.7, -.5, .3]).reshape(1,3), initial_rpys=np.array([0, -30*(np.pi/180), 0]).reshape(1,3), gui=True, obstacles=True, user_debug_gui=False) #### Get PyBullet's and drone's ids ################################################################ PYB_CLIENT = env.getPyBulletClient(); DRONE_IDS = env.getDroneIds() #### Make the drone weightless ##################################################################### p.setGravity(0, 0, 0, physicsClientId=PYB_CLIENT) #### Draw base frame ############################################################################### env._showDroneLocalAxes(0) #### Run the simulation ############################################################################ START = time.time() for i in range(ARGS.duration_sec*env.SIM_FREQ): #### Apply x-axis force to the base ################################################################ # p.applyExternalForce(DRONE_IDS[0], linkIndex=-1, forceObj=[1e-4,0.,0,], posObj=[0.,0.,0.], flags=p.WORLD_FRAME, physicsClientId=PYB_CLIENT) # p.applyExternalForce(DRONE_IDS[0], linkIndex=-1, forceObj=[1e-4,0.,0,], posObj=[0.,0.,0.], flags=p.LINK_FRAME, physicsClientId=PYB_CLIENT)