Tetrapod Project
control_node.cpp
Go to the documentation of this file.
1 #include "ros/ros.h"
2 #include <ros/console.h>
3 
5 
6 int main(int argc, char **argv)
7 {
8  bool USE_POSITION_CONTROL = false;
9 
10  double PUBLISH_FREQUENCY = 200.0;
11 
12  SingleMotorController controller(PUBLISH_FREQUENCY, USE_POSITION_CONTROL);
13 
14  controller.initROS();
15 
16  controller.initializeMotor();
17 
18  ros::Rate check_for_messages_rate(1);
19 
20  ros::Rate send_command_rate(PUBLISH_FREQUENCY);
21 
22 
23  while(!controller.initialStateReceived())
24  {
25  controller.checkForNewMessages();
26  ROS_INFO("Waiting for state");
27  controller.printAll();
28  check_for_messages_rate.sleep();
29  }
30 
31  controller.moveToZero();
32 
33  while(!controller.readyToProceed())
34  {
35  controller.checkForNewMessages();
36  ROS_INFO("Waiting for ready to proceed");
37  check_for_messages_rate.sleep();
38  }
39 
40  while(true)
41  {
42  controller.checkForNewMessages();
43  controller.increaseIterator();
44  controller.updateTrajectory();
45  //controller.writeToLog();
46  if(USE_POSITION_CONTROL)
47  {
48  controller.sendJointPositionCommand();
49  }
50  else
51  {
52  controller.sendJointTorqueCommand();
53  }
54  controller.printAll();
55  if(controller.keepLogging())
56  {
57  controller.writeToLog();
58  }
59  send_command_rate.sleep();
60  }
61 
62  return 0;
63 }
64 
void initializeMotor(double _k_p_pos, double _k_d_pos, double _k_p_vel, double _k_i_vel, double _k_p_torque, double _k_i_torque)
int main(int argc, char **argv)
Definition: control_node.cpp:6