39 rclcpp::Duration id_timeout(secs * 1e9);
42 std::uniform_int_distribution<int> dis(0,INT_MAX);
44 std::vector<uint8_t> id(4);
55 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"bsm_generator"),
"Newly generated random id: " <<
random_id_);
59 for(
int i = 0;
i <
id.size(); ++
i)
68 return static_cast<uint16_t
>((now.nanoseconds() / 1000000) % 60000);
73 return static_cast<float>(std::max(std::min(speed, 163.8), 0.0));
78 return static_cast<float>(std::max(std::min(angle * 57.2958, 189.0), -189.0));
83 return std::max(std::min(accel, 20.0f), -20.0f);
88 return static_cast<float>(std::max(std::min(yaw_rate, 327.67), -327.67));
93 return brake >= 0.05 ? 0b1111 : 0;
98 return std::max(std::min(heading, 359.9875f), 0.0f);
rclcpp::Time last_id_generation_time_
std::default_random_engine generator_
float getSteerWheelAngleInRange(const double angle)
Function to apply minimum and maximum limits to a steering wheel angle value. Minimum limit is -189....
float getYawRateInRange(const double yaw_rate)
Function to apply minimum and maximum limits to a yaw rate value. Minimum limit is -327....
float getSpeedInRange(const double speed)
Function to apply minimum and maximum limits to a speed value. Minimum limit is 0....
BSMGeneratorWorker()
Default Constructor for BSMGeneratorWorker.
float getLongAccelInRange(const float accel)
Function to apply minimum and maximum limits to a longitudinal acceleration value....
std::vector< uint8_t > getMsgId(const rclcpp::Time now, double secs)
Function to obtain the current BSM message ID. The ID is updated to a new random BSM message ID every...
uint8_t getNextMsgCount()
Function to increment the BSM message counter and obtain the new counter value. Counter restarts at 0...
uint8_t getBrakeAppliedStatus(const double brake)
Function to convert the current applied brake status to a value used within the BSM message.
uint16_t getSecMark(const rclcpp::Time now)
Function to obtain the 'milliseconds' mark of the provided time within the last minute.
float getHeadingInRange(const float heading)
Function to apply minimum and maximum limits to a vehicle heading value. Minimum limit is 0....