Skip to content

Commit

Permalink
Feat : #1 cmd_vel_converter revise
Browse files Browse the repository at this point in the history
convert cmd_vel to cmd_vel_converter with P gain
  • Loading branch information
GeoChoi committed Jun 15, 2023
1 parent 6e73299 commit 539c3b0
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/cmd_vel_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#define MAX_ANGLE 20
#define MIN_ANGLE 0


#define P_VEL 40
#define P_ANG 20

// Create a publisher for the cmd_vel topic
ros::Publisher cmd_vel_converter;
ros::Publisher cmd_vel_echo_converter;
Expand Down Expand Up @@ -184,6 +188,8 @@ bool cmdVelEcho2Converted(const geometry_msgs::Twist::ConstPtr &cmd_vel_echo)
return true;
}



/* =====================
* CallBack Functions
===================== */
Expand Down Expand Up @@ -235,6 +241,23 @@ void cmdVelCallback(const geometry_msgs::Twist::ConstPtr &cmd_vel)
}
}

void cmdVelEcho_simple_Callback(const geometry_msgs::Twist::ConstPtr &cmd_vel_echo)
{
echo_converted.linear.x = (cmd_vel_echo->linear.x)/P_VEL;
echo_converted.angular.z = (cmd_vel_echo->angular.z)/P_ANG;

cmd_vel_echo_converter.publish(echo_converted);
}

void cmdVel_simple_Callback(const geometry_msgs::Twist::ConstPtr &cmd_vel)
{
converted.linear.x = P_VEL * cmd_vel->linear.x;
converted.angular.z = P_ANG * cmd_vel->angular.z;

cmd_vel_converter.publish(converted);
}


/* =====================
* main
===================== */
Expand All @@ -252,11 +275,11 @@ int main(int argc, char **argv)
// ROS_INFO("cmd_vel_echo_converter - Setup publisher on cmd_vel_converted");

// Subscribe to the cmd_vel topic
cmd_vel_sub = nh.subscribe("cmd_vel", 10, cmdVelCallback);
cmd_vel_sub = nh.subscribe("cmd_vel", 10, cmdVelEcho_simple_Callback);
// ROS_INFO("cmd_vel_converter - Setup subscriber on cmd_vel");

// Subscribe to the cmd_vel topic
cmd_vel_echo_sub = nh.subscribe("cmd_vel_echo", 10, cmdVelEchoCallback);
cmd_vel_echo_sub = nh.subscribe("cmd_vel_echo", 10, cmdVel_simple_Callback);
// ROS_INFO("cmd_vel_echo_converter - Setup subscriber on cmd_vel");

// Enter the main event loop
Expand Down

0 comments on commit 539c3b0

Please sign in to comment.