Tetrapod Project
gait_test_node.cpp
Go to the documentation of this file.
1 #include "ros/ros.h"
2 #include <ros/console.h>
3 
5 
6 
7 int main(int argc, char **argv)
8 {
9  bool USE_GUIDANCE_CONTROL = false;
10 
11  int controller_frequency = 200;
12 
13  double gait_period = 0.4;
14 
15  double SET_TWIST_TIME = gait_period * 10.0;
16 
17  double LOG_START_TIME = gait_period * 20.0;;
18 
19  double LOG_PERIOD = gait_period * 3.0; // [s]
20 
21  RobotController controller(controller_frequency, gait_period);
22 
23  ros::Rate control_rate(controller_frequency);
24 
25  ROS_INFO("Initialization complete");
26 
27  controller.PrintParameters();
28 
29  controller.waitForReadyToProceed();
30 
31  ROS_INFO("Position joint states received");
32 
33  controller.setInitialConfiguration();
34 
35  controller.waitForReadyToProceed();
36 
37  int iteration = 0;
38 
39  while(ros::ok())
40  {
41  ros::spinOnce();
42 
43  if(iteration == int(SET_TWIST_TIME * controller_frequency))
44  {
45  controller.SetTwistCommand(0.5, 0.0, 0.0);
46  }
47 
48  if(controller.UpdateGaitState())
49  {
50  if(USE_GUIDANCE_CONTROL)
51  {
52  controller.UpdateGuidanceCommands();
53  }
54  else
55  {
56  controller.UpdateNonGuidanceCommands();
57  }
58  controller.UpdateStepDistances();
59  }
60 
61  //controller.UpdateFeetReferences();
62  controller.UpdateFeetTrajectories();
63  controller.UpdateJointCommands();
64  controller.UpdateVelocityCommands();
65  controller.PrintFootPositions();
66  //controller.PrintVelCommands();
67  controller.sendJointPositionCommands();
68 
69  if(iteration >= int(LOG_START_TIME * controller_frequency) && (iteration <= int((LOG_START_TIME + LOG_PERIOD) * controller_frequency)))
70  {
71  controller.WriteToLog();
72  }
73 
74  control_rate.sleep();
75  iteration++;
76  }
77 
78  return 0;
79 }
bool UpdateJointCommands()
Definition: controller.cpp:28
bool UpdateVelocityCommands()
Definition: controller.cpp:65
void WriteToLog()
Definition: controller.cpp:287
void waitForReadyToProceed()
Definition: controller.cpp:14
void SetTwistCommand(double lin_vel_cmd_x, double lin_vel_cmd_y, double ang_vel_cmd_z)
Definition: controller.cpp:280
bool sendJointPositionCommands()
Definition: controller.cpp:85
virtual void setInitialConfiguration()
Definition: controller.cpp:120
void UpdateNonGuidanceCommands()
int main(int argc, char **argv)