#pragma once #include #include #include namespace torcs { constexpr auto IMAGE_WIDTH = 640; constexpr auto IMAGE_HEIGHT = 480; constexpr auto IMAGE_CHANNELS = 1; constexpr auto IMAGE_SIZE_BYTES = IMAGE_WIDTH*IMAGE_HEIGHT*IMAGE_CHANNELS; struct shared_use_st { int written = 0; //a label, if 1: available to read, if 0: available to write uint8_t data[IMAGE_SIZE_BYTES]; // image data field int control = 0; int pause = 0; double fast = 0.0; double dist_L = 0.0; double dist_R = 0.0; double toMarking_L = 0.0; double toMarking_M = 0.0; double toMarking_R = 0.0; double dist_LL = 0.0; double dist_MM = 0.0; double dist_RR = 0.0; double toMarking_LL = 0.0; double toMarking_ML = 0.0; double toMarking_MR = 0.0; double toMarking_RR = 0.0; double toMiddle = 0.0; double angle = 0.0; double speed = 0.0; double steerCmd = 0.0; double accelCmd = 0.0; double brakeCmd = 0.0; }; struct Command { double steerCmd = 0.0; double accelCmd = 0.0; double brakeCmd = 0.0; }; using DataContainer = std::array; class TorcsClient { public: TorcsClient(); std::unique_ptr getScreenshot(); void sendCommand(Command cmd); private: struct shared_use_st *shared; bool connected = false; }; }