Skip to content

Commit

Permalink
deactivate sound using settings
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Oct 4, 2017
1 parent 31ca47b commit 2eb0e49
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 7 deletions.
2 changes: 0 additions & 2 deletions PythonClient/hello_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
client.enableApiControl(True)
car_controls = CarControls()

client.reset()

for idx in range(3):
# get state of the car
car_state = client.getCarState()
Expand Down
6 changes: 5 additions & 1 deletion Unreal/Plugins/AirSim/Source/Car/CarPawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,12 @@ void ACarPawn::NotifyHit(class UPrimitiveComponent* MyComp, class AActor* Other,
HitNormal, NormalImpulse, Hit);
}

void ACarPawn::initializeForBeginPlay(bool enable_rpc, const std::string& api_server_address)
void ACarPawn::initializeForBeginPlay(bool enable_rpc, const std::string& api_server_address, bool engine_sound)
{
if (engine_sound)
EngineSoundComponent->Activate();
else
EngineSoundComponent->Deactivate();

//put camera little bit above vehicle
FTransform camera_transform(FVector(0, 0, 0));
Expand Down
2 changes: 1 addition & 1 deletion Unreal/Plugins/AirSim/Source/Car/CarPawn.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ACarPawn : public AWheeledVehicle
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

VehiclePawnWrapper* getVehiclePawnWrapper();
void initializeForBeginPlay(bool enable_rpc, const std::string& api_server_address);
void initializeForBeginPlay(bool enable_rpc, const std::string& api_server_address, bool engine_sound);

virtual void NotifyHit(class UPrimitiveComponent* MyComp, class AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation,
FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) override;
Expand Down
2 changes: 1 addition & 1 deletion Unreal/Plugins/AirSim/Source/Car/SimModeCar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void ASimModeCar::setupVehiclesAndCamera(std::vector<VehiclePtr>& vehicles)
{
//initialize each vehicle pawn we found
TVehiclePawn* vehicle_pawn = static_cast<TVehiclePawn*>(pawn);
vehicle_pawn->initializeForBeginPlay(enable_rpc, api_server_address);
vehicle_pawn->initializeForBeginPlay(enable_rpc, api_server_address, engine_sound);

//chose first pawn as FPV if none is designated as FPV
VehiclePawnWrapper* wrapper = vehicle_pawn->getVehiclePawnWrapper();
Expand Down
2 changes: 2 additions & 0 deletions Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void ASimModeBase::readSettings()
usage_scenario = "";
enable_collision_passthrough = false;
clock_type = "";
engine_sound = true;


typedef msr::airlib::Settings Settings;
Expand Down Expand Up @@ -108,6 +109,7 @@ void ASimModeBase::readSettings()
//don't work
api_server_address = settings.getString("LocalHostIp", "");
is_record_ui_visible = settings.getBool("RecordUIVisible", true);
engine_sound = settings.getBool("EngineSound", true);

std::string view_mode_string = settings.getString("ViewMode", "");

Expand Down
1 change: 1 addition & 0 deletions Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class AIRSIM_API ASimModeBase : public AActor
std::string clock_type;
float settings_version_actual;
float settings_version_minimum = 1;
bool engine_sound;


private:
Expand Down
1 change: 1 addition & 0 deletions docs/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Car has followings APIs available:
* `setCarControls`: This allows you to set throttle, steering, handbrake and auto or manual gear.
* `getCarState`: This retrieves the state information including speed, current gear, velocity vector, position and orientation.
* [Image APIs](image_apis.md).
* `reset`: This resets the vehicle to its original starting state.

### APIs for Multirotor
Multirotor can be controlled by specifying angles, velocity vector, destination position or some combination of these. There are corresponding `move*` APIs for this purpose. When doing position control, we need to use some path following algorithm. By default AirSim uses carrot following algorithm. This is often referred to as "high level control" because you just need to specify very high level goal and the firmware takes care of the rest. Currently lowest level control available in AirSim is moveByAngle API however we will be adding more lower level controls soon as well.
Expand Down
6 changes: 5 additions & 1 deletion docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Below are complete list of settings available along with their default values. I
"ViewMode": "",
"UsageScenario": "",
"RpcEnabled": true,
"EngineSound": true,
"PhysicsEngineName": "",
"EnableCollisionPassthrogh": false,
"Recording": {
Expand Down Expand Up @@ -138,7 +139,7 @@ Currently SimMode can be set to `""`, `"Multirotor"` or `"Car"`. The empty strin
#### PhysicsEngineName
For cars, we support only PhysX for now (regardless of value in this setting). For multirotors, we support `"FastPhysicsEngine"` only.

### ViewMode
#### ViewMode
The ViewMode determines how you will view the vehicle. For multirotors, the default ViewMode is `"FlyWithMe"` while for cars the default ViewMode is `"SpringArmChase"`.

* FlyWithMe: Chase the vehicle from behind with 6 degrees of freedom
Expand All @@ -147,6 +148,9 @@ The ViewMode determines how you will view the vehicle. For multirotors, the defa
* Manual: Don't move camera automatically. Use arrow keys and ASWD keys for move camera manually.
* SpringArmChase: Chase the vehicle with camera mounted on (invisible) arm that is attached to the vehicle via spring (so it has some latency in movement).

#### EngineSound
To turn off the engine sound use [setting](settings.md) `"EngineSound": false`. Currently this setting applies only to car.




Expand Down
2 changes: 1 addition & 1 deletion docs/using_car.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ You can control the car, get state and images by calling APIs in variety of clie
By default camera will chase the car from the back. You can get the FPV view by pressing `F` key and switch back to chasing from back view by pressing `/` key. More keyboard shortcuts can be seen by pressing F1.

## Cameras
By default car is installed with 3 cameras: center, left and right. You can chose the images from these camera by specifying the camera ID 0, 1 and 2 respectively.
By default car is installed with 3 cameras: center, left and right. You can chose the images from these camera by specifying the camera ID 0, 1 and 2 respectively.

0 comments on commit 2eb0e49

Please sign in to comment.