17#include <tf2_ros/transform_listener.h> 
   18#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp> 
   19#include <tf2/LinearMath/Quaternion.h> 
   20#include <tf2/transform_datatypes.h> 
   21#include <tf2_ros/transform_listener.h> 
   22#include <tf2_eigen/tf2_eigen.h> 
   29  : obj_pub_(obj_pub), tf_lookup_(tf_lookup), logger_(logger) {}
 
   33  return obj.classification.end() != std::find_if(obj.classification.begin(), obj.classification.end(),
 
   34    [&class_id](
auto o){ return o.classification == class_id; }
 
   42  carma_perception_msgs::msg::ExternalObjectList msg;
 
   43  msg.header = obj_array->header;
 
   50    RCLCPP_WARN_STREAM(
logger_->get_logger(), 
"Ignoring fix message: Could not locate static transforms exception.");
 
   54  geometry_msgs::msg::TransformStamped object_frame_tf = transform.get();
 
   56  for (
size_t i = 0; 
i < obj_array->objects.size(); 
i++)
 
   58    carma_perception_msgs::msg::ExternalObject obj;
 
   61    obj.header = msg.header;
 
   66    obj.presence_vector = obj.presence_vector | obj.ID_PRESENCE_VECTOR;
 
   67    obj.presence_vector = obj.presence_vector | obj.POSE_PRESENCE_VECTOR;
 
   68    obj.presence_vector = obj.presence_vector | obj.VELOCITY_PRESENCE_VECTOR;
 
   69    obj.presence_vector = obj.presence_vector | obj.SIZE_PRESENCE_VECTOR;
 
   70    obj.presence_vector = obj.presence_vector | obj.OBJECT_TYPE_PRESENCE_VECTOR;
 
   71    obj.presence_vector = obj.presence_vector | obj.DYNAMIC_OBJ_PRESENCE;
 
   72    obj.presence_vector = obj.presence_vector | obj.CONFIDENCE_PRESENCE_VECTOR;
 
   75    obj.id = obj_array->objects[
i].object_id;
 
   78    geometry_msgs::msg::PoseStamped input_object_pose;
 
   79    input_object_pose.header = obj_array->header;
 
   80    input_object_pose.pose.position = obj_array->objects[
i].kinematics.centroid_position;
 
   81    input_object_pose.pose.orientation = obj_array->objects[
i].kinematics.orientation;
 
   83    geometry_msgs::msg::PoseStamped output_pose;
 
   85    tf2::doTransform(input_object_pose, output_pose, object_frame_tf);
 
   87    obj.pose.pose = output_pose.pose;
 
   91    auto xx = obj_array->objects[
i].kinematics.position_covariance[0];
 
   92    auto xy = obj_array->objects[
i].kinematics.position_covariance[1];
 
   93    auto xz = obj_array->objects[
i].kinematics.position_covariance[2];
 
   94    auto yx = obj_array->objects[
i].kinematics.position_covariance[3];
 
   95    auto yy = obj_array->objects[
i].kinematics.position_covariance[4];
 
   96    auto yz = obj_array->objects[
i].kinematics.position_covariance[5];
 
   97    auto zx = obj_array->objects[
i].kinematics.position_covariance[6];
 
   98    auto zy = obj_array->objects[
i].kinematics.position_covariance[7];
 
   99    auto zz = obj_array->objects[
i].kinematics.position_covariance[8];
 
  102    std::array<double, 36> input_covariance = {
 
  112    tf2::Transform covariance_transform;
 
  113    tf2::fromMsg(object_frame_tf.transform, covariance_transform);
 
  117    obj.confidence = obj_array->objects[
i].existence_probability;
 
  120    obj.velocity = obj_array->objects[
i].kinematics.twist;
 
  127    double minX = std::numeric_limits<double>::max();
 
  128    double maxX = std::numeric_limits<double>::lowest();
 
  129    double minY = std::numeric_limits<double>::max();
 
  130    double maxY = std::numeric_limits<double>::lowest();
 
  131    double maxHeight = std::numeric_limits<double>::lowest();
 
  133    for(
auto shape : obj_array->objects[
i].shape) {
 
  134      for (
auto point :  shape.polygon.points) {
 
  148      if (shape.height > maxHeight)
 
  149        maxHeight = shape.height;
 
  152    double dX = maxX - minX;
 
  153    double dY = maxY - minY;
 
  155    obj.size.x = dX / 2.0; 
 
  156    obj.size.y = dY / 2.0;
 
  159    obj.size.z = maxHeight / 2.0;
 
  164    if (
isClass(obj_array->objects[
i], autoware_auto_msgs::msg::ObjectClassification::MOTORCYCLE))
 
  166      obj.object_type = obj.MOTORCYCLE;
 
  168    else if (
isClass(obj_array->objects[
i], autoware_auto_msgs::msg::ObjectClassification::BICYCLE))
 
  170      obj.object_type = obj.MOTORCYCLE; 
 
  172    else if (
isClass(obj_array->objects[
i], autoware_auto_msgs::msg::ObjectClassification::CAR))
 
  174      obj.object_type = obj.SMALL_VEHICLE;
 
  176    else if (
isClass(obj_array->objects[
i], autoware_auto_msgs::msg::ObjectClassification::TRUCK))
 
  178      obj.object_type = obj.LARGE_VEHICLE;
 
  180    else if (
isClass(obj_array->objects[
i], autoware_auto_msgs::msg::ObjectClassification::TRAILER))
 
  182      obj.object_type = obj.LARGE_VEHICLE; 
 
  184    else if (
isClass(obj_array->objects[
i], autoware_auto_msgs::msg::ObjectClassification::PEDESTRIAN))
 
  186      obj.object_type = obj.PEDESTRIAN;
 
  190      obj.object_type = obj.UNKNOWN;
 
  195    if ((fabs(obj.velocity.twist.linear.x || obj.velocity.twist.linear.y || obj.velocity.twist.linear.z)) > 0.75)
 
  204    msg.objects.emplace_back(obj);
 
PublishObjectCallback obj_pub_
 
ObjectDetectionTrackingWorker(PublishObjectCallback obj_pub, TransformLookupCallback tf_lookup, rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger)
Constructor.
 
bool isClass(const autoware_auto_msgs::msg::TrackedObject &obj, uint8_t class_id)
Helper method to check if the provided tracked object has the provided class type.
 
void detectedObjectCallback(autoware_auto_msgs::msg::TrackedObjects::UniquePtr msg)
detectedObjectCallback populates detected object along with its velocity,yaw, yaw_rate and static/dyn...
 
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger_
 
void setMapFrame(std::string map_frame)
 
std::function< void(const carma_perception_msgs::msg::ExternalObjectList &)> PublishObjectCallback
 
std::function< boost::optional< geometry_msgs::msg::TransformStamped >(const std::string &, const std::string &, const rclcpp::Time &stamp)> TransformLookupCallback
 
TransformLookupCallback tf_lookup_
 
geometry_msgs::msg::PoseWithCovariance::_covariance_type transformCovariance(const geometry_msgs::msg::PoseWithCovariance::_covariance_type &cov_in, const tf2::Transform &transform)
Transform the covariance matrix of a PoseWithCovariance message to a new frame.