Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
AccCar.h
00001 #ifndef _ACC_CAR_H_ 00002 #define _ACC_CAR_H_ 00003 00004 #include "mqtt.h" 00005 #include "mbed.h" 00006 #include "Road.h" 00007 00008 class Road; 00009 00010 class AccCar{ 00011 public: 00012 int position; 00013 int speed; 00014 int flag; 00015 bool waited; 00016 00017 // constructor 00018 AccCar(int id, Road* road, int flag, mqtt* mqtt_singleton); 00019 00020 // sets the car ahead of it 00021 void set_forward_car(AccCar* car); 00022 00023 // main update function where all the logic is held 00024 void update(); 00025 00026 // reset the car 00027 void reset(int speed); 00028 00029 // kill the car essentially 00030 void stop(); 00031 00032 // for breaking continuous right of way ties 00033 int car_clock; 00034 00035 int get_car_id(); 00036 00037 int wait_time; 00038 00039 int get_cycles(); 00040 00041 protected: 00042 int car_id; 00043 int target_speed; 00044 AccCar* forward_car; 00045 Road* road; 00046 Thread* thread; 00047 position_msg_t* msg; 00048 mqtt* singleton; 00049 00050 int cycles; 00051 00052 // state of the car... are we crossing driving or stopping? 00053 drive_state_t state; 00054 // just tells us if we are the lead car or not. 00055 // if we are lead car we do not have to worry about anything in front 00056 bool lead; 00057 00058 // update our speed 00059 void update_speed(); 00060 00061 // 00062 void drive_normal(); 00063 00064 // 00065 void get_new_target_speed(); 00066 00067 // 00068 void make_position_msg(position_msg_t* msg); 00069 00070 }; 00071 #endif
Generated on Wed Jul 13 2022 16:04:36 by
1.7.2