<commit_before>#include <ros/ros.h>
#include <std_msgs/Float32.h>
#include <motionlibrary/ForwardAction.h>
#include <motionlibrary/ForwardActionFeedback.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/client/terminal_state.h>
#include <dynamic_reconfigure/server.h>
#include <motionlibrary/forwardConfig.h>

typedef actionlib::SimpleActionClient<motionlibrary::ForwardAction> Client;
Client *chutiya;
motionlibrary::ForwardGoal goal;

bool moving=false;

//dynamic reconfig 
void callback(motionlibrary::forwardConfig &config, double level) {
	ROS_INFO("Reconfigure Request: %f %s", config.double_param, config.bool_param?"True":"False");
	Client &can = *chutiya;
	if(!config.bool_param){
		if(moving){
			moving = false;
			can.cancelGoal();
			ROS_INFO("Goal Cancelled");
		}
	}
	else{
		if(moving){
			Client &can = *chutiya;
			can.cancelGoal();
			ROS_INFO("Goal Cancelled");	
		}
		goal.MotionTime = config.double_param;
		can.sendGoal(goal);
	 	ROS_INFO("Goal Send %f", goal.MotionTime);
		moving = true;
	}
	
}

//never ever put the argument of the callback function anything other then the specified
//void forwardCb(const motionlibrary::ForwardActionFeedbackConstPtr msg){
void forwardCb(motionlibrary::ForwardActionFeedback msg){
	ROS_INFO("feedback recieved %fsec remaining ",msg.feedback.TimeRemaining);
}


// void spinThread()
// {
// 	ros::spin();
// }

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

	ros::init(argc, argv, "testForwardMotion");
	
	ros::NodeHandle nh;
	ros::Subscriber sub_ = nh.subscribe<motionlibrary::ForwardActionFeedback>("/forward/feedback",1000,&forwardCb);

	Client forwardTestClient("forward");
	chutiya = &forwardTestClient;

	ROS_INFO("Waiting for action server to start.");
	forwardTestClient.waitForServer();
	goal.MotionTime =0;
	ROS_INFO("Action server started, sending goal.");

	//register dynamic reconfig server.
	dynamic_reconfigure::Server<motionlibrary::forwardConfig> server;
	dynamic_reconfigure::Server<motionlibrary::forwardConfig>::CallbackType f;
	f = boost::bind(&callback, _1, _2);
	server.setCallback(f);

	// // Create the action client
	// Client forwardTestClient("forward");
<commit_msg>A simple thread added in client to inform about the success.<commit_after>#include <ros/ros.h>
#include <std_msgs/Float32.h>
#include <motionlibrary/ForwardAction.h>
#include <motionlibrary/ForwardActionFeedback.h>
#include <motionlibrary/ForwardActionResult.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/client/terminal_state.h>
#include <dynamic_reconfigure/server.h>
#include <motionlibrary/forwardConfig.h>

typedef actionlib::SimpleActionClient<motionlibrary::ForwardAction> Client;

Client *chutiya;
motionlibrary::ForwardGoal goal;

bool moving=false;
bool success=false;

void spinThread(){
	Client &temp = *chutiya;
	temp.waitForResult();
	success = (*(temp.getResult())).MotionCompleted;
	if(success){
		ROS_INFO("motion successful");
	}
	else
		ROS_INFO("motion unsuccessful");
}


//dynamic reconfig 
void callback(motionlibrary::forwardConfig &config, double level) {
	ROS_INFO("Reconfigure Request: %f %s", config.double_param, config.bool_param?"True":"False");
	Client &can = *chutiya;
	if(!config.bool_param){
		if(moving){
			moving = false;
			can.cancelGoal();
			ROS_INFO("Goal Cancelled");
		}
	}
	else{
		if(moving){
			Client &can = *chutiya;
			can.cancelGoal();
			ROS_INFO("Goal Cancelled");	
		}
		goal.MotionTime = config.double_param;
		can.sendGoal(goal);
		boost::thread spin_thread(&spinThread);
	 	ROS_INFO("Goal Send %f", goal.MotionTime);
		moving = true;
	}
	
}

//never ever put the argument of the callback function anything other then the specified
//void forwardCb(const motionlibrary::ForwardActionFeedbackConstPtr msg){
void forwardCb(motionlibrary::ForwardActionFeedback msg){
	ROS_INFO("feedback recieved %fsec remaining ",msg.feedback.TimeRemaining);
}

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

	ros::init(argc, argv, "testForwardMotion");
	
	ros::NodeHandle nh;
	ros::Subscriber sub_ = nh.subscribe<motionlibrary::ForwardActionFeedback>("/forward/feedback",1000,&forwardCb);

	Client forwardTestClient("forward");
	chutiya = &forwardTestClient;

	ROS_INFO("Waiting for action server to start.");
	forwardTestClient.waitForServer();
	goal.MotionTime =0;
	ROS_INFO("Action server started, sending goal.");



	//register dynamic reconfig server.
	dynamic_reconfigure::Server<motionlibrary::forwardConfig> server;
	dynamic_reconfigure::Server<motionlibrary::forwardConfig>::CallbackType f;
	f = boost::bind(&callback, _1, _2);
	server.setCallback(f);

	// // Create the action client
	// Client forwardTestClient("forward");

{'fraction_non_alphanumeric': 0.1348218119364534, 'fraction_numerical': 0.0038643194504079004, 'mean_word_length': 6.189814814814815, 'pattern_counts': {'":': 2, '<': 28, '<?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': '4583724', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1463, 'n_words': 315}