Skip to content

Latest commit

 

History

History
236 lines (164 loc) · 10.1 KB

airsim_turbine_inspection.md

File metadata and controls

236 lines (164 loc) · 10.1 KB
Imagine you are helping me interact with the AirSim simulator for drones. At any given point of time, you have the following abilities. You are also required to output code for some of the requests.

Question - Ask me a clarification question Reason - Explain why you did something the way you did it. Code - Output a code command that achieves the desired goal.

The simulator contains a drone, along with several objects. Apart from the drone, none of the objects are movable. Within the code, we have the following commands available to us. You are not to use any other hypothetical functions.

get_position(object_name): Takes a string as input indicating the name of an object of interest, and returns a vector of 3 floats indicating its X,Y,Z coordinates.

fly_to(position): Takes a vector of 3 floats as input indicating X,Y,Z coordinates and commands the drone to fly there.

fly_path(positions): Takes a list of X,Y,Z positions indicating waypoints along a path and flies the drone along that path.

Here is an example scenario that tells you how to respond where we are working with a simulated world that has two spheres in it.

Me: Fly the drone to the sphere. You: Question - There are two spheres in the world, which one do you want me to fly the drone to? Me: Let's pick Sphere 1.

There are two turbines, some solar panels and a car in the world.

Are you ready?


Yes, I'm ready! How can I help you interact with the AirSim simulator for drones?


Go ahead and take off, please.


Code - Here's the command to takeoff the drone:

takeoff()

This command will make the drone takeoff and hover in the air.


Fly to the turbine.


Question - There are two turbines in the world, which one do you want me to fly the drone to? Turbine 1 or Turbine 2?

Assuming you want to fly to Turbine 1, here's the code to fly the drone to the turbine:

# Get the position of Turbine 1
turbine_position = get_position("Turbine 1")

# Fly the drone to the position of Turbine 1
fly_to(turbine_position)

This code will retrieve the position of Turbine 1 using the get_position() function and then fly the drone to that position using the fly_to() function.


Turbine 2, please. Fly to the turbine while keeping 12 meters away from the turbine along the X axis, and reach an altitude of 50 meters.


Here's the code to fly the drone to Turbine 2 while maintaining a distance of 12 meters along the X-axis and reaching an altitude of 50 meters:

# Get the position of Turbine 2
turbine_position = get_position("Turbine 2")

# Set the target position to be 12 meters away from the turbine along the X-axis and 50 meters high
target_position = [turbine_position[0] - 12, turbine_position[1], 50]

# Fly the drone to the target position
fly_to(target_position)

The code first retrieves the position of Turbine 2 using the get_position() function. Then it calculates the target position, which is 12 meters away from the turbine along the X-axis and 50 meters high. Finally, it uses the fly_to() function to fly the drone to the target position.


Now let's start inspecting the blades of the wind turbine. The first blade is oriented vertically upwards, fly 30 meters above your current position and back down again.


Here's the code to fly the drone up 30 meters above its current position and then back down again:

# Get the drone's current position
current_position = get_position("Drone")

# Calculate the target position that is 30 meters higher than the current position
target_position = [current_position[0], current_position[1], current_position[2] + 30]

# Fly the drone to the target position
fly_to(target_position)

# Calculate the starting position (same as the current position)
start_position = [current_position[0], current_position[1], current_position[2]]

# Fly the drone back to the starting position
fly_to(start_position)

The code first retrieves the current position of the drone using the get_position() function. Then it calculates the target position, which is 30 meters higher than the current position. The drone is flown to the target position using the fly_to() function. Finally, it calculates the starting position (which is the same as the current position), and flies the drone back to it using the fly_to() function.


To inspect the second blade, I need you to fly in the bottom-right direction at an angle of -30 degrees from the horizontal axis. You should fly in the YZ plane for a distance of 30 meters, and then back to the current position.


Here's the code to fly the drone in the bottom-right direction at an angle of -30 degrees from the horizontal axis, in the YZ plane for a distance of 30 meters, and then back to the current position:

import math

# Get the drone's current position
current_position = get_position("Drone")

# Calculate the target position, which is 30 meters away in the YZ plane at an angle of -30 degrees from the horizontal axis
angle = math.radians(-30)
target_position = [
    current_position[0],
    current_position[1] + 30 * math.cos(angle),
    current_position[2] + 30 * math.sin(angle)
]

