diff --git a/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnApi.cpp b/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnApi.cpp index 3112245b07..dbf51d2a1b 100644 --- a/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnApi.cpp +++ b/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnApi.cpp @@ -2,9 +2,9 @@ #include "../../PInvokeWrapper.h" -CarPawnApi::CarPawnApi(CarPawn* pawn, const msr::airlib::Kinematics::State* pawn_kinematics, +CarPawnApi::CarPawnApi(const msr::airlib::Kinematics::State* pawn_kinematics, const std::string car_name, msr::airlib::CarApiBase* vehicle_api) - : pawn_(pawn), pawn_kinematics_(pawn_kinematics), car_name_(car_name), vehicle_api_(vehicle_api) + : pawn_kinematics_(pawn_kinematics), car_name_(car_name), vehicle_api_(vehicle_api) { } diff --git a/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnApi.h b/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnApi.h index 4ec68d3433..6467d1c2b8 100644 --- a/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnApi.h +++ b/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnApi.h @@ -2,7 +2,6 @@ #include "vehicles/car/api/CarApiBase.hpp" #include "physics/Kinematics.hpp" -#include "CarPawn.h" class CarPawnApi { @@ -10,7 +9,7 @@ class CarPawnApi typedef msr::airlib::ImageCaptureBase ImageCaptureBase; public: - CarPawnApi(CarPawn* pawn, const msr::airlib::Kinematics::State* pawn_kinematics, + CarPawnApi(const msr::airlib::Kinematics::State* pawn_kinematics, const std::string car_name, msr::airlib::CarApiBase* vehicle_api); void updateMovement(const msr::airlib::CarApiBase::CarControls& controls); @@ -24,7 +23,6 @@ class CarPawnApi private: msr::airlib::CarApiBase::CarControls last_controls_; - CarPawn* pawn_; const msr::airlib::Kinematics::State* pawn_kinematics_; std::string car_name_; msr::airlib::CarApiBase* vehicle_api_; diff --git a/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnSimApi.cpp b/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnSimApi.cpp index 17cba87077..1fb506b2f2 100644 --- a/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnSimApi.cpp +++ b/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnSimApi.cpp @@ -7,32 +7,28 @@ #include "../../UnitySensors/UnitySensorFactory.h" -CarPawnSimApi::CarPawnSimApi(const Params& params, - const msr::airlib::CarApiBase::CarControls& keyboard_controls, std::string car_name) - : PawnSimApi(params), params_(params), - keyboard_controls_(keyboard_controls), car_name_(car_name) +CarPawnSimApi::CarPawnSimApi(const Params& params, std::string car_name) + : PawnSimApi(params), params_(params), car_name_(car_name) { - createVehicleApi(static_cast(params.pawn), params.home_geopoint); - joystick_controls_ = msr::airlib::CarApiBase::CarControls(); } void CarPawnSimApi::initialize() { PawnSimApi::initialize(); - createVehicleApi(static_cast(params_.pawn), params_.home_geopoint); + createVehicleApi(params_.home_geopoint); //TODO: should do reset() here? joystick_controls_ = msr::airlib::CarApiBase::CarControls(); } -void CarPawnSimApi::createVehicleApi(CarPawn* pawn, const msr::airlib::GeoPoint& home_geopoint) +void CarPawnSimApi::createVehicleApi(const msr::airlib::GeoPoint& home_geopoint) { std::shared_ptr sensor_factory = std::make_shared(car_name_, &getNedTransform()); vehicle_api_ = CarApiFactory::createApi(getVehicleSetting(), sensor_factory, (*getGroundTruthKinematics()), (*getGroundTruthEnvironment()), home_geopoint); - pawn_api_ = std::unique_ptr(new CarPawnApi(pawn, getGroundTruthKinematics(), car_name_, vehicle_api_.get())); + pawn_api_ = std::unique_ptr(new CarPawnApi(getGroundTruthKinematics(), car_name_, vehicle_api_.get())); } std::string CarPawnSimApi::getRecordFileLine(bool is_header_line) const @@ -77,9 +73,9 @@ void CarPawnSimApi::updateRendering(float dt) PawnSimApi::updateRendering(dt); updateCarControls(); - for (auto i = 0; i < vehicle_api_messages_.size(); ++i) + for (const auto& message : vehicle_api_messages_) { - PrintLogMessage(vehicle_api_messages_[i].c_str(), "LogDebugLevel::Success", car_name_.c_str(), ErrorLogSeverity::Information); + PrintLogMessage(message.c_str(), "LogDebugLevel::Success", car_name_.c_str(), ErrorLogSeverity::Information); } try @@ -146,7 +142,7 @@ void CarPawnSimApi::updateCarControls() else { PrintLogMessage("Control Mode: ", "Keyboard", getVehicleName().c_str(), ErrorLogSeverity::Information); - current_controls_ = keyboard_controls_; + // current_controls_ = keyboard_controls_; } bool api_enabled = vehicle_api_->isApiControlEnabled(); diff --git a/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnSimApi.h b/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnSimApi.h index b63f60b554..281ac5a29a 100644 --- a/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnSimApi.h +++ b/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/CarPawnSimApi.h @@ -1,6 +1,5 @@ #pragma once -#include "CarPawn.h" #include "CarPawnApi.h" #include "../../PawnSimApi.h" #include "vehicles/car/api/CarApiBase.hpp" @@ -15,12 +14,12 @@ class CarPawnSimApi : public PawnSimApi typedef msr::airlib::Pose Pose; private: - void createVehicleApi(CarPawn* pawn, const msr::airlib::GeoPoint& home_geopoint); + void createVehicleApi(const msr::airlib::GeoPoint& home_geopoint); void updateCarControls(); public: virtual void initialize() override; - CarPawnSimApi(const Params& params, const msr::airlib::CarApiBase::CarControls& keyboard_controls, std::string car_name); + CarPawnSimApi(const Params& params, std::string car_name); virtual ~CarPawnSimApi() = default; virtual void update() override; @@ -46,7 +45,4 @@ class CarPawnSimApi : public PawnSimApi msr::airlib::CarApiBase::CarControls joystick_controls_; msr::airlib::CarApiBase::CarControls current_controls_; std::string car_name_; - - //storing reference from pawn - const msr::airlib::CarApiBase::CarControls& keyboard_controls_; }; diff --git a/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/SimModeCar.cpp b/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/SimModeCar.cpp index 39dbc1d44f..9bc914d065 100644 --- a/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/SimModeCar.cpp +++ b/Unity/AirLibWrapper/AirsimWrapper/Source/Vehicles/Car/SimModeCar.cpp @@ -87,10 +87,9 @@ UnityPawn* SimModeCar::GetVehiclePawn() std::unique_ptr SimModeCar::createVehicleSimApi(const PawnSimApi::Params& pawn_sim_api_params) const { - auto vehicle_pawn = static_cast(pawn_sim_api_params.pawn); + // auto vehicle_pawn = static_cast(pawn_sim_api_params.pawn); - auto vehicle_sim_api = std::unique_ptr(new CarPawnSimApi(pawn_sim_api_params, - vehicle_pawn->getKeyBoardControls(), vehicle_name_)); + auto vehicle_sim_api = std::unique_ptr(new CarPawnSimApi(pawn_sim_api_params, vehicle_name_)); vehicle_sim_api->initialize(); vehicle_sim_api->reset(); return vehicle_sim_api;