<commit_before>#include <ros/ros.h>
#include <igvc_msgs/action_path.h>
#include <igvc_msgs/velocity_pair.h>
#include <mutex>
#include <chrono>

using namespace igvc_msgs;
using namespace std;
using namespace chrono;

action_pathConstPtr path;
mutex path_mutex;

int path_index = 0;
bool path_reset = false;

void newPath(const action_pathConstPtr &msg)
{
  lock_guard<mutex> lock(mutex);
  path = msg;
  path_index = 0;
  path_reset = true;
}

int main(int argc, char** argv)
{

  ros::init(argc, argv, "path_follower");

  time_point<high_resolution_clock> cmd_start_time;

  ros::Rate rate(60);
  while(ros::ok())
  {
    ros::spinOnce();

    { //scope for mutex lock
      lock_guard<mutex> lock(mutex);
      if(path.get() != nullptr)
      {
        if(path_reset)
        {
          // TODO send motor commands
          cmd_start_time = high_resolution_clock::now();
        }
        auto elapsed_time = high_resolution_clock::now() -  cmd_start_time;
        if(duration_cast<seconds>(elapsed_time).count() > path->actions[path_index].duration)
        {
          path_index++;
          // TODO send motor commands
          cmd_start_time = high_resolution_clock::now();
        }
      }
    }

    rate.sleep();
  }

  return 0;
}<commit_msg>Adds path_follower logic for publishing motor commands from path.<commit_after>#include <ros/ros.h>
#include <igvc_msgs/action_path.h>
#include <igvc_msgs/velocity_pair.h>
#include <mutex>
#include <chrono>

using namespace igvc_msgs;
using namespace std;
using namespace chrono;

action_pathConstPtr path;
mutex path_mutex;

int path_index = 0;
bool path_reset = false;

void newPath(const action_pathConstPtr &msg)
{
  lock_guard<mutex> lock(mutex);
  path = msg;
  path_index = 0;
  path_reset = true;
}

int main(int argc, char** argv)
{

  ros::init(argc, argv, "path_follower");

  time_point<high_resolution_clock> cmd_start_time;

  ros::NodeHandle n;

  ros::Publisher cmd_pub = n.advertise<velocity_pair>("/motors", 1);

  ros::Rate rate(60);
  while(ros::ok())
  {
    ros::spinOnce();

    { //scope for mutex lock
      lock_guard<mutex> lock(mutex);
      if(path.get() != nullptr)
      {
        if(path_reset)
        {
          cmd_pub.publish(path->actions[path_index]);
          cmd_start_time = high_resolution_clock::now();
        }
        auto elapsed_time = high_resolution_clock::now() -  cmd_start_time;
        if(duration_cast<seconds>(elapsed_time).count() > path->actions[path_index].duration)
        {
          path_index++;
          cmd_pub.publish(path->actions[path_index]);
          cmd_start_time = high_resolution_clock::now();
        }
      }
    }

    rate.sleep();
  }

  return 0;
}
{'fraction_non_alphanumeric': 0.12667161961367013, 'fraction_numerical': 0.004086181277860327, 'mean_word_length': 3.227629513343799, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 28, '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': '1532438', 'n_tokens_mistral': 959, 'n_tokens_neox': 910, 'n_words': 180}