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 int get_target_speed(); 00042 protected: 00043 int car_id; 00044 int target_speed; 00045 AccCar* forward_car; 00046 Road* road; 00047 Thread* thread; 00048 position_msg_t* msg; 00049 mqtt* singleton; 00050 00051 int cycles; 00052 00053 // state of the car... are we crossing driving or stopping? 00054 drive_state_t state; 00055 // just tells us if we are the lead car or not. 00056 // if we are lead car we do not have to worry about anything in front 00057 bool lead; 00058 00059 // update our speed 00060 void update_speed(); 00061 00062 // 00063 void drive_normal(); 00064 00065 // 00066 void get_new_target_speed(); 00067 00068 // 00069 void make_position_msg(position_msg_t* msg); 00070 00071 int enter_safety_mode(); 00072 00073 }; 00074 #endif
Generated on Fri Jul 29 2022 03:44:50 by
1.7.2