Skip to content

Commit

Permalink
use_sim_time param load bug fix; hardware improve
Browse files Browse the repository at this point in the history
  • Loading branch information
ShuoYangRobotics committed May 25, 2022
1 parent fa93f35 commit dc07ae8
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 35 deletions.
38 changes: 19 additions & 19 deletions src/a1_cpp/config/hardware_a1_mpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ a1_default_foot_pos_RR_x: -0.17
a1_default_foot_pos_RR_y: -0.15
a1_default_foot_pos_RR_z: -0.3

a1_gait_counter_speed_FL: 1.1
a1_gait_counter_speed_FR: 1.1
a1_gait_counter_speed_RL: 1.1
a1_gait_counter_speed_RR: 1.1
a1_gait_counter_speed_FL: 1.4
a1_gait_counter_speed_FR: 1.4
a1_gait_counter_speed_RL: 1.4
a1_gait_counter_speed_RR: 1.4

# MPC parameters

Expand All @@ -56,21 +56,21 @@ q_weights_11: 0.3 # vel z

q_weights_12: 0.0

r_weights_0: 1e-5
r_weights_1: 1e-5
r_weights_2: 1e-6
r_weights_0: 1e-2
r_weights_1: 1e-2
r_weights_2: 1e-3

r_weights_3: 1e-5
r_weights_4: 1e-5
r_weights_5: 1e-6
r_weights_3: 1e-2
r_weights_4: 1e-2
r_weights_5: 1e-3

r_weights_6: 1e-5
r_weights_7: 1e-5
r_weights_8: 1e-6
r_weights_6: 1e-2
r_weights_7: 1e-2
r_weights_8: 1e-3

r_weights_9: 1e-6
r_weights_10: 1e-6
r_weights_11: 1e-6
r_weights_9: 1e-2
r_weights_10: 1e-2
r_weights_11: 1e-3

# foot swing controller parameters
# force_tgt = km_foot * kp_foot * foot_pos_error
Expand All @@ -79,9 +79,9 @@ a1_kp_foot_x: 120.0
a1_kp_foot_y: 120.0
a1_kp_foot_z: 80.0

a1_kd_foot_x: 5.0
a1_kd_foot_y: 5.0
a1_kd_foot_z: 8.0
a1_kd_foot_x: 6.0
a1_kd_foot_y: 6.0
a1_kd_foot_z: 5.0

a1_km_foot_x: 0.1
a1_km_foot_y: 0.1
Expand Down
2 changes: 1 addition & 1 deletion src/a1_cpp/src/A1RobotControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ Eigen::Matrix<double, 3, NUM_LEG> A1RobotControl::compute_grf(A1CtrlStates &stat
double mpc_dt = 0.0025;

// in simulation, use dt has no problem
if (use_sim_time == true) {
if (use_sim_time == "true") {
mpc_dt = dt;
}

Expand Down
2 changes: 1 addition & 1 deletion src/a1_cpp/src/A1RobotControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class A1RobotControl {
//MPC does not start for the first 10 ticks to prevent uninitialized NAN goes into joint_torques
int mpc_init_counter;

bool use_sim_time;
std::string use_sim_time;

// filters
MovingWindowFilter terrain_angle_filter;
Expand Down
11 changes: 4 additions & 7 deletions src/a1_cpp/src/MainGazebo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,12 @@ int main(int argc, char **argv) {
}

// make sure the ROS infra using sim time, otherwise the controller cannot run with correct time steps
bool use_sim_time;
if (nh.getParam("/use_sim_time", use_sim_time)) {
if (use_sim_time != true) {
std::cout << "ROS must set use_sim_time to be true in order to use this program!" << std::endl;
std::string use_sim_time;
if (ros::param::get("/use_sim_time", use_sim_time)) {
if (use_sim_time != "true") {
std::cout << "ROS must set use_sim_time in order to use this program!" << std::endl;
return -1;
}
} else {
std::cout << "ROS must set use_sim_time in order to use this program!" << std::endl;
return -1;
}

// create a1 controller
Expand Down
4 changes: 2 additions & 2 deletions src/a1_cpp/src/MainHardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ int main(int argc, char **argv) {
}

// make sure the ROS infra DO NOT use sim time, otherwise the controller cannot run with correct time steps
bool use_sim_time;
std::string use_sim_time;
if (ros::param::get("/use_sim_time", use_sim_time)) {
if (use_sim_time != false) {
if (use_sim_time != "false") {
std::cout << "hardware must have real time in order to use this program!" << std::endl;
return -1;
}
Expand Down
11 changes: 6 additions & 5 deletions src/a1_cpp/src/MainIsaac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ int main(int argc, char **argv) {
}

// make sure the ROS infra using sim time, otherwise the controller cannot run with correct time steps
bool use_sim_time;
if (nh.getParam("/use_sim_time", use_sim_time)) {
if (use_sim_time != true) {
std::cout << "ROS must set use_sim_time to be true in order to use this program!" << std::endl;
std::string use_sim_time;
if (ros::param::get("/use_sim_time", use_sim_time)) {
if (use_sim_time != "true") {
std::cout << "ROS must set use_sim_time in order to use this program!" << std::endl;
return -1;
}
} else {
}
else {
std::cout << "ROS must set use_sim_time in order to use this program!" << std::endl;
return -1;
}
Expand Down

0 comments on commit dc07ae8

Please sign in to comment.