Tetrapod Project
plot_spline.cpp
Go to the documentation of this file.
1 #include "ros/ros.h"
2 #include "ros/console.h"
3 #include "sensor_msgs/JointState.h"
4 
6 
7 int main(int argc, char **argv)
8 {
9  int control_rate = 200;
10 
11  double a_max = 50.0;
12 
13  double rise_percentage = 0.4;
14 
15  double swing_period = 0.2;
16 
17  double step_distance = 0.0;
18 
19  double vel_cmd = 0.0;
20 
21  ros::init(argc, argv, "polynomial_publisher");
22 
23  ros::NodeHandle nh;
24 
25  ros::Publisher publisher = nh.advertise<sensor_msgs::JointState>("/trajectory", 1);
26 
27  ros::Rate loop_rate(control_rate);
28 
29  ros::Duration(3.0).sleep();
30 
31  int iteration = 0;
32 
33  int iteration_final = control_rate * swing_period;
34 
35  while(ros::ok() && (iteration <= iteration_final))
36  {
37  double t = double(iteration)/double(iteration_final)*swing_period;
38 
39  //double val = polynomialSpine(t, swing_period, step_distance, a_max, vel);
40  double pos, vel, acc, jerk;
41 
42  //CalculatePolynomialTrajectory(t, swing_period, step_distance, a_max, vel_cmd, pos, vel, acc, jerk);
43  CalculatePolynomialTrajectory(t, swing_period, rise_percentage, step_distance, vel_cmd, pos, vel, acc, jerk);
44 
45  ROS_INFO("I: %d\tT: %f\tP: %f\tV: %f\tA: %f\tJ: %f", iteration, t, pos, vel, acc, jerk);
46 
47  sensor_msgs::JointState msg;
48 
49  msg.header.stamp = ros::Time::now();
50 
51  msg.position.push_back(pos);
52  msg.velocity.push_back(vel);
53  msg.effort.push_back(acc);
54 
55  iteration ++;
56 
57  publisher.publish(msg);
58 
59  loop_rate.sleep();
60  }
61 
62  ros::Duration(3.0).sleep();
63 }
void CalculatePolynomialTrajectory(double t, double swing_period, double rise_percentage, double distance, double vel_cmd, double &_pos, double &_vel, double &_acc, double &_jerk)
Definition: gaits.cpp:196
int main(int argc, char **argv)
Definition: plot_spline.cpp:7