Skip to content

Commit

Permalink
[Unity] Remove unused CarPawn references
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat2004 committed Mar 7, 2021
1 parent 5c8f9d8 commit 456e71c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

#include "vehicles/car/api/CarApiBase.hpp"
#include "physics/Kinematics.hpp"
#include "CarPawn.h"

class CarPawnApi
{
public:
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);
Expand All @@ -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_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CarPawn*>(params.pawn), params.home_geopoint);
joystick_controls_ = msr::airlib::CarApiBase::CarControls();
}

void CarPawnSimApi::initialize()
{
PawnSimApi::initialize();

createVehicleApi(static_cast<CarPawn*>(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<UnitySensorFactory> sensor_factory = std::make_shared<UnitySensorFactory>(car_name_, &getNedTransform());

vehicle_api_ = CarApiFactory::createApi(getVehicleSetting(), sensor_factory, (*getGroundTruthKinematics()),
(*getGroundTruthEnvironment()), home_geopoint);
pawn_api_ = std::unique_ptr<CarPawnApi>(new CarPawnApi(pawn, getGroundTruthKinematics(), car_name_, vehicle_api_.get()));
pawn_api_ = std::unique_ptr<CarPawnApi>(new CarPawnApi(getGroundTruthKinematics(), car_name_, vehicle_api_.get()));
}

std::string CarPawnSimApi::getRecordFileLine(bool is_header_line) const
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include "CarPawn.h"
#include "CarPawnApi.h"
#include "../../PawnSimApi.h"
#include "vehicles/car/api/CarApiBase.hpp"
Expand All @@ -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;
Expand All @@ -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_;
};
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@ UnityPawn* SimModeCar::GetVehiclePawn()

std::unique_ptr<PawnSimApi> SimModeCar::createVehicleSimApi(const PawnSimApi::Params& pawn_sim_api_params) const
{
auto vehicle_pawn = static_cast<TVehiclePawn*>(pawn_sim_api_params.pawn);
// auto vehicle_pawn = static_cast<TVehiclePawn*>(pawn_sim_api_params.pawn);

auto vehicle_sim_api = std::unique_ptr<PawnSimApi>(new CarPawnSimApi(pawn_sim_api_params,
vehicle_pawn->getKeyBoardControls(), vehicle_name_));
auto vehicle_sim_api = std::unique_ptr<PawnSimApi>(new CarPawnSimApi(pawn_sim_api_params, vehicle_name_));
vehicle_sim_api->initialize();
vehicle_sim_api->reset();
return vehicle_sim_api;
Expand Down

0 comments on commit 456e71c

Please sign in to comment.