2 #include <ros/console.h>
6 int main(
int argc,
char **argv)
8 enum CONTROL_MODE {POSITION, VELOCITY, TORQUE};
11 const CONTROL_MODE control_mode = POSITION;
13 const int NUMBER_OF_GAIT_CYCLES = 2;
16 double publish_frequency = 200.0;
25 ros::Rate check_for_messages_rate(1);
28 ros::Rate send_control_command_rate(publish_frequency);
37 check_for_messages_rate.sleep();
40 ROS_INFO(
"WAITING FOR INITIAL STATE");
44 ROS_INFO(
"Initial state received");
53 check_for_messages_rate.sleep();
56 ROS_INFO(
"WAITING FOR START MESSAGE");
65 int number_of_phase_cycles = 0;
75 number_of_phase_cycles++;
77 if(number_of_phase_cycles >= NUMBER_OF_GAIT_CYCLES * 2)
89 if(control_mode == CONTROL_MODE::POSITION)
93 else if(control_mode == CONTROL_MODE::VELOCITY)
101 else if(control_mode == CONTROL_MODE::TORQUE)
117 send_control_command_rate.sleep();
void writeToLog()
Write the joint references and estimated states to the log.
void updateJointVelocityCommands()
Updates the joint velocity control commands based on the joint velocity reference and the joint posit...
void printAllStates()
Print various information about all joints.
void updateFootTrajectoryReference()
Update the foot trajectory based on the leg state.
bool moveFootToNominalPosition()
The function tries to move the foot to the nominal trajectory position.
void resetReadyToProceed()
Set the ready_to_proceed flag to false.
void initROS()
This function initilizes ROS.
void sendJointVelocityCommands()
Updates the joint velocity commands and send them to the motors.
void sendJointPositionCommands()
Sends a joint position commands to the motors.
bool isInitialStateReceived()
Check if the uninitalized joint state of the robot has been overridden by measurements.
void updateJointTorqueCommands(const Eigen::Matrix< double, 3, 1 > &_joint_pos_ref, const Eigen::Matrix< double, 3, 1 > &_joint_vel_ref, const Eigen::Matrix< double, 3, 1 > &_joint_acc_ref, const Eigen::Matrix< double, 3, 1 > &_joint_pos, const Eigen::Matrix< double, 3, 1 > &_joint_vel)
Update the joint torqes references based on the joint trajectories and joint states.
void updateJointReferences()
Update The joint trajectory reference based on the spatial foot trajectory.
bool updateGaitPhase()
Increments the gait cycle iterator and updates the leg state.
void sendJointTorqueCommands()
Updates the joint torque control commands based on the desired foot position.
void checkForNewMessages()
Function used to check if any new ROS messages has been received.
bool readyToProceed()
Check whether or not a ready to proceed message has been received.
int main(int argc, char **argv)