Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
xxEoD2242 committed Jun 23, 2024
2 parents 889df70 + 0985804 commit 499f0e8
Show file tree
Hide file tree
Showing 28 changed files with 333 additions and 120 deletions.
4 changes: 4 additions & 0 deletions AirLib/include/api/RpcLibClientBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ namespace airlib
void simSetWeatherParameter(WorldSimApiBase::WeatherParameter param, float val);

vector<string> simListSceneObjects(const string& name_regex = string(".*")) const;
vector<string> simListSceneObjectsByTag(const string& tag_regex = string(".*")) const;

Pose simGetObjectPose(const std::string& object_name) const;
bool simLoadLevel(const string& level_name);
Vector3r simGetObjectScale(const std::string& object_name) const;
Expand Down Expand Up @@ -163,6 +165,8 @@ namespace airlib
void simSetWind(const Vector3r& wind) const;
void simSetExtForce(const Vector3r& ext_force) const;

Vector3r simFindLookAtRotation(const std::string& vehicle_name, const std::string& object_name) const;

vector<string> listVehicles();

std::string getSettingsString() const;
Expand Down
3 changes: 3 additions & 0 deletions AirLib/include/api/WorldSimApiBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ namespace airlib
virtual void simPlotTransformsWithNames(const vector<Pose>& poses, const vector<std::string>& names, float tf_scale, float tf_thickness, float text_scale, const vector<float>& text_color_rgba, float duration) = 0;

virtual std::vector<std::string> listSceneObjects(const std::string& name_regex) const = 0;
virtual std::vector<std::string> listSceneObjectsByTag(const std::string& tag_regex) const = 0;

virtual Pose getObjectPose(const std::string& object_name) const = 0;
virtual Vector3r getObjectScale(const std::string& object_name) const = 0;
virtual bool setObjectPose(const std::string& object_name, const Pose& pose, bool teleport) = 0;
Expand All @@ -79,6 +81,7 @@ namespace airlib
virtual vector<MeshPositionVertexBuffersResponse> getMeshPositionVertexBuffers() const = 0;

virtual bool createVoxelGrid(const Vector3r& position, const int& x_size, const int& y_size, const int& z_size, const float& res, const std::string& output_file) = 0;
virtual Vector3r findLookAtRotation(const std::string& vehicle_name, const std::string& object_name) = 0;

// Recording APIs
virtual void startRecording() = 0;
Expand Down
10 changes: 10 additions & 0 deletions AirLib/src/api/RpcLibClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,11 @@ __pragma(warning(disable : 4239))
return pimpl_->client.call("simListSceneObjects", name_regex).as<vector<string>>();
}

vector<string> RpcLibClientBase::simListSceneObjectsByTag(const string& tag_regex) const
{
return pimpl_->client.call("simListSceneObjectsByTag", tag_regex).as<vector<string>>();
}

std::vector<std::string> RpcLibClientBase::simSwapTextures(const std::string& tags, int tex_id, int component_id, int material_id)
{
return pimpl_->client.call("simSwapTextures", tags, tex_id, component_id, material_id).as<vector<string>>();
Expand Down Expand Up @@ -578,6 +583,11 @@ __pragma(warning(disable : 4239))
return pimpl_->client.call("simCreateVoxelGrid", RpcLibAdaptorsBase::Vector3r(position), x, y, z, res, output_file).as<bool>();
}

msr::airlib::Vector3r RpcLibClientBase::simFindLookAtRotation(const std::string& vehicle_name, const std::string& object_name) const
{
return pimpl_->client.call("simFindLookAtRotation", vehicle_name, object_name).as<RpcLibAdaptorsBase::Vector3r>().to();
}

void RpcLibClientBase::cancelLastTask(const std::string& vehicle_name)
{
pimpl_->client.call("cancelLastTask", vehicle_name);
Expand Down
9 changes: 9 additions & 0 deletions AirLib/src/api/RpcLibServerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ namespace airlib
return getWorldSimApi()->listSceneObjects(name_regex);
});

pimpl_->server.bind("simListSceneObjectsByTag", [&](const std::string& tag_regex) -> std::vector<string> {
return getWorldSimApi()->listSceneObjectsByTag(tag_regex);
});

pimpl_->server.bind("simLoadLevel", [&](const std::string& level_name) -> bool {
return getWorldSimApi()->loadLevel(level_name);
});
Expand Down Expand Up @@ -512,6 +516,11 @@ namespace airlib
return getWorldSimApi()->getSettingsString();
});

pimpl_->server.bind("simFindLookAtRotation", [&](const std::string& vehicle_name, const std::string& object_name) -> RpcLibAdaptorsBase::Vector3r {
const auto& rot = getWorldSimApi()->findLookAtRotation(vehicle_name, object_name);
return RpcLibAdaptorsBase::Vector3r(rot);
});

