123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- #pragma once
- #include<mutex>
- #include<memory>
- #include <fstream>
- #include<string>
- #include<condition_variable>
- #include <vector>
- #include "protocol.pb.h"
- #include "../common/iobuffer.h"
- #include "../common/socket_client.h"
- #include "../common/sensor_socket.h"
- #include "../common/update_thread.h"
- #include "message.h"
-
- int8_t hi_byte(int16_t value);
- int8_t lo_byte(int16_t value);
- class CRadarSensor;
- class CEncoderSensor;
- class CCarSensor;
- class SocketClient;
- class CPeerConnection;
- //class VideoRenderer;
- //class CAutoSensor;
- enum MessageType:int32_t
- {
- ReqVideo,
- RepVideo,
- Connected,
- Leave,
- StopSensor,
- Ping,
- AsyncMessage,
-
- };
- enum class ParkingState:int32_t
- {
- None,
- Turn,
- Reverse,
- Restore,
- RiseDown,//举升
- // Down, //下降
- TipOut, //倾翻倒出
- TipIn, // 倾倒收回
- TipRise, //倾翻上升
- TipDown,//倾翻下降
-
- };
- struct Message
- {
- MessageType cmd;
- int64_t param_l;
- int64_t param_r;
-
- };
-
- struct LocalCameraInfo
- {
- int32_t index;
- std::string label;
- };
- struct radar_node;
-
- class CIOBuffer;
- enum TurnSide
- {
- Left,
- Right,
- Other
- };
- enum ROUT_LIST
- {
- FRONT_IN_1,
- BACK_IN_1,
- FRONT_OUT_1,
- FRONT_IN_2,
- BACK_IN_2,
- FRONT_OUT_2,
- FRONT_IN_3,
- BACK_IN_3,
- FRONT_OUT_3,
- ROUT_ALL
- };
- class CMessageQueue:public INativeNotify
- {
- public:
- CMessageQueue();
- virtual ~CMessageQueue();
- void Create();
- void EnQueue(CIOBuffer* pBuffer);
- void Process();
- virtual void OnAdd(int32_t uid,bool bRet) override;
- virtual void OnConnected(bool bRet) override;
- // virtual bool IsCarId(int32_t value) override;
- // virtual void WriteCanMessage(std::unordered_map<int32_t, cannet_frame>& node,bool islidar) override;
- #ifdef WIN32
- virtual void OnVideoRep(int32_t index,int32_t peer) override;
- #else
- virtual void OnVideoReq(int32_t index,int32_t peer) override;
- virtual void OnMoveBegin(WorkArea area, int32_t no) override;
- #endif
- virtual void OnVideoOffer(int32_t index,const char* type, const char* sdp) override;
- virtual void OnVideoAnswer(int32_t index, const char* type, const char* sdp) override;
- virtual void OnVideoCandidate(int32_t index,const char* candidate,
- int32_t sdp_mline_index,
- const char* sdp_mid) override;
- /*virtual void OnVideoAddTrack(RemoteVideoTrackWrapper* ptr) = 0;*/
- //virtual void OnCancelReq(int32_t index) override;
- virtual void OnVideoLeave(int32_t peer,EgoType type) override;
-
- virtual void OnSwitchDriver() override;
- virtual void OnMessageFrameNotify(ChannelType type,int16_t cmd,int16_t length,const void * data) override;
- void OnNotifyConnected(bool bRet);
- void OnNotifyReq(int32_t index);
- void OnNotifyRep(int32_t index);
- void OnNotifyStopSensor();
- void OnNotifyLeave();
- void OnNotifyMessage();
- void SetNdtPos(ARNdtPos* pos);
- void SetSteerAngle(int16_t);
- void SetLeftAngle(int16_t);
- void SetRightAngle(int16_t);
- void OnGoalFinish(WorkArea are,int32_t no);
- void OnTip(int16_t value);
- void GetParkCanMessage(TPCANMsg* msg);
- void OnNotifyPing(int64_t value);
- void InitPeerConnection(int32_t peer,int32_t index);
- void WriteBuffer(ChannelType type,CIOBuffer& pBufer);
- void WriteBuffer(CIOBuffer& pBuffer);
- void WriteSensor(radar_node* node,int32_t count);
- // void WriteRadarData(radar_node* data);
- void SetAutomous(bool value,int32_t delay);
- void SwitchCamera(bool front);
- // void WriteRobotStatus(int32_t value,int32_t desc);
- const radar_node* GetRadar();
- void StopAutomous();
- ParkingState GetParkingState();
- void SetParkingState(ParkingState state);
- CarType GetCarType();
- //#ifdef LIDAR_SENSOR
- // void WriteLidarPoint(const PointCloudMsg<PointXYZI>& msg,ChannelType side);
- //#endif
- // void StopCar();
- // void StartCar();
- void CheckSignal();
- void ChangeState(UserState state);
- int32_t GetPeer();
- void TestPark();
- void OnRiseDown(TPCANMsg* msg);
-
- void OnTipRise(TPCANMsg* msg);
- void OnTipDown(TPCANMsg* msg);
- void OnTipOut(TPCANMsg* msg);
- void OnTipIn(TPCANMsg* msg);
- void OnTurn(TPCANMsg* msg);
- void OnReverse(TPCANMsg* msg);
- void OnRestore(TPCANMsg* msg);
- public:
- // void BegRecord();
- // void EndRecord();
- // void PlayRecord(ROUT_LIST index);
- // bool IsRecord(){ return _start_record;}
- // void WriteRecord(TPCANMsg * msg);
-
- private:
- // void LoadRecord(ROUT_LIST dir,const char * file);
-
- // void OnPlayrecord(TPCANMsg* msg);
- // bool _start_record=false;
-
- //bool _start_play=false;
- // ROUT_LIST _rout_index;
- // std::fstream _ofile;
- // std::vector<cannet_frame> frames[ROUT_LIST::ROUT_ALL];
- // int32_t _play_index=0;
- private:
- std::mutex _mlock;
- std::condition_variable _cv;
- CIOBuffer* Head;
- CIOBuffer* Tail;
- // std::unique_ptr<PeerConnectionWrapper> _peer_video;
- std::vector<std::unique_ptr<CPeerConnection> > _peerArray;
- std::vector<LocalCameraInfo> _cameraArray;
-
- //EgoType _egoType;
- //int32_t _indexOffset;
- // std::vector<std::unique_ptr<VideoRenderer> > _windowArray;
- // std::unique_ptr<VideoRenderer> _main_window;
- // std::unique_ptr<VideoRenderer> _arm_window;
- std::unique_ptr<SocketClient> _client;
- std::unique_ptr<SensorSocket<CRadarSensor>> _radar;
- std::unique_ptr<SensorSocket<CEncoderSensor>> _encoder;
- // std::unique_ptr<SensorSocket<CLidarSensor>> _lidar;
- std::unique_ptr<SensorSocket<CCarSensor>> _robot;
- //std::unique_ptr<SensorSocket<CAutoSensor>> _auto;
-
- int32_t _peerId;
- // int32_t _canport;
- // int32_t _hostport;
- // int32_t _lidarport;
- // std::string _canip;
- std::string _serial;
-
- std::string _name;
- CarType _car;
- bool _camera_inited=false;
-
- bool bStopedCar;
- CUpdateThread _updatethread;
- std::mutex _canLock;
- int64_t _curTick;
-
- int32_t _uid=0;
- ParkingState _parking=ParkingState::None;
- std::mutex _pose_lock;
- ARNdtPos _curpos;
-
-
- int16_t _steer_angle;
- FVector3d _initpos;
- WorkArea _workarea=WorkArea::Area_A;
- Metal_Area _metalArea=Metal_Area::Put_Wait;
- int32_t _no=0;
- TurnSide _side=TurnSide::Left;
-
- int16_t _left_length=0;
- int16_t _right_length=0;
- int16_t pre_left_length=-1;
- int16_t pre_right_length=-1;
- //int16_t _tip_length=0;
- int16_t max_left_length=0;
- int16_t max_right_length=0;
- int16_t min_left_length=0;
- int16_t min_right_length=0;
- int32_t tipin_time=0;
- int32_t tipout_time=0;
- int32_t _start_time=0;
- int32_t _diff_degree=30;
- int32_t _angle_value=10;
- int32_t _sq_length=102;
- int32_t _turn_base=1000;
- bool _start_check=false;
-
-
-
-
- };
|