I want to test the PX4 Collision Prevention feature in a simulation environment. For this, I added a lidar to the drone and ensured a specific angle is covered. I populated the data into a variable I created from the px4_msgs::msg::ObstacleDistance message in ROS2 and publish it at certain intervals. However, the vehicle does not arm on the PX4 side. I am sharing the error I received and the parameters I changed via QGC in the images below. (The steps I followed are on this page).
PX4 Output
PX4 Parameter
Gz Sim Lidar Data:
code:
using obstacleDistanceMsg = px4_msgs::msg::ObstacleDistance;
obstacleDistanceMsg obs_distance;
obs_distance.frame = obs_distance.MAV_FRAME_BODY_FRD;
obs_distance.sensor_type = obs_distance.MAV_DISTANCE_SENSOR_LASER;
obs_distance.increment = 1;
obs_distance.min_distance = 8;
obs_distance.max_distance = 600;
obs_distance.angle_offset = -36;
void SensorListener::lidarCallabck(const laserScanMsg::SharedPtr msg)
{
for(int i = 0; i < msg->ranges.size(); i++)
{
obs_distance.distances[i] = std::min(std::max(static_cast<int>(msg->ranges[i] * 1e2), static_cast<int>(obs_distance.min_distance)), static_cast<int>(obs_distance.max_distance));
}
obs_distance.timestamp = px4_time;
obstacle_distance->publish(obs_distance);
}
- The right side is the system’s timestamp value, and the left side is the timestamp value I published.
@hamishwillee , have you done any work related to this?