123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- //
- // Created by huli on 2020/9/8.
- //
- #include "common_data.h"
- void Common_data::copy_data(Car_measure_information& car_measure_information_out, const message::Locate_information& locate_information_in)
- {
- if ( locate_information_in.has_locate_x() )
- {
- car_measure_information_out.car_center_x = locate_information_in.locate_x();
- }
- else
- {
- car_measure_information_out.car_center_x = 0;
- }
- if ( locate_information_in.has_locate_y() )
- {
- car_measure_information_out.car_center_y = locate_information_in.locate_y();
- }
- else
- {
- car_measure_information_out.car_center_y = 0;
- }
- if ( locate_information_in.has_locate_angle() )
- {
- car_measure_information_out.car_angle = locate_information_in.locate_angle();
- }
- else
- {
- car_measure_information_out.car_angle = 0;
- }
- if ( locate_information_in.has_locate_length() )
- {
- car_measure_information_out.car_length = locate_information_in.locate_length();
- }
- else
- {
- car_measure_information_out.car_length = 0;
- }
- if ( locate_information_in.has_locate_width() )
- {
- car_measure_information_out.car_width = locate_information_in.locate_width();
- }
- else
- {
- car_measure_information_out.car_width = 0;
- }
- if ( locate_information_in.has_locate_height() )
- {
- car_measure_information_out.car_height = locate_information_in.locate_height();
- }
- else
- {
- car_measure_information_out.car_height = 0;
- }
- if ( locate_information_in.has_locate_wheel_base() )
- {
- car_measure_information_out.car_wheel_base = locate_information_in.locate_wheel_base();
- }
- else
- {
- car_measure_information_out.car_wheel_base = 0;
- }
- if ( locate_information_in.has_locate_wheel_width() )
- {
- car_measure_information_out.car_wheel_width = locate_information_in.locate_wheel_width();
- }
- else
- {
- car_measure_information_out.car_wheel_width = 0;
- }
- if ( locate_information_in.has_locate_front_theta() )
- {
- car_measure_information_out.car_front_theta = locate_information_in.locate_front_theta();
- }
- else
- {
- car_measure_information_out.car_front_theta = 0;
- }
- if ( locate_information_in.has_locate_correct() )
- {
- car_measure_information_out.correctness = locate_information_in.locate_correct();
- }
- else
- {
- car_measure_information_out.correctness = false;
- }
- }
- void Common_data::copy_data(message::Locate_information& locate_information_out, const Car_measure_information& car_measure_information_in)
- {
- locate_information_out.set_locate_x(car_measure_information_in.car_center_x);
- locate_information_out.set_locate_y(car_measure_information_in.car_center_y);
- locate_information_out.set_locate_angle(car_measure_information_in.car_angle);
- locate_information_out.set_locate_length(car_measure_information_in.car_length);
- locate_information_out.set_locate_width(car_measure_information_in.car_width);
- locate_information_out.set_locate_height(car_measure_information_in.car_height);
- locate_information_out.set_locate_wheel_base(car_measure_information_in.car_wheel_base);
- locate_information_out.set_locate_wheel_width(car_measure_information_in.car_wheel_width);
- locate_information_out.set_locate_front_theta(car_measure_information_in.car_front_theta);
- locate_information_out.set_locate_correct(car_measure_information_in.correctness);
- }
- void Common_data::copy_data(Car_information& car_information_out, const message::Car_info& car_info_in)
- {
- if ( car_info_in.has_license() )
- {
- car_information_out.license = car_info_in.license();
- }
- else
- {
- car_information_out.license.clear();
- }
- if ( car_info_in.has_car_length() )
- {
- car_information_out.car_length = car_info_in.car_length();
- }
- else
- {
- car_information_out.car_length = 0;
- }
- if ( car_info_in.has_car_width() )
- {
- car_information_out.car_width = car_info_in.car_width();
- }
- else
- {
- car_information_out.car_width = 0;
- }
- if ( car_info_in.has_car_height() )
- {
- car_information_out.car_height = car_info_in.car_height();
- }
- else
- {
- car_information_out.car_height = 0;
- }
- if ( car_info_in.has_car_wheel_base() )
- {
- car_information_out.car_wheel_base = car_info_in.car_wheel_base();
- }
- else
- {
- car_information_out.car_wheel_base = 0;
- }
- if ( car_info_in.has_car_wheel_width() )
- {
- car_information_out.car_wheel_width = car_info_in.car_wheel_width();
- }
- else
- {
- car_information_out.car_wheel_width = 0;
- }
- }
- void Common_data::copy_data(message::Car_info& car_info_out, const Car_information& car_information_in)
- {
- car_info_out.set_license(car_information_in.license);
- car_info_out.set_car_length(car_information_in.car_length);
- car_info_out.set_car_width(car_information_in.car_width);
- car_info_out.set_car_height(car_information_in.car_height);
- car_info_out.set_car_wheel_base(car_information_in.car_wheel_base);
- car_info_out.set_car_wheel_width(car_information_in.car_wheel_width);
- }
- void Common_data::copy_data(Parkspace_information& parkspace_information_out, const message::Parkspace_info& parkspace_info_in)
- {
- parkspace_information_out.parkingspace_index_id = parkspace_info_in.parkingspace_index_id();
- parkspace_information_out.parkingspace_type = (Common_data::Parkspace_type)parkspace_info_in.parkingspace_type();
- parkspace_information_out.parkingspace_unit_id = parkspace_info_in.parkingspace_unit_id();
- parkspace_information_out.parkingspace_floor_id = parkspace_info_in.parkingspace_floor_id();
- parkspace_information_out.parkingspace_room_id = parkspace_info_in.parkingspace_room_id();
- parkspace_information_out.parkingspace_direction = (Common_data::Direction)parkspace_info_in.parkingspace_direction();
- parkspace_information_out.parkingspace_width = parkspace_info_in.parkingspace_width();
- parkspace_information_out.parkingspace_height = parkspace_info_in.parkingspace_height();
- parkspace_information_out.parkingspace_status = (Common_data::Parkspace_status)parkspace_info_in.parkingspace_status();
- copy_data(parkspace_information_out.car_information, (message::Car_info&) parkspace_info_in.car_info());
- parkspace_information_out.car_entry_time = parkspace_info_in.entry_time();
- parkspace_information_out.car_leave_time = parkspace_info_in.leave_time();
- parkspace_information_out.parkspace_path = (Common_data::Parkspace_path)parkspace_info_in.parkspace_path();
- parkspace_information_out.path_estimate_time = parkspace_info_in.path_estimate_time();
- parkspace_information_out.parkspace_status_target = (Common_data::Parkspace_status)parkspace_info_in.parkspace_status_target();
- }
- void Common_data::copy_data(message::Parkspace_info& parkspace_info_out, const Parkspace_information& parkspace_information_in)
- {
- parkspace_info_out.set_parkingspace_index_id(parkspace_information_in.parkingspace_index_id);
- parkspace_info_out.set_parkingspace_type((message::Parkspace_type)parkspace_information_in.parkingspace_type);
- parkspace_info_out.set_parkingspace_unit_id(parkspace_information_in.parkingspace_unit_id);
- parkspace_info_out.set_parkingspace_room_id(parkspace_information_in.parkingspace_room_id);
- parkspace_info_out.set_parkingspace_direction((message::Direction)parkspace_information_in.parkingspace_direction);
- parkspace_info_out.set_parkingspace_floor_id(parkspace_information_in.parkingspace_floor_id);
- parkspace_info_out.set_parkingspace_width(parkspace_information_in.parkingspace_width);
- parkspace_info_out.set_parkingspace_height(parkspace_information_in.parkingspace_height);
- parkspace_info_out.set_parkingspace_status((message::Parkspace_status)parkspace_information_in.parkingspace_status);
- copy_data(*parkspace_info_out.mutable_car_info(), parkspace_information_in.car_information);
- parkspace_info_out.set_entry_time(parkspace_information_in.car_entry_time);
- parkspace_info_out.set_leave_time(parkspace_information_in.car_leave_time);
- parkspace_info_out.set_parkspace_path((message::Parkspace_path)parkspace_information_in.parkspace_path);
- parkspace_info_out.set_path_estimate_time(parkspace_information_in.path_estimate_time);
- parkspace_info_out.set_parkspace_status_target((message::Parkspace_status)parkspace_information_in.parkspace_status_target);
- }
- void Common_data::transform_data(Car_information& car_information_out, const Car_measure_information& car_measure_information_in)
- {
- car_information_out.license.clear();
- car_information_out.car_length = car_measure_information_in.car_length;
- car_information_out.car_width = car_measure_information_in.car_width;
- car_information_out.car_height = car_measure_information_in.car_height;
- car_information_out.car_wheel_base = car_measure_information_in.car_wheel_base;
- car_information_out.car_wheel_width = car_measure_information_in.car_wheel_width;
- }
- void Common_data::transform_data(Car_measure_information& car_measure_information_out, const Car_information& car_informatio_in)
- {
- car_measure_information_out.car_center_x = 0;
- car_measure_information_out.car_center_y = 0;
- car_measure_information_out.car_angle = 0;
- car_measure_information_out.car_length = car_informatio_in.car_length;
- car_measure_information_out.car_width = car_informatio_in.car_width;
- car_measure_information_out.car_height = car_informatio_in.car_height;
- car_measure_information_out.car_wheel_base = car_informatio_in.car_wheel_base;
- car_measure_information_out.car_wheel_width = car_informatio_in.car_wheel_width;
- car_measure_information_out.car_front_theta = 0;
- car_measure_information_out.correctness = false;
- }
- void Common_data::transform_data(Car_wheel_information& car_wheel_information_out, const Car_measure_information& car_measure_information_in)
- {
- car_wheel_information_out.car_center_x = car_measure_information_in.car_center_x;
- car_wheel_information_out.car_center_y = car_measure_information_in.car_center_y;
- car_wheel_information_out.car_angle = car_measure_information_in.car_angle;
- car_wheel_information_out.car_wheel_base = car_measure_information_in.car_wheel_base;
- car_wheel_information_out.car_wheel_width = car_measure_information_in.car_wheel_width;
- car_wheel_information_out.car_front_theta = car_measure_information_in.car_front_theta;
- car_wheel_information_out.correctness = car_measure_information_in.correctness;
- }
- void Common_data::transform_data(Car_measure_information& car_measure_information_out, const Car_wheel_information& car_wheel_information_in)
- {
- car_measure_information_out.car_center_x = car_wheel_information_in.car_center_x;
- car_measure_information_out.car_center_y = car_wheel_information_in.car_center_y;
- car_measure_information_out.car_angle = car_wheel_information_in.car_angle;
- car_measure_information_out.car_length = 0;
- car_measure_information_out.car_width = 0;
- car_measure_information_out.car_height = 0;
- car_measure_information_out.car_wheel_base = car_wheel_information_in.car_wheel_base;
- car_measure_information_out.car_wheel_width = car_wheel_information_in.car_wheel_width;
- car_measure_information_out.car_front_theta = car_wheel_information_in.car_front_theta;
- car_measure_information_out.correctness = car_wheel_information_in.correctness;
- }
- void Common_data::scaling(Car_measure_information& car_measure_information, float rate)
- {
- car_measure_information.car_center_x *= rate;
- car_measure_information.car_center_y *= rate;
- car_measure_information.car_length *= rate;
- car_measure_information.car_width *= rate;
- car_measure_information.car_height *= rate;
- car_measure_information.car_wheel_base *= rate;
- car_measure_information.car_wheel_width *= rate;
- }
- void Common_data::scaling(Car_information& car_information, float rate)
- {
- car_information.car_length *= rate;
- car_information.car_width *= rate;
- car_information.car_height *= rate;
- car_information.car_wheel_base *= rate;
- car_information.car_wheel_width *= rate;
- }
- void Common_data::scaling(Parkspace_information& parkspace_information, float rate)
- {
- parkspace_information.parkingspace_width *= rate;
- parkspace_information.parkingspace_height *= rate;
- scaling(parkspace_information.car_information, rate);
- }
- bool Common_data::approximate_rate(float a, float b, float rate)
- {
- if ( a >= b*(1-rate) && a< b*(1+rate))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- bool Common_data::approximate_difference(float a, float b, float difference)
- {
- if ( a >= (b-difference) && a< (b+difference) )
- {
- return true;
- }
- else
- {
- return false;
- }
- }
|