Skip to content
Snippets Groups Projects
PlatoonController.h 1.53 KiB
Newer Older
Hoop77's avatar
-
Hoop77 committed
//
// Created by philipp on 12.02.18.
//

#ifndef CAR_PLATOONCONTROLLER_H
#define CAR_PLATOONCONTROLLER_H

Franz Bethke's avatar
Franz Bethke committed
#include <functional>

#include "PlatoonProtocolLib/VehicleFacade.h"
Franz Bethke's avatar
Franz Bethke committed
#include "PlatoonProtocolLib/Protocol.h"
#include "PC2CarLib/CommandReceiver.h"
#include "EgoMotion.h"
Franz Bethke's avatar
Franz Bethke committed
#include "PlatoonState.h"
#include <atomic>
Franz Bethke's avatar
Franz Bethke committed
#include <chrono>
Hoop77's avatar
-
Hoop77 committed
namespace car
{

class PlatoonController
{
public:
Franz Bethke's avatar
Franz Bethke committed
    using Callback = std::function<void()>;
Hoop77's avatar
-  
Hoop77 committed

    PlatoonController(platoonProtocol::VehicleFacade & c2c,
                      pc2car::CommandReceiver::Ptr pc,
Hoop77's avatar
-  
Hoop77 committed
                      EgoMotion & egoMotion);

Hoop77's avatar
-  
Hoop77 committed
    void run();
Hoop77's avatar
-  
Hoop77 committed

    Callback cruiseControllerNotify;
Hoop77's avatar
-  
Hoop77 committed

    // TODO make values ATOMIC !
Franz Bethke's avatar
Franz Bethke committed
    // these value need to be stored and atomic, since they will be pulled from other modules
    PlatoonState curState = PlatoonState::ACC;
Hoop77's avatar
-  
Hoop77 committed

Franz Bethke's avatar
Franz Bethke committed
    platoonProtocol::PlatoonConfig platoonConfig; // TODO needs to be removed, once C2C returns TimedValues
Hoop77's avatar
-
Hoop77 committed

private:
Hoop77's avatar
-  
Hoop77 committed
    platoonProtocol::VehicleFacade & c2c;
Franz Bethke's avatar
Franz Bethke committed
    pc2car::CommandReceiver::Ptr pc;
Hoop77's avatar
-  
Hoop77 committed
    EgoMotion & egoMotion;
    bool c2cAlive = false;
Franz Bethke's avatar
Franz Bethke committed
    // void updateC2cConfig(); // once C2C returns TimedValues
Hoop77's avatar
-  
Hoop77 committed

Franz Bethke's avatar
Franz Bethke committed
    void updatePcConfig();
Hoop77's avatar
-  
Hoop77 committed

    networking::time::TimedValue<platoonProtocol::PlatoonSpeed> PS{0.0f};
    networking::time::TimedValue<platoonProtocol::InnerPlatoonDistance> IPD{0.0f};

Franz Bethke's avatar
Franz Bethke committed
    void updateDesSpeed();
Hoop77's avatar
-  
Hoop77 committed

    networking::time::TimedValue<float> desSpeed{0.0f};

Franz Bethke's avatar
Franz Bethke committed

    void setupC2C();
Hoop77's avatar
-  
Hoop77 committed

Franz Bethke's avatar
Franz Bethke committed
    // METHODS
    void run_ACC();
Hoop77's avatar
-  
Hoop77 committed

Franz Bethke's avatar
Franz Bethke committed
    void run_CACC_FV();
Hoop77's avatar
-  
Hoop77 committed

Franz Bethke's avatar
Franz Bethke committed
    void run_CACC_LV();
Hoop77's avatar
-  
Hoop77 committed

Hoop77's avatar
-
Hoop77 committed
};

}

#endif //CAR_PLATOONCONTROLLER_H