<commit_before>/**
 * @file      environment.cpp
 * @brief     Main environment for the robot
 * @author    <NAME> <<EMAIL>>
 * @date      2015-08-01
 * @copyright (MIT) 2015 Edinferno
 */

#include "environment/environment.hpp"

Environment::Environment(ros::NodeHandle* nh) {
  nh_ = nh;
  robot_name_ = ros::this_node::getNamespace();
  this->init();
  this->rosSetup();
}

Environment::~Environment() {
  ;
}

void Environment::init() {
  planning_ = true;
  use_rvo_planner_ = true;
}

void Environment::rosSetup() {
  curr_pose_pub_ = nh_->advertise<geometry_msgs::Pose2D>("curr_pose", 1, true);
  target_goal_pub_ = nh_->advertise<geometry_msgs::Pose2D>("target_goal", 1,
                                                           true);
  robot_cmd_velocity_pub_ = nh_->advertise<geometry_msgs::Twist>(
                              "cmd_vel", 1, true);
  ros::service::waitForService(robot_name_ + "/planner/setup_rvo_planner");
  setup_rvo_planner_ =
    nh_->serviceClient<planner_msgs::SetupRVOPlanner>(
      robot_name_ + "/planner/setup_rvo_planner", true);
  tracker_pose_sub_ = nh_->subscribe(robot_name_ + "/planner/curr_pose", 1000,
                                     &Environment::trackerInfoCB, this);
  planner_cmd_vel_sub_ = nh_->subscribe(robot_name_ + "/planner/cmd_vel", 1000,
                                        &Environment::plannerCmdVelCB, this);
}

void Environment::pubRobotVelocity() {
  if (planning_ && use_rvo_planner_) {
    robot_cmd_velocity_ = planner_cmd_velocity_;
    robot_cmd_velocity_pub_.publish(robot_cmd_velocity_);
  }
}

void Environment::trackerInfoCB(const geometry_msgs::Pose2D::ConstPtr& msg) {
  ;
}

void Environment::plannerCmdVelCB(const geometry_msgs::Twist::ConstPtr& msg) {
  planner_cmd_velocity_ = *msg;
}<commit_msg>Change cmd vel topic for robot environment so Youbot may hear it<commit_after>/**
 * @file      environment.cpp
 * @brief     Main environment for the robot
 * @author    <NAME> <<EMAIL>>
 * @date      2015-08-01
 * @copyright (MIT) 2015 Edinferno
 */

#include "environment/environment.hpp"

Environment::Environment(ros::NodeHandle* nh) {
  nh_ = nh;
  robot_name_ = ros::this_node::getNamespace();
  this->init();
  this->rosSetup();
}

Environment::~Environment() {
  ;
}

void Environment::init() {
  planning_ = true;
  use_rvo_planner_ = true;
}

void Environment::rosSetup() {
  curr_pose_pub_ = nh_->advertise<geometry_msgs::Pose2D>("curr_pose", 1, true);
  target_goal_pub_ = nh_->advertise<geometry_msgs::Pose2D>("target_goal", 1,
                                                           true);
  robot_cmd_velocity_pub_ = nh_->advertise<geometry_msgs::Twist>(
                              robot_name_ + "/cmd_vel", 1, true);
  ros::service::waitForService(robot_name_ + "/planner/setup_rvo_planner");
  setup_rvo_planner_ =
    nh_->serviceClient<planner_msgs::SetupRVOPlanner>(
      robot_name_ + "/planner/setup_rvo_planner", true);
  tracker_pose_sub_ = nh_->subscribe(robot_name_ + "/planner/curr_pose", 1000,
                                     &Environment::trackerInfoCB, this);
  planner_cmd_vel_sub_ = nh_->subscribe(robot_name_ + "/planner/cmd_vel", 1000,
                                        &Environment::plannerCmdVelCB, this);
}

void Environment::pubRobotVelocity() {
  if (planning_ && use_rvo_planner_) {
    // TODO: Set vels to absolute zero if small enough
    robot_cmd_velocity_ = planner_cmd_velocity_;
    robot_cmd_velocity_pub_.publish(robot_cmd_velocity_);
  }
}

void Environment::trackerInfoCB(const geometry_msgs::Pose2D::ConstPtr& msg) {
  ;
}

void Environment::plannerCmdVelCB(const geometry_msgs::Twist::ConstPtr& msg) {
  planner_cmd_velocity_ = *msg;
  this->pubRobotVelocity();
}
{'fraction_non_alphanumeric': 0.128928283642224, 'fraction_numerical': 0.013967230727907601, 'mean_word_length': 3.4386174016686533, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4212552', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1241, 'n_words': 196}