Go to the documentation of this file.
2 #include "geometry_msgs/PointStamped.h"
3 #include "geometry_msgs/TransformStamped.h"
4 #include "sensor_msgs/TimeReference.h"
21 #include "outsight_alb_driver/AugmentedCloud.h"
22 #include "outsight_alb_driver/ObjectData.h"
23 #include "outsight_alb_driver/TrackedObjects.h"
123 ROS_WARN(
"[AlbPublisher] No base_frame_id specified in the config file.");
126 geometry_msgs::TransformStamped base_to_lidar =
130 ROS_INFO(
"[AlbPublisher] Base to lidar transform received.");
133 "[AlbPublisher] No base to lidar transform provided, package will not be able to relocate Lidar frame in the robot frame.");
134 ROS_WARN(
"[AlbPublisher] %s", ex.what());
143 std::string ip_address;
145 ROS_ERROR(
"[AlbPublisher] IP address not defined");
151 std::string raw_zones;
219 Tlv::Parser parser(frame->getValue(), frame->getLength());
222 ROS_ERROR(
"[AlbPublisher] Timestamp not found, unable to publish TimeReference.");
228 sensor_msgs::TimeReference time_message;
233 time_message.source =
"alb_time";
236 time_message.source =
"ros_time";
244 Tlv::Parser parser(frame->getValue(), frame->getLength());
247 ROS_ERROR(
"[AlbPublisher] Scan frame not found, unable to publish PointCloud.");
251 Tlv::Parser frameParser(frameTlv->getValue(), frameTlv->getLength());
253 if (!augmented_point_cloud) {
254 ROS_ERROR(
"[AlbPublisher] Augmented point cloud not found, unable to publish PointCloud.");
259 const Tlv::Parser cloudParser(augmented_point_cloud->getValue(), augmented_point_cloud->getLength());
264 if (!cartesian_tlv || !number_points_tlv || !number_layers_tlv) {
265 std::string error_msg(!cartesian_tlv ?
"Cartesian not found. " :
"");
266 error_msg.append(!number_points_tlv ?
"Number of points not found." :
"");
267 error_msg.append(!number_layers_tlv ?
"Number of layers not found." :
"");
269 ROS_ERROR(
"[AlbPublisher] Unable to publish PointCloud: %s", error_msg.c_str());
275 sensor_msgs::PointCloud2 point_cloud_msg;
292 geometry_msgs::PoseStamped pose_msg;
301 Tlv::Parser parser(frame->getValue(), frame->getLength());
304 ROS_ERROR(
"[AlbPublisher] Scan frame not found, unable to publish BoundingBoxes message.");
308 Tlv::Parser frameParser(frameTlv->getValue(), frameTlv->getLength());
311 ROS_ERROR(
"[AlbPublisher] Tracked objects not found, unable to publish BoundingBoxes message.");
315 Tlv::Parser objectsParser(objectsTlv->getValue(), objectsTlv->getLength());
322 if (!num_objects || !object_ids || !bbox_sizes || !pose_array || !speed_vectors || !class_ids) {
323 std::string error_msg(!num_objects ?
"Number of objects not found. " :
"");
324 error_msg.append(!object_ids ?
"Object ids not found. " :
"");
325 error_msg.append(!bbox_sizes ?
"Box sizes not found. " :
"");
326 error_msg.append(!pose_array ?
"Pose array not found. " :
"");
327 error_msg.append(!speed_vectors ?
"Speed vectors not found. " :
"");
328 error_msg.append(!class_ids ?
"Class IDs not found. " :
"");
330 ROS_ERROR(
"[AlbPublisher] Unable to publish BoundingBoxes message: %s.", error_msg.c_str());
334 outsight_alb_driver::TrackedObjects tracked_message;
338 uint32_t *ids = (uint32_t *)(object_ids->getValue());
340 for (
size_t box_index = 0; box_index < tracked_message.number_of_objects; box_index++) {
341 outsight_alb_driver::ObjectData object;
343 object.id = ids[box_index];
348 uint32_t *class_id = (uint32_t *)(class_ids->getValue() +
sizeof(uint32_t) * box_index);
351 tracked_message.objects.push_back(
object);
363 geometry_msgs::PoseStamped ego_msg;
392 Tlv::Parser parser(frame->getValue(), frame->getLength());
395 ROS_ERROR(
"[AlbPublisher] Scan frame not found, unable to publish PointCloud.");
399 Tlv::Parser frameParser(frameTlv->getValue(), frameTlv->getLength());
401 if (!augmented_point_cloud) {
402 ROS_ERROR(
"[AlbPublisher] Augmented point cloud not found, unable to publish PointCloud.");
406 outsight_alb_driver::AugmentedCloud message;
422 geometry_msgs::PoseStamped pose_msg;
440 Tlv::Parser parser(frame->getValue(), frame->getLength());
450 "[AlbPublisher] Transform between fixed frame and sensor frame requires odometry to be published. Set the odometry parameter to 'true' in order to broadcast this transform.");
456 geometry_msgs::Transform odom_to_lidar;
457 odom_to_lidar.translation.x =
odom_msg.pose.pose.position.x;
458 odom_to_lidar.translation.y =
odom_msg.pose.pose.position.y;
459 odom_to_lidar.translation.z =
odom_msg.pose.pose.position.z;
460 odom_to_lidar.rotation =
odom_msg.pose.pose.orientation;
465 geometry_msgs::TransformStamped transformStamped;
471 transformStamped.transform =
tf2::toMsg(odom_to_base_tf);
475 transformStamped.transform =
tf2::toMsg(odom_to_lidar_tf);
484 ROS_WARN(
"[AlbPublisher] No map_frame_id specified in the config file");
487 geometry_msgs::TransformStamped static_transformStamped;
492 static_transformStamped.transform.translation.x = pose.position.x;
493 static_transformStamped.transform.translation.y = pose.position.y;
494 static_transformStamped.transform.translation.z = pose.position.z;
495 static_transformStamped.transform.rotation = pose.orientation;
void publish(const Tlv::tlv_s *frame)
Publish messages from the ALB frame.
void publishOdometry(const Tlv::tlv_s *frame)
Publish odometry message.
geometry_msgs::Pose first_pose
ros::Publisher pose_publisher
void publishZones()
Publish the zones message.
constexpr const char * k_alb_point_cloud_config
void publishTimeReference(const Tlv::tlv_s *frame)
Publish TimeReference message.
void initPublishers(ros::NodeHandle &nodeHandle)
Initialize the ROS publishers.
ros::Time current_timestamp
#define OSEF_TYPE_TRACKED_OBJECTS
bool get_egomotion_from_tlv(const Tlv::tlv_s *frame, geometry_msgs::PoseStamped &pose)
Get a ROS egomotion pose from the TLV data.
void updatePose(const Tlv::tlv_s *frame)
Update current position as the last position.
void publishAugmentedCloud(const Tlv::tlv_s *frame)
Publish the augmented cloud message.
constexpr const char * k_alb_augmented_cloud_config
constexpr const char * k_alb_use_colwise_order
#define OSEF_TYPE_NUMBER_OF_POINTS
void updateTimeStamp(const Tlv::tlv_s *frame)
Update used time stamp with the ALB time stamp.
void fromMsg(const A &, B &b)
tf2::Transform base_to_lidar_tf
void define_augmented_cloud(outsight_alb_driver::AugmentedCloud &message, const Tlv::tlv_s *frame)
Define the AugmentedCloud message.
bool getParam(const std::string &key, bool &b) const
constexpr const char * k_alb_zones
constexpr const char * k_alb_ip
void define_point_fields(sensor_msgs::PointCloud2 &pointCloud)
Define the point fields for the ALB PointCloud2 message.
constexpr const char * k_alb_odometry_config
void define_box_pose(outsight_alb_driver::ObjectData &tracked, const Tlv::tlv_s *bBoxPoses, size_t objectIndex)
Define the bounding box pose for the tracked object.
void define_object_speed(outsight_alb_driver::ObjectData &tracked, const Tlv::tlv_s *objectSpeeds, size_t objectIndex)
Define the tracked object speed.
constexpr const char * k_alb_objects
void publishPointCloud(const Tlv::tlv_s *frame)
Publish pointCloud message.
constexpr const char * k_alb_objects_config
constexpr const char * k_alb_egomotion
geometry_msgs::Pose current_pose
#define OSEF_TYPE_TIMESTAMP_MICROSECOND
bool get_pose_from_tlv(const Tlv::tlv_s *frame, geometry_msgs::PoseStamped &pose)
Get a ROS pose from the TLV data.
ros::Publisher egomotion_publisher
constexpr const char * k_default_sensor_frame_id
void define_points_data(sensor_msgs::PointCloud2 &pointCloud, const uint32_t layers, const uint32_t points, float *pointData, bool use_colwise_order)
Define the PointCloud2 point data from raw points coming from the ALB.
bool transform_broadcaster
void broadcastMapTransform(const geometry_msgs::Pose &pose)
Broadcast the ALB map to fixed frame transform.
void publish(const boost::shared_ptr< M > &message) const
Class to handle the curl ALB requests.
Publisher advertise(AdvertiseOptions &ops)
constexpr const char * k_alb_time_ref_config
#define OSEF_TYPE_NUMBER_OF_LAYERS
uint32_t castValue(const Tlv::tlv_s *leafTlv)
const std::string getErrorMessage(void) const
Get the error message.
ros::Publisher point_cloud_publisher
void define_box_size(outsight_alb_driver::ObjectData &tracked, const Tlv::tlv_s *bBoxSizes, size_t objectIndex)
Define the bounding box size for the tracked object.
constexpr const char * k_alb_augmented_cloud
void broadcastAlbTransform(const geometry_msgs::Pose &pose)
Broadcast the ALB fixed frame to sensor frame transform.
constexpr const char * k_default_fixed_frame_id
std::string fixed_frame_id
ros::Publisher odometry_publisher
outsight_alb_driver::Zones zones_msg
ros::Publisher augmented_cloud_publisher
#define OSEF_TYPE_POSE_ARRAY
void publishTrackedObjects(const Tlv::tlv_s *frame)
Publish tracked objects message.
void initTransforms()
Initialize the transform frames.
bool hasParam(const std::string &key) const
#define OSEF_TYPE_CARTESIAN_COORDINATES
#define OSEF_TYPE_NUMBER_OF_OBJECTS
timestamp_s castValue(const Tlv::tlv_s *leafTlv)
ros::Publisher time_reference_publisher
constexpr const char * k_alb_zones_config
void init_pose(geometry_msgs::Pose &pose)
Initialize a ROS Pose message.
constexpr const char * k_alb_broadcast_tf_config
constexpr const char * k_alb_fixed_frame_id
void publishEgomotion(const Tlv::tlv_s *frame)
Publish egomotion message.
bool executeProcessingZones(std::string &zones)
Execute the processing command for the zones.
constexpr const char * k_alb_egomotion_config
#define OSEF_TYPE_SCAN_FRAME
constexpr const uint32_t k_queue_size
AlbPublisher(ros::NodeHandle &nodeHandle)
#define OSEF_TYPE_BBOX_SIZES
void publishPose(const Tlv::tlv_s *frame)
Publish pose message.
std::string base_frame_id
std::string sensor_frame_id
constexpr const char * k_alb_use_alb_time
tlv_s * findTlv(type_t type) const
constexpr const char * k_alb_map_frame_id
T param(const std::string ¶m_name, const T &default_val) const
void buildZones()
Build ALB zones when the processing starts.
#define OSEF_TYPE_OBJECT_ID_32_BITS
constexpr const char * k_alb_odometry
std::string get_object_class(uint32_t classId)
Get the string class of the tracked object from the ALB.
constexpr const char * k_alb_time_ref
void parse_zone_data(const std::string &raw_zones, outsight_alb_driver::Zones &zones_msg)
Parse the zone data in the raw string and set them in the Zones msg.
constexpr const char * k_alb_pose_config
nav_msgs::Odometry odom_msg
ros::Publisher zones_publisher
constexpr const char * k_alb_pose
ros::Publisher tracked_objects_publisher
void computeOdometry(nav_msgs::Odometry &odom, const geometry_msgs::Pose ¤t_pose, const geometry_msgs::Pose &last_pose, const geometry_msgs::Pose &first_pose, float dt)
Compute the odometry between the last two poses.
#define OSEF_TYPE_SPEED_VECTORS
geometry_msgs::Pose last_pose
constexpr const char * k_alb_base_frame_id
constexpr const char * k_alb_point_cloud
constexpr const char * k_alb_sensor_frame_id
#define OSEF_TYPE_AUGMENTED_CLOUD
#define OSEF_TYPE_CLASS_ID_ARRAY