Tetrapod Project
robot_controller_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 
10  int controller_frequency = 200;
11 
12  double gait_period = 0.4;
13 
14  double SET_TWIST_TIME = gait_period * 10.0;
15 
16  double LOG_START_TIME = gait_period * 20.0;;
17 
18  double LOG_PERIOD = gait_period * 3.0; // [s]
19 
20  RobotController controller(controller_frequency, gait_period);
21 
22  ros::Rate control_rate(controller_frequency);
23 
24  ROS_INFO("Initialization complete");
25 
26  controller.PrintParameters();
27 
28  controller.waitForReadyToProceed();
29 
30  //controller.ResetReadyToProceedFlag();
31 
32  ROS_INFO("Position joint states received");
33 
34  controller.WaitForInitialState();
35 
36  controller.RunStandUpSequence();
37 
38  //controller.SetReadyToProceedFlag();
39 
40  while(ros::ok() && !controller.CheckReadyToProceed())
41  {
42  ros::spinOnce();
43 
44  controller.sendJointPositionCommands();
45 
46  controller.WriteToLog();
47 
48  control_rate.sleep();
49  }
50 
51  //controller.waitForReadyToProceed();
52 
53  int iteration = 0;
54 
55  while(ros::ok())
56  {
57  ros::spinOnce();
58 
59  if(controller.UpdateGaitState())
60  {
61  controller.UpdateNonGuidanceCommands();
62  controller.UpdateStepDistances();
63  }
64 
65  controller.UpdateFeetTrajectories();
66  controller.UpdateJointCommands();
67  //controller.PrintFootPositions();
68  //controller.PrintVelCommands();
69  controller.sendJointPositionCommands();
70 
71  controller.WriteToLog();
72 
73  /*
74  if(iteration >= int(LOG_START_TIME * controller_frequency) && (iteration <= int((LOG_START_TIME + LOG_PERIOD) * controller_frequency)))
75  {
76  controller.WriteToLog();
77  }
78  */
79 
80  control_rate.sleep();
81  iteration++;
82  }
83 
84  return 0;
85 }
bool UpdateJointCommands()
Definition: controller.cpp:28
bool CheckReadyToProceed()
Definition: controller.h:81
void WaitForInitialState()
Definition: controller.cpp:376
void WriteToLog()
Definition: controller.cpp:287
void waitForReadyToProceed()
Definition: controller.cpp:14
bool RunStandUpSequence()
Definition: controller.cpp:386
bool sendJointPositionCommands()
Definition: controller.cpp:85
void UpdateNonGuidanceCommands()
int main(int argc, char **argv)