<commit_before>// Reads tabletop segmentation clusters and publishes the table.

#include "rviz_objdetect_caller/publish_table.h"

#include "geometry_msgs/Pose.h"
#include "geometry_msgs/Vector3.h"
#include "object_manipulation_msgs/FindClusterBoundingBox.h"
#include "ros/ros.h"
#include "rviz_objdetect_caller/Clusters.h"
#include "tabletop_object_detector/Table.h"
#include "visualization_msgs/Marker.h"

#include <string>
#include <vector>

using geometry_msgs::Pose;
using geometry_msgs::Vector3;
using rviz_objdetect_caller::Clusters;
using std::string;
using std::vector;
using tabletop_object_detector::Table;
using visualization_msgs::Marker;

namespace {
static const string kFixedFrame = "/base_link";
static const string kNamespace = "table";
}

namespace rviz_objdetect_caller {
TablePublisher::TablePublisher(
    string clusters_topic,
    string table_topic):
  clusters_topic_(clusters_topic),
  node_handle_(),
  marker_pub_(node_handle_.advertise<Marker>("segmented_objects_table", 10)) {
}

TablePublisher::~TablePublisher() {
}

void TablePublisher::Start() {
  subscriber_ = node_handle_.subscribe(
    clusters_topic_,
    10,
    &TablePublisher::ClusterCallback,
    this);
}

void TablePublisher::MakeMarker(
    const Pose& pose,
    const Vector3& dimensions,
    Marker* marker) {
  marker->header.frame_id = kFixedFrame;
  marker->header.stamp = ros::Time::now();
  marker->ns = kNamespace;
  marker->id = 0;
  marker->action = Marker::ADD;
  marker->type = Marker::CUBE;
  marker->pose = pose;
  marker->scale = dimensions;
  marker->color.a = 1;
  marker->color.r = 0;
  marker->color.g = 0;
  marker->color.b = 1;
}

void TablePublisher::ClusterCallback(const Clusters& clusters) {
  Table table = clusters.table;
  Marker marker;
  Pose message_pose = table.pose.pose;
  Pose pose = message_pose;
  float depth = table.x_max - table.x_min;
  float width = table.y_max - table.y_min;
  pose.position.x += table.x_min + depth / 2;
  pose.position.y += table.y_min + width / 2;
  Vector3 dimensions;
  dimensions.x = table.x_max - table.x_min;
  dimensions.y = table.y_max - table.y_min;
  dimensions.z = 0.05;
  MakeMarker(
    table.pose.pose,<commit_msg>Compute table's real position relative to the robot.<commit_after>// Reads tabletop segmentation clusters and publishes the table.

#include "rviz_objdetect_caller/publish_table.h"

#include "geometry_msgs/Pose.h"
#include "geometry_msgs/Vector3.h"
#include "object_manipulation_msgs/FindClusterBoundingBox.h"
#include "ros/ros.h"
#include "rviz_objdetect_caller/Clusters.h"
#include "tabletop_object_detector/Table.h"
#include "visualization_msgs/Marker.h"

#include <string>
#include <vector>

using geometry_msgs::Pose;
using geometry_msgs::Vector3;
using rviz_objdetect_caller::Clusters;
using std::string;
using std::vector;
using tabletop_object_detector::Table;
using visualization_msgs::Marker;

namespace {
static const string kFixedFrame = "/base_link";
static const string kNamespace = "table";
}

namespace rviz_objdetect_caller {
TablePublisher::TablePublisher(
    string clusters_topic,
    string table_topic):
  clusters_topic_(clusters_topic),
  node_handle_(),
  marker_pub_(node_handle_.advertise<Marker>("segmented_objects_table", 10)) {
}

TablePublisher::~TablePublisher() {
}

void TablePublisher::Start() {
  subscriber_ = node_handle_.subscribe(
    clusters_topic_,
    10,
    &TablePublisher::ClusterCallback,
    this);
}

void TablePublisher::MakeMarker(
    const Pose& pose,
    const Vector3& dimensions,
    Marker* marker) {
  marker->header.frame_id = kFixedFrame;
  marker->header.stamp = ros::Time::now();
  marker->ns = kNamespace;
  marker->id = 0;
  marker->action = Marker::ADD;
  marker->type = Marker::CUBE;
  marker->pose = pose;
  marker->scale = dimensions;
  marker->color.a = 1;
  marker->color.r = 0;
  marker->color.g = 0;
  marker->color.b = 1;
}

void TablePublisher::ClusterCallback(const Clusters& clusters) {
  Table table = clusters.table;
  Marker marker;
  Pose message_pose = table.pose.pose;
  Pose pose = message_pose;
  pose.position.x += (table.x_max - table.x_min) / 2;
  pose.position.y += (table.y_max + table.y_min) / 2;
  Vector3 dimensions;
  dimensions.x = table.x_max - table.x_min;
  dimensions.y = table.y_max - table.y_min;
  dimensions.z = 0.05;
  MakeMarker(
    table.pose.pose,
{'fraction_non_alphanumeric': 0.12428078250863062, 'fraction_numerical': 0.008285385500575374, 'mean_word_length': 4.920980926430517, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2720134', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1489, 'n_words': 300}