How to use the airsim.Pose 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 / PythonClient / computer_vision / cv_mode.py View on Github external
for i, response in enumerate(responses):
        if response.pixels_as_float:
            print("Type %d, size %d, pos %s" % (response.image_type, len(response.image_data_float), pprint.pformat(response.camera_position)))
            airsim.write_pfm(os.path.normpath('/temp/cv_mode_' + str(x) + "_" + str(i) + '.pfm'), airsim.get_pfm_array(response))
        else:
            print("Type %d, size %d, pos %s" % (response.image_type, len(response.image_data_uint8), pprint.pformat(response.camera_position)))
            airsim.write_file(os.path.normpath('/temp/cv_mode_' + str(x) + "_" + str(i) + '.png'), response.image_data_uint8)

    pose = client.simGetVehiclePose()
    pp.pprint(pose)

    time.sleep(3)

# currently reset() doesn't work in CV mode. Below is the workaround
client.simSetPose(airsim.Pose(airsim.Vector3r(0, 0, 0), airsim.to_quaternion(0, 0, 0)), True)
github microsoft / AirSim / PythonClient / computer_vision / cv_navigate.py View on Github external
def moveUAV(client,pos,yaw):
    client.simSetVehiclePose(airsim.Pose(airsim.Vector3r(pos[0], pos[1], pos[2]), airsim.to_quaternion(0, 0, yaw)), True) 
github microsoft / AirSim / PythonClient / computer_vision / cv_mode.py View on Github external
client = airsim.VehicleClient()
client.confirmConnection()

airsim.wait_key('Press any key to set camera-0 gimble to 15-degree pitch')
client.simSetCameraOrientation("0", airsim.to_quaternion(0.261799, 0, 0)); #radians

airsim.wait_key('Press any key to get camera parameters')
for camera_name in range(5):
    camera_info = client.simGetCameraInfo(str(camera_name))
    print("CameraInfo %d: %s" % (camera_name, pp.pprint(camera_info)))

airsim.wait_key('Press any key to get images')
for x in range(3): # do few times
    z = x * -20 - 5 # some random number
    client.simSetVehiclePose(airsim.Pose(airsim.Vector3r(z, z, z), airsim.to_quaternion(x / 3.0, 0, x / 3.0)), True)

    responses = client.simGetImages([
        airsim.ImageRequest("0", airsim.ImageType.DepthVis),
        airsim.ImageRequest("1", airsim.ImageType.DepthPerspective, True),
        airsim.ImageRequest("2", airsim.ImageType.Segmentation),
        airsim.ImageRequest("3", airsim.ImageType.Scene),
        airsim.ImageRequest("4", airsim.ImageType.DisparityNormalized),
        airsim.ImageRequest("4", airsim.ImageType.SurfaceNormals)])

    for i, response in enumerate(responses):
        if response.pixels_as_float:
            print("Type %d, size %d, pos %s" % (response.image_type, len(response.image_data_float), pprint.pformat(response.camera_position)))
            airsim.write_pfm(os.path.normpath('/temp/cv_mode_' + str(x) + "_" + str(i) + '.pfm'), airsim.get_pfm_array(response))
        else:
            print("Type %d, size %d, pos %s" % (response.image_type, len(response.image_data_uint8), pprint.pformat(response.camera_position)))
            airsim.write_file(os.path.normpath('/temp/cv_mode_' + str(x) + "_" + str(i) + '.png'), response.image_data_uint8)
github microsoft / AirSim-Drone-Racing-VAE-Imitation / gate_pose_regressor / utils_reg.py View on Github external
def generate_gate_poses(num_gates, race_course_radius, radius_noise, height_range, type_of_segment="circle"):
    if type_of_segment == "circle":
        (x_t, y_t, z_t) = tuple([generate_circle(i, num_gates, race_course_radius, radius_noise) for i in range(3)])
        # todo unreadable code
        # todo un-hardcode
        # airsim.Vector3r((x_t[t_i][0] - x_t[0][0]), (y_t[t_i][0] - y_t[0][0]), random.uniform(height_range[0], height_range[1])), \
        gate_poses = [\
                        airsim.Pose(\
                        airsim.Vector3r((x_t[t_i][0]), (y_t[t_i][0]), random.uniform(height_range[0], height_range[1])), \
                        quaternionFromUnitGradient(x_t[t_i][1], y_t[t_i][1], z_t[t_i][1])\
                      )\
                    for t_i in range(num_gates)]
    # elif type_of_segment == "cubic":
    return gate_poses
github microsoft / AirSim-Drone-Racing-VAE-Imitation / gate_pose_regressor / pose_regressor_navigation.py View on Github external
def move_drone(client, gate_pose):
    # client.enableApiControl(True, vehicle_name=drone_name)
    # client.moveOnSplineAsync([gate_pose.position], vel_max=vel_max, acc_max=acc_max, vehicle_name=drone_name)
    gate_vector = racing_utils.geom_utils.get_gate_facing_vector_from_quaternion(gate_pose.orientation, direction=0, scale=1.0)
    client.plot_tf([airsim.Pose(gate_pose.position + gate_vector, gate_pose.orientation)], duration=20.0, vehicle_name=drone_name)
    # client.plot_tf([gate_pose], duration=20.0, vehicle_name=drone_name)
    # client.moveOnSplineAsync([gate_pose.position], [gate_vector], vel_max=vel_max, acc_max=acc_max, vehicle_name=drone_name, viz_traj=True)
    # client.moveOnSplineVelConstraintsAsync([gate_pose.position], [gate_vector], add_curr_odom_position_constraint=True, add_curr_odom_velocity_constraint=True, vel_max=vel_max, acc_max=acc_max, vehicle_name=drone_name, viz_traj=True)
    client.moveOnSplineAsync([gate_pose.position],
                             add_curr_odom_position_constraint=True,
                             add_curr_odom_velocity_constraint=True,
                             vel_max=vel_max, acc_max=acc_max,
                             vehicle_name=drone_name, viz_traj=True)
    # client.moveOnSplineVelConstraintsAsync([gate_pose.position-gate_vector],
github microsoft / AirSim / PythonClient / computer_vision / character_control.py View on Github external
client = airsim.VehicleClient()
client.confirmConnection()
client.reset()

airsim.wait_key('Press any key to set skin age to 1')
client.simCharSetSkinAgeing(1)

airsim.wait_key('Press any key to set skin color to 0.9')
client.simCharSetSkinDarkness(0.9)

#airsim.wait_key('Press any key to set face expression')
#client.simCharSetFaceExpression("BlendShapeNode_Smile", 1);

airsim.wait_key('Press any key to set bone pose')
client.reset()
jaw_pose = airsim.Pose()
jaw_pose.position = airsim.Vector3r(0.002, 0.001, -0.003)
jaw_pose.orientation = airsim.to_quaternion(0, 0, -.15)
client.simCharSetBonePose( "Jaw", jaw_pose);

airsim.wait_key('Press any key to set preset')
client.reset()
for x in range(0, 10, 3):
    client.simCharSetFacePreset("FACS_0" + str(x), 5);
    time.sleep(1)

airsim.wait_key('Press any key to set multiple presets')
presets = {"Phoneme_l":0.5, "Phoneme_ae": 1, "Phoneme_ooo":0.0}
client.simCharSetFacePresets(presets)

airsim.wait_key('Press any key to turn head around')
client.reset()