//if we don't suppress then server will bomb out for exceptions raised by any method
pimpl_->server.suppress_exceptions(true);
}
Expand Down
17 changes: 17 additions & 0 deletions PythonClient/airsim/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,20 @@ def simListSceneObjects(self, name_regex = '.*'):
"""
return self.client.call('simListSceneObjects', name_regex)

def simListSceneObjectsByTag(self, tag_regex = '.*'):
"""
Lists the objects present in the environment by searching their tags
Default behaviour is to list all objects, regex can be used to return smaller list of matching objects or actors
Args:
tag_regex (str, optional): String to match actor tags against, e.g. "Tag.*"
Returns:
list[str]: List containing all the names
"""
return self.client.call('simListSceneObjectsByTag', tag_regex)

def simLoadLevel(self, level_name):
"""
Loads a level specified by its name
Expand Down Expand Up @@ -1123,6 +1137,9 @@ def simSetExtForce(self, ext_force):
"""
self.client.call('simSetExtForce', ext_force)

def simFindLookAtRotation(self, object_name, vehicle_name = ''):
return self.client.call('simFindLookAtRotation', vehicle_name, object_name)

# ----------------------------------- Multirotor APIs ---------------------------------------------
class MultirotorClient(VehicleClient, object):
def __init__(self, ip = "", port = 41451, timeout_value = 3600):
Expand Down
3 changes: 2 additions & 1 deletion PythonClient/multirotor/add_drone.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import airsim
import tempfile
import os
import random
import numpy as np
import cv2
import pprint
Expand All @@ -11,7 +12,7 @@
client.confirmConnection()

# add new vehicle
vehicle_name = "Drone2"
vehicle_name = "Drone2" + str(random.randrange(100))
pose = airsim.Pose(airsim.Vector3r(0, 0, 0), airsim.to_quaternion(0, 0, 0))

client.simAddVehicle(vehicle_name, "simpleflight", pose)
Expand Down
2 changes: 1 addition & 1 deletion PythonClient/multirotor/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

# AirSim uses NED coordinates so negative axis is up.
# z of -5 is 5 meters above the original launch point.
z = -5
z = -30
print("make sure we are hovering at {} meters...".format(-z))
client.moveToZAsync(z, 1).join()

Expand Down
58 changes: 29 additions & 29 deletions Unreal/Environments/Blocks/Blocks.uproject
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"FileVersion": 3,
"EngineAssociation": "5.1",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "Blocks",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"AirSim"
]
}
],
"Plugins": [
{
"Name": "AirSim",
"Enabled": true
},
{
"Name": "SteamVR",
"Enabled": false
},
{
"Name": "OculusVR",
"Enabled": false
}
]
{
"FileVersion": 3,
"EngineAssociation": "5.3",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "Blocks",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"AirSim"
]
}
],
"Plugins": [
{
"Name": "AirSim",
"Enabled": true
},
{
"Name": "SteamVR",
"Enabled": false
},
{
"Name": "OculusVR",
"Enabled": false
}
]
}
1 change: 1 addition & 0 deletions Unreal/Environments/Blocks/Config/DefaultEditor.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ bReplaceBlueprintWithClass= true
bDontLoadBlueprintOutsideEditor= true
bBlueprintIsNotBlueprintType= true

[/Script/AdvancedPreviewScene.SharedProfiles]

13 changes: 13 additions & 0 deletions Unreal/Environments/Blocks/Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,17 @@ AsyncSceneSmoothingFactor=0.990000
InitialAverageFrameRate=0.016667
PhysXTreeRebuildRate=10

[/Script/AndroidFileServerEditor.AndroidFileServerRuntimeSettings]
bEnablePlugin=True
bAllowNetworkConnection=True
SecurityToken=811F8F1C4E41692A119A55BE04E6DB61
bIncludeInShipping=False
bAllowExternalStartInShipping=False
bCompileAFSProject=False
bUseCompression=False
bLogFiles=False
bReportStats=False
ConnectionType=USBOnly
bUseManualIPAddress=False
ManualIPAddress=

80 changes: 73 additions & 7 deletions Unreal/Environments/Blocks/Config/DefaultInput.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,86 @@
[/Script/Engine.InputSettings]
-AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
-AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
-AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
+AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
bAltEnterTogglesFullscreen=True
bF11TogglesFullscreen=True
bUseMouseForTouch=False
bEnableMouseSmoothing=True
bEnableFOVScaling=True
FOVScale=0.011110
DoubleClickTime=0.200000
bCaptureMouseOnLaunch=False
DefaultViewportMouseCaptureMode=NoCapture
bDefaultViewportMouseLock=False
DefaultViewportMouseLockMode=DoNotLock
bEnableLegacyInputScales=True
bEnableMotionControls=True
bFilterInputByPlatformUser=False
bEnableInputDeviceSubsystem=True
bShouldFlushPressedKeysOnViewportFocusLost=True
bEnableDynamicComponentInputBinding=True
bAlwaysShowTouchInterface=False
bShowConsoleOnFourFingerTap=True
bEnableGestureRecognizer=False
bUseAutocorrect=False
DefaultViewportMouseCaptureMode=NoCapture
DefaultViewportMouseLockMode=DoNotLock
FOVScale=0.011110
DoubleClickTime=0.200000
DefaultPlayerInputClass=/Script/EnhancedInput.EnhancedPlayerInput
DefaultInputComponentClass=/Script/EnhancedInput.EnhancedInputComponent
DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks
ConsoleKey=None
-ConsoleKeys=Tilde
+ConsoleKeys=Tilde


2 changes: 1 addition & 1 deletion Unreal/Environments/Blocks/Source/Blocks.Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public BlocksTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
ExtraModuleNames.AddRange(new string[] { "Blocks" });

DefaultBuildSettings = BuildSettingsVersion.V4;
//bUseUnityBuild = false;
if (Target.Platform == UnrealTargetPlatform.Linux)
bUsePCHFiles = false;
Expand Down
2 changes: 1 addition & 1 deletion Unreal/Environments/Blocks/Source/BlocksEditor.Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public BlocksEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
ExtraModuleNames.AddRange(new string[] { "Blocks" });
DefaultBuildSettings = BuildSettingsVersion.V2;
DefaultBuildSettings = BuildSettingsVersion.V4;
//bUseUnityBuild = false;
//bUsePCHFiles = false;
}
Expand Down
Loading

0 comments on commit 499f0e8

Please sign in to comment.