
not running
Diff: AccCar.cpp
- Revision:
- 2:16b3bd337db2
- Parent:
- 0:3b4906b8a747
--- a/AccCar.cpp Tue Dec 10 23:40:25 2019 +0000 +++ b/AccCar.cpp Wed Dec 11 20:20:12 2019 +0000 @@ -11,7 +11,7 @@ Serial pc_acc(USBTX, USBRX); -AccCar::AccCar(int id, Road* road, int flag, char* t1, char* t2) { +AccCar::AccCar(int id, Road* road, int flag, Communication* c) { this->id = id; this->road = road; this->flag = flag; @@ -20,11 +20,7 @@ this->forward_car = NULL; this->cycle = 0; - this->comm = Communication::getInstance(); - this->topic_position = t1; - this->topic_control = t2; -// communication->subscribe_to_position(topic_position); - comm->subscribe_to_topic_control(topic_control); + this->comm = c; } void AccCar::set_forward_car(AccCar* car) { @@ -51,9 +47,12 @@ speed = target_speed; } // TODO: publish Position and Acc-speed - comm->publish_car(topic_position, speed, position); - Communication::control_flags.wait_all(flag); // wait for speed instruction from controller - speed = Communication::speeds[id - 1]; + if (position < 255) { + comm->publish_car(id, speed, position); + Communication::control_flags.wait_all(flag); // wait for speed instruction from controller + speed = Communication::speeds[id - 1]; + pc_acc.printf("Suggested speed: %d\r\n", speed); + } // // Crossing // if (position < STOP) { // speed = std::min(speed, STOP - position);