Skip to content
Snippets Groups Projects
PlatoonController.h 1.59 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()>;
    
    PlatoonController(platoonProtocol::VehicleFacade& c2c,
                      pc2car::CommandReceiver::Ptr pc,
                      EgoMotion& egoMotion);
Franz Bethke's avatar
Franz Bethke committed
      
Hoop77's avatar
-  
Hoop77 committed
    void run();

    float getDesSpeed() { return desSpeed.get(); }
    Callback cruiseControllerNotify;
     
    // 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;
    
    platoonProtocol::PlatoonConfig platoonConfig; // TODO needs to be removed, once C2C returns TimedValues
Hoop77's avatar
-
Hoop77 committed

private:
    platoonProtocol::VehicleFacade& c2c;
Franz Bethke's avatar
Franz Bethke committed
    pc2car::CommandReceiver::Ptr pc;
    EgoMotion& egoMotion;

    bool c2cAlive = false;
Franz Bethke's avatar
Franz Bethke committed
    // void updateC2cConfig(); // once C2C returns TimedValues
Franz Bethke's avatar
Franz Bethke committed
    void updatePcConfig();
    pc2car::TimedValue<platoonProtocol::PlatoonSpeed>          PS{0.0f};
    pc2car::TimedValue<platoonProtocol::InnerPlatoonDistance> IPD{0.0f};
Franz Bethke's avatar
Franz Bethke committed
    void updateDesSpeed();
    pc2car::TimedValue<float> desSpeed{0.0f};
    
    void setupC2C();
Franz Bethke's avatar
Franz Bethke committed
    
    // METHODS
    void run_ACC();
    void run_CACC_FV();
    void run_CACC_LV();
    
Hoop77's avatar
-
Hoop77 committed
};

}

#endif //CAR_PLATOONCONTROLLER_H