forked from microsoft/AirSim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Distance sensor Upgrades (microsoft#2807)
* Add DrawDebugPoint option for distance sensor * Expose Distance Sensor settings Plus fix for Car sensor default pose * [Pythonclient] Fix DistanceSensorData type Distances are float, not Quaternion * [docs] Add info about Distance sensor settings and usage * Use custom sensor orientation in Mavlink Distance sensor message * [ros] Change to DistanceSensorData struct * [Pythonclient] Example script for distance sensor with 2 cars
- Loading branch information
Showing
17 changed files
with
246 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import airsim | ||
import time | ||
|
||
''' | ||
An example script showing usage of Distance sensor to measure distance between 2 Car vehicles | ||
Settings - | ||
{ | ||
"SettingsVersion": 1.2, | ||
"SimMode": "Car", | ||
"Vehicles": { | ||
"Car1": { | ||
"VehicleType": "PhysXCar", | ||
"AutoCreate": true, | ||
"Sensors": { | ||
"Distance": { | ||
"SensorType": 5, | ||
"Enabled" : true, | ||
"DrawDebugPoints": true | ||
} | ||
} | ||
}, | ||
"Car2": { | ||
"VehicleType": "PhysXCar", | ||
"AutoCreate": true, | ||
"X": 10, "Y": 0, "Z": 0, | ||
"Sensors": { | ||
"Distance": { | ||
"SensorType": 5, | ||
"Enabled" : true, | ||
"DrawDebugPoints": true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
Car2 is placed in front of Car 1 | ||
''' | ||
|
||
client = airsim.CarClient() | ||
client.confirmConnection() | ||
|
||
while True: | ||
data_car1 = client.getDistanceSensorData(vehicle_name="Car1") | ||
data_car2 = client.getDistanceSensorData(vehicle_name="Car2") | ||
print(f"Distance sensor data: Car1: {data_car1.distance}, Car2: {data_car2.distance}") | ||
time.sleep(1.0) |
Oops, something went wrong.