How to use the airsim.Vector3r function in airsim

To help you get started, we’ve selected a few airsim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / AirSim-Drone-Racing-VAE-Imitation / datagen / action_generator / src / soccer_datagen.py View on Github external
def takeoff_with_moveOnSpline(self, takeoff_height, vel_max, acc_max):
        self.client.moveOnSplineAsync(path=[airsim.Vector3r(4, -2, takeoff_height)],
                                      vel_max=vel_max, acc_max=acc_max,
                                      add_curr_odom_position_constraint=True,
                                      add_curr_odom_velocity_constraint=True,
                                      viz_traj=viz_traj,
                                      vehicle_name=self.drone_name).join()
github microsoft / AirSim / PythonClient / computer_vision / objects.py View on Github external
# search non-existent object
pose3 = client.simGetObjectPose("Non-Existent"); # should return nan pose
print("Non-Existent - Position: %s, Orientation: %s" % (pprint.pformat(pose3.position),
    pprint.pformat(pose3.orientation)))


#------------------------------------ Set new pose ------------------------------------------------

# here we move with teleport enabled so collisions are ignored
pose1.position = pose1.position + airsim.Vector3r(-2, -2, -2)
success = client.simSetObjectPose("OrangeBall", pose1, True);
airsim.wait_key("OrangeBall moved. Success: %i" % (success))

# here we move with teleport enabled so collisions are not ignored
pose2.position = pose2.position + airsim.Vector3r(3, 3, -2)
success = client.simSetObjectPose("PulsingCone", pose2, False);
airsim.wait_key("PulsingCone moved. Success: %i" % (success))

# move non-existent object
success = client.simSetObjectPose("Non-Existent", pose2); # should return nan pose
airsim.wait_key("Non-Existent moved. Success: %i" % (success))

#------------------------------------ Get new pose ------------------------------------------------


pose1 = client.simGetObjectPose("OrangeBall");
print("OrangeBall - Position: %s, Orientation: %s" % (pprint.pformat(pose1.position),
    pprint.pformat(pose1.orientation)))

# search another object by tag
pose2 = client.simGetObjectPose("PulsingCone");
github microsoft / AirSim-Drone-Racing-VAE-Imitation / gate_pose_regressor / pose_regressor_navigation.py View on Github external
time.sleep(0.01)
    client.setTrajectoryTrackerGains(airsim.TrajectoryTrackerGains().to_list(), vehicle_name=drone_name)
    time.sleep(0.01)

    # destroy all previous gates in map
    racing_utils.trajectory_utils.AllGatesDestroyer(client)

    # spawn red gates in appropriate locations
    # gate_poses = racing_utils.trajectory_utils.RedGateSpawner(client, num_gates=1, noise_amp=0)
    gate_poses = racing_utils.trajectory_utils.RedGateSpawnerCircle(client, num_gates=13, radius=20, radius_noise=0.0, height_range=[10, 11])

    # wait till takeoff complete
    vel_max = 3.0
    acc_max = 3.0

    takeoff_position = airsim.Vector3r(20, -2, 10)
    takeoff_orientation = airsim.Vector3r(0, -1, 0)
    # takeoff_position = airsim.Vector3r(0, 0, 10)
    # takeoff_orientation = airsim.Vector3r(1, 0, 0)
    # client.plot_tf([takeoff_pose], duration=20.0, vehicle_name=drone_name)
    # client.moveOnSplineAsync([airsim.Vector3r(0, 0, -3)], vel_max=15.0, acc_max=5.0, vehicle_name=drone_name, viz_traj=True).join()
    client.moveOnSplineVelConstraintsAsync([takeoff_position], [takeoff_orientation], vel_max=vel_max, acc_max=acc_max, vehicle_name=drone_name, viz_traj=True).join()
    # client.moveOnSplineVelConstraintsAsync([airsim.Vector3r(1, 0, 8)], [airsim.Vector3r(1, 0, 0)], vel_max=vel_max, acc_max=acc_max, vehicle_name=drone_name, viz_traj=True)

    time.sleep(1.0)
    img_res = 64

    # path_weights = '/home/rb/data/model_outputs/reg_6/reg_model_10.ckpt'
    path_weights = '/home/rb/data/model_outputs/cmvae_9/cmvae_model_20.ckpt'
    gate_regressor = gate_regressor.GateRegressor(regressor_type='cmvae', path_weights=path_weights)

    while True:
github microsoft / AirSim-Drone-Racing-VAE-Imitation / gate_pose_regressor / pose_regressor_navigation.py View on Github external
client.setTrajectoryTrackerGains(airsim.TrajectoryTrackerGains().to_list(), vehicle_name=drone_name)
    time.sleep(0.01)

    # destroy all previous gates in map
    racing_utils.trajectory_utils.AllGatesDestroyer(client)

    # spawn red gates in appropriate locations
    # gate_poses = racing_utils.trajectory_utils.RedGateSpawner(client, num_gates=1, noise_amp=0)
    gate_poses = racing_utils.trajectory_utils.RedGateSpawnerCircle(client, num_gates=13, radius=20, radius_noise=0.0, height_range=[10, 11])

    # wait till takeoff complete
    vel_max = 3.0
    acc_max = 3.0

    takeoff_position = airsim.Vector3r(20, -2, 10)
    takeoff_orientation = airsim.Vector3r(0, -1, 0)
    # takeoff_position = airsim.Vector3r(0, 0, 10)
    # takeoff_orientation = airsim.Vector3r(1, 0, 0)
    # client.plot_tf([takeoff_pose], duration=20.0, vehicle_name=drone_name)
    # client.moveOnSplineAsync([airsim.Vector3r(0, 0, -3)], vel_max=15.0, acc_max=5.0, vehicle_name=drone_name, viz_traj=True).join()
    client.moveOnSplineVelConstraintsAsync([takeoff_position], [takeoff_orientation], vel_max=vel_max, acc_max=acc_max, vehicle_name=drone_name, viz_traj=True).join()
    # client.moveOnSplineVelConstraintsAsync([airsim.Vector3r(1, 0, 8)], [airsim.Vector3r(1, 0, 0)], vel_max=vel_max, acc_max=acc_max, vehicle_name=drone_name, viz_traj=True)

    time.sleep(1.0)
    img_res = 64

    # path_weights = '/home/rb/data/model_outputs/reg_6/reg_model_10.ckpt'
    path_weights = '/home/rb/data/model_outputs/cmvae_9/cmvae_model_20.ckpt'
    gate_regressor = gate_regressor.GateRegressor(regressor_type='cmvae', path_weights=path_weights)

    while True:
        img_batch_1, cam_pos, cam_orientation = process_image(client, img_res)
github microsoft / AirSim / PythonClient / multirotor / survey.py View on Github external
# let it settle there a bit.
        self.client.hoverAsync().join()
        time.sleep(2)

        # after hovering we need to re-enabled api control for next leg of the trip
        self.client.enableApiControl(True)

        # now compute the survey path required to fill the box 
        path = []
        distance = 0
        while x < self.boxsize:
            distance += self.boxsize 
            path.append(airsim.Vector3r(x, self.boxsize, z))
            x += self.stripewidth            
            distance += self.stripewidth 
            path.append(airsim.Vector3r(x, self.boxsize, z))
            distance += self.boxsize 
            path.append(airsim.Vector3r(x, -self.boxsize, z)) 
            x += self.stripewidth  
            distance += self.stripewidth 
            path.append(airsim.Vector3r(x, -self.boxsize, z))
            distance += self.boxsize 
        
        print("starting survey, estimated distance is " + str(distance))
        trip_time = distance / self.velocity
        print("estimated survey time is " + str(trip_time))
        try:
            result = self.client.moveOnPathAsync(path, self.velocity, trip_time, airsim.DrivetrainType.ForwardOnly, 
                airsim.YawMode(False,0), self.velocity + (self.velocity/2), 1).join()
        except:
            errorType, value, traceback = sys.exc_info()
            print("moveOnPath threw exception: " + str(value))
github microsoft / AirSim / PythonClient / multirotor / path.py View on Github external
import sys
import time

client = airsim.MultirotorClient()
client.confirmConnection()
client.enableApiControl(True)


# AirSim uses NED coordinates so negative axis is up.
# z of -7 is 7 meters above the original launch point.
z = -7

# see https://github.com/Microsoft/AirSim/wiki/moveOnPath-demo

# this method is async and we are not waiting for the result since we are passing timeout_sec=0.
result = client.moveOnPathAsync([airsim.Vector3r(0,-253,z),airsim.Vector3r(125,-253,z),airsim.Vector3r(125,0,z),airsim.Vector3r(0,0,z),airsim.Vector3r(0,0,-20)], 
                        12, 120, 
                        airsim.DrivetrainType.ForwardOnly, airsim.YawMode(False,0), 20, 1).join()
client.moveToPositionAsync(0,0,z,1).join()
client.landAsync()
client.armDisarm(False)
client.enableApiControl(False)