Skip to content

Commit

Permalink
fixed car controls in log: microsoft#869
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Mar 14, 2018
1 parent 25ff1db commit 349841c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
25 changes: 12 additions & 13 deletions Unreal/Plugins/AirSim/Source/Car/CarPawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ void ACarPawn::Tick(float Delta)

void ACarPawn::updateCarControls()
{
const msr::airlib::CarApiBase::CarControls* current_controls = nullptr;
if (wrapper_->getRemoteControlID() >= 0 && joystick_state_.is_initialized) {
joystick_.getJoyStickState(0, joystick_state_);

Expand Down Expand Up @@ -442,25 +441,25 @@ void ACarPawn::updateCarControls()
}

UAirBlueprintLib::LogMessageString("Control Mode: ", "Wheel/Joystick", LogDebugLevel::Informational);
current_controls = &joystick_controls_;
current_controls_ = joystick_controls_;
}
else {
UAirBlueprintLib::LogMessageString("Control Mode: ", "Keyboard", LogDebugLevel::Informational);
current_controls = &keyboard_controls_;
current_controls_ = keyboard_controls_;
}

if (!api_->isApiControlEnabled()) {
api_->setCarControls(* current_controls);
api_->setCarControls(current_controls_);
}
else {
UAirBlueprintLib::LogMessageString("Control Mode: ", "API", LogDebugLevel::Informational);
current_controls = & api_->getCarControls();
current_controls_ = api_->getCarControls();
}
UAirBlueprintLib::LogMessageString("Accel: ", std::to_string(current_controls->throttle), LogDebugLevel::Informational);
UAirBlueprintLib::LogMessageString("Break: ", std::to_string(current_controls->brake), LogDebugLevel::Informational);
UAirBlueprintLib::LogMessageString("Steering: ", std::to_string(current_controls->steering), LogDebugLevel::Informational);
UAirBlueprintLib::LogMessageString("Handbreak: ", std::to_string(current_controls->handbrake), LogDebugLevel::Informational);
UAirBlueprintLib::LogMessageString("Target Gear: ", std::to_string(current_controls->manual_gear), LogDebugLevel::Informational);
UAirBlueprintLib::LogMessageString("Accel: ", std::to_string(current_controls_.throttle), LogDebugLevel::Informational);
UAirBlueprintLib::LogMessageString("Break: ", std::to_string(current_controls_.brake), LogDebugLevel::Informational);
UAirBlueprintLib::LogMessageString("Steering: ", std::to_string(current_controls_.steering), LogDebugLevel::Informational);
UAirBlueprintLib::LogMessageString("Handbreak: ", std::to_string(current_controls_.handbrake), LogDebugLevel::Informational);
UAirBlueprintLib::LogMessageString("Target Gear: ", std::to_string(current_controls_.manual_gear), LogDebugLevel::Informational);
}

void ACarPawn::BeginPlay()
Expand Down Expand Up @@ -552,9 +551,9 @@ std::string ACarPawn::getLogString()

std::string logString = std::to_string(timestamp_millis).append("\t")
.append(std::to_string(KPH_int).append("\t"))
.append(std::to_string(keyboard_controls_.throttle)).append("\t")
.append(std::to_string(keyboard_controls_.steering)).append("\t")
.append(std::to_string(keyboard_controls_.brake)).append("\t")
.append(std::to_string(current_controls_.throttle)).append("\t")
.append(std::to_string(current_controls_.steering)).append("\t")
.append(std::to_string(current_controls_.brake)).append("\t")
.append(gear).append("\t");

return logString;
Expand Down
1 change: 1 addition & 0 deletions Unreal/Plugins/AirSim/Source/Car/CarPawn.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class ACarPawn : public AWheeledVehicle

CarPawnApi::CarControls keyboard_controls_;
CarPawnApi::CarControls joystick_controls_;
CarPawnApi::CarControls current_controls_;

SimJoyStick joystick_;
SimJoyStick::State joystick_state_;
Expand Down

0 comments on commit 349841c

Please sign in to comment.