# Fly the drone to the target position
fly_to(target_position)

# Fly the drone back to the current position
fly_to(current_position)

The code first retrieves the current position of the drone using the get_position() function. Then it calculates the target position by computing the Y and Z coordinates using the angle and distance given in the prompt, and leaving the X coordinate the same as the current position. The drone is flown to the target position using the fly_to() function. Finally, it flies the drone back to the current position.


Now we need to inspect the back of the blade as well. I need you to repeat what you just did, but stop when you get to the end.


Here's the code to fly the drone in the bottom-right direction at an angle of -30 degrees from the horizontal axis, in the YZ plane for a distance of 30 meters:

import math

# Get the drone's current position
current_position = get_position("Drone")

# Calculate the target position, which is 30 meters away in the YZ plane at an angle of -30 degrees from the horizontal axis
angle = math.radians(-30)
target_position = [
    current_position[0],
    current_position[1] + 30 * math.cos(angle),
    current_position[2] + 30 * math.sin(angle)
]

# Fly the drone to the target position
fly_to(target_position)

This code is the same as the previous code, but it doesn't fly the drone back to the current position.


Now fly behind the turbine by moving forward. Fly 20 meters on the X axis plus a couple additional meters for clearance, and then rotate the drone 180 degrees. You can use the set_yaw() function to rotate the drone.


Here's the code to fly behind the turbine by moving forward, flying 20 meters on the X axis, and then rotating the drone 180 degrees:

# Get the drone's current position
current_position = get_position("Drone")

# Calculate the target position that is 22 meters to the right of the current position (20 meters + 2 meters clearance)
target_position = [current_position[0] + 22, current_position[1], current_position[2]]

# Fly the drone to the target position
fly_to(target_position)

# Rotate the drone 180 degrees using set_yaw() function
set_yaw(180)

The code first retrieves the current position of the drone using the get_position() function. Then it calculates the target position that is 22 meters to the right of the current position (20 meters + 2 meters clearance) by adding 22 to the X coordinate and leaving the Y and Z coordinates the same. The drone is flown to the target position using the fly_to() function. Finally, it rotates the drone 180 degrees using the set_yaw() function.


Great! Now I want you to inspect the back of the blade. This means you do the exact opposite of what you did before, that means, fly in the top-right direction.


Here's the code to fly the drone in the top-right direction at an angle of 30 degrees from the horizontal axis, in the YZ plane for a distance of 30 meters:

import math

# Get the drone's current position
current_position = get_position("Drone")

# Calculate the target position, which is 30 meters away in the YZ plane at an angle of 30 degrees from the horizontal axis
angle = math.radians(30)
target_position = [
    current_position[0],
    current_position[1] + 30 * math.cos(angle),
    current_position[2] + 30 * math.sin(angle)
]

# Fly the drone to the target position
fly_to(target_position)

The code is similar to the previous code, but it flies the drone in the top-right direction at an angle of 30 degrees from the horizontal axis, in the YZ plane for a distance of 30 meters. It retrieves the current position of the drone using the get_position() function, then calculates the target position using the angle and distance given in the prompt, and flies the drone to the target position using the fly_to() function.


Delta y should be negative as we are flying in the opposite direction of what we did earlier.


You are correct. I apologize for my mistake in the previous response.

Here's the corrected code to fly the drone in the top-right direction at an angle of 30 degrees from the horizontal axis, in the YZ plane for a distance of 30 meters:

import math

# Get the drone's current position
current_position = get_position("Drone")

# Calculate the target position, which is 30 meters away in the YZ plane at an angle of 30 degrees from the horizontal axis
angle = math.radians(30)
target_position = [
    current_position[0],
    current_position[1] - 30 * math.cos(angle),
    current_position[2] + 30 * math.sin(angle)
]

# Fly the drone to the target position
fly_to(target_position)

The code first retrieves the current position of the drone using the get_position() function. Then it calculates the target position using the angle and distance given in the prompt, with a negative delta in the Y-axis direction to fly in the opposite direction of the previous flight. Finally, it flies the drone to the target position using the fly_to() function.


Thank you very much!


You're welcome! If you have any more questions or need any more help, feel free to ask.