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 = TORQUE;
14 double publish_frequency = 200.0;
23 ros::Rate check_for_messages_rate(1);
26 ros::Rate send_control_command_rate(publish_frequency);
35 check_for_messages_rate.sleep();
38 ROS_INFO(
"WAITING FOR INITIAL STATE");
42 ROS_INFO(
"Initial state received");
51 check_for_messages_rate.sleep();
54 ROS_INFO(
"WAITING FOR START MESSAGE");
60 Eigen::Matrix<double, 3, 1> foot_goal_position(0.0, 0.4, -0.35);
67 int setpoint_loop_counter = 0;
78 if((setpoint == 0) && (setpoint_loop_counter > 1 * publish_frequency))
80 foot_goal_position(2) = -0.25;
85 else if((setpoint == 1) && (setpoint_loop_counter > 3 * publish_frequency))
87 foot_goal_position(2) = -0.35;
92 else if((setpoint == 2) && (setpoint_loop_counter > 5 * publish_frequency))
94 foot_goal_position(2) = -0.20;
99 else if(setpoint_loop_counter > 7 * publish_frequency)
105 if(control_mode == CONTROL_MODE::POSITION)
109 else if(control_mode == CONTROL_MODE::VELOCITY)
117 else if(control_mode == CONTROL_MODE::TORQUE)
127 ROS_INFO(
"SP: %d\t", setpoint);
136 send_control_command_rate.sleep();
139 setpoint_loop_counter++;
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 updateClosedLoopTorqueCommands()
A non model based torque controller.
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 updatePoseControlJointTrajectoryReference()
Update the pose control trajectory reference for the single leg.
bool isInitialStateReceived()
Check if the uninitalized joint state of the robot has been overridden by measurements.
void setPoseGoal(Eigen::Matrix< double, 3, 1 > _foot_pos)
Set the final and initial states for pose control trajectories.
bool moveFootToPosition(Eigen::Matrix< double, 3, 1 > _foot_goal_pos)
Creates a trajectory from the current foot position to the goal foot position and moves the foot to t...
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)