2 #include "ros/console.h"
3 #include "sensor_msgs/JointState.h"
7 int main(
int argc,
char **argv)
9 int control_rate = 200;
13 double rise_percentage = 0.4;
15 double swing_period = 0.2;
17 double step_distance = 0.0;
21 ros::init(argc, argv,
"polynomial_publisher");
25 ros::Publisher publisher = nh.advertise<sensor_msgs::JointState>(
"/trajectory", 1);
27 ros::Rate loop_rate(control_rate);
29 ros::Duration(3.0).sleep();
33 int iteration_final = control_rate * swing_period;
35 while(ros::ok() && (iteration <= iteration_final))
37 double t = double(iteration)/double(iteration_final)*swing_period;
40 double pos, vel, acc, jerk;
45 ROS_INFO(
"I: %d\tT: %f\tP: %f\tV: %f\tA: %f\tJ: %f", iteration,
t, pos, vel, acc, jerk);
47 sensor_msgs::JointState msg;
49 msg.header.stamp = ros::Time::now();
51 msg.position.push_back(pos);
52 msg.velocity.push_back(vel);
53 msg.effort.push_back(acc);
57 publisher.publish(msg);
62 ros::Duration(3.0).sleep();
void CalculatePolynomialTrajectory(double t, double swing_period, double rise_percentage, double distance, double vel_cmd, double &_pos, double &_vel, double &_acc, double &_jerk)
int main(int argc, char **argv)