fit the new unitree_legged_sdk

This commit is contained in:
Bian Zekun 2020-08-26 15:27:17 +08:00
parent b238d44432
commit ccb6143b51
4 changed files with 27 additions and 20 deletions

View File

@ -35,7 +35,7 @@ double jointLinearInterpolation(double initPos, double targetPos, double rate)
}
template<typename TCmd, typename TState, typename TLCM>
int mainHelper(int argc, char *argv[])
int mainHelper(int argc, char *argv[], TLCM &roslcm)
{
std::cout << "WARNING: Control level is set to LOW-level." << std::endl
<< "Make sure the robot is hung up." << std::endl
@ -57,7 +57,7 @@ int mainHelper(int argc, char *argv[])
TState RecvLowLCM = {0};
unitree_legged_msgs::LowCmd SendLowROS;
unitree_legged_msgs::LowState RecvLowROS;
TLCM roslcm;
bool initiated_flag = false; // initiate need time
int count = 0;
@ -166,7 +166,8 @@ int main(int argc, char *argv[]){
if(firmwork == "3_1"){
aliengo::Control control(aliengo::LOWLEVEL);
mainHelper<aliengo::LowCmd, aliengo::LowState, aliengo::LCM>(argc, argv);
aliengo::LCM roslcm;
mainHelper<aliengo::LowCmd, aliengo::LowState, aliengo::LCM>(argc, argv, roslcm);
}
else if(firmwork == "3_2"){
std::string robot_name;
@ -177,7 +178,9 @@ int main(int argc, char *argv[]){
else if(strcasecmp(robot_name.c_str(), "Aliengo") == 0)
rname = UNITREE_LEGGED_SDK::LeggedType::Aliengo;
UNITREE_LEGGED_SDK::Control control(rname, UNITREE_LEGGED_SDK::LOWLEVEL);
mainHelper<UNITREE_LEGGED_SDK::LowCmd, UNITREE_LEGGED_SDK::LowState, UNITREE_LEGGED_SDK::LCM>(argc, argv);
// UNITREE_LEGGED_SDK::Control control(rname, UNITREE_LEGGED_SDK::LOWLEVEL);
UNITREE_LEGGED_SDK::InitEnvironment();
UNITREE_LEGGED_SDK::LCM roslcm(LOWLEVEL);
mainHelper<UNITREE_LEGGED_SDK::LowCmd, UNITREE_LEGGED_SDK::LowState, UNITREE_LEGGED_SDK::LCM>(argc, argv, roslcm);
}
}

View File

@ -26,7 +26,7 @@ void* update_loop(void* param)
}
template<typename TCmd, typename TState, typename TLCM>
int mainHelper(int argc, char *argv[])
int mainHelper(int argc, char *argv[], TLCM &roslcm)
{
std::cout << "WARNING: Control level is set to LOW-level." << std::endl
<< "Make sure the robot is hung up." << std::endl
@ -42,7 +42,6 @@ int mainHelper(int argc, char *argv[])
TState RecvLowLCM = {0};
unitree_legged_msgs::LowCmd SendLowROS;
unitree_legged_msgs::LowState RecvLowROS;
TLCM roslcm;
roslcm.SubscribeState();
@ -92,7 +91,8 @@ int main(int argc, char *argv[]){
if(firmwork == "3_1"){
aliengo::Control control(aliengo::LOWLEVEL);
mainHelper<aliengo::LowCmd, aliengo::LowState, aliengo::LCM>(argc, argv);
aliengo::LCM roslcm;
mainHelper<aliengo::LowCmd, aliengo::LowState, aliengo::LCM>(argc, argv, roslcm);
}
else if(firmwork == "3_2"){
std::string robot_name;
@ -103,7 +103,8 @@ int main(int argc, char *argv[]){
else if(strcasecmp(robot_name.c_str(), "Aliengo") == 0)
rname = UNITREE_LEGGED_SDK::LeggedType::Aliengo;
UNITREE_LEGGED_SDK::Control control(rname, UNITREE_LEGGED_SDK::LOWLEVEL);
mainHelper<UNITREE_LEGGED_SDK::LowCmd, UNITREE_LEGGED_SDK::LowState, UNITREE_LEGGED_SDK::LCM>(argc, argv);
UNITREE_LEGGED_SDK::InitEnvironment();
UNITREE_LEGGED_SDK::LCM roslcm(LOWLEVEL);
mainHelper<UNITREE_LEGGED_SDK::LowCmd, UNITREE_LEGGED_SDK::LowState, UNITREE_LEGGED_SDK::LCM>(argc, argv, roslcm);
}
}

View File

@ -27,7 +27,7 @@ void* update_loop(void* param)
}
template<typename TCmd, typename TState, typename TLCM>
int mainHelper(int argc, char *argv[])
int mainHelper(int argc, char *argv[], TLCM &roslcm)
{
std::cout << "WARNING: Control level is set to LOW-level." << std::endl
<< "Make sure the robot is hung up." << std::endl
@ -45,7 +45,6 @@ int mainHelper(int argc, char *argv[])
TState RecvLowLCM = {0};
unitree_legged_msgs::LowCmd SendLowROS;
unitree_legged_msgs::LowState RecvLowROS;
TLCM roslcm;
roslcm.SubscribeState();
@ -95,7 +94,8 @@ int main(int argc, char *argv[]){
if(firmwork == "3_1"){
aliengo::Control control(aliengo::LOWLEVEL);
mainHelper<aliengo::LowCmd, aliengo::LowState, aliengo::LCM>(argc, argv);
aliengo::LCM roslcm;
mainHelper<aliengo::LowCmd, aliengo::LowState, aliengo::LCM>(argc, argv, roslcm);
}
else if(firmwork == "3_2"){
std::string robot_name;
@ -106,7 +106,9 @@ int main(int argc, char *argv[]){
else if(strcasecmp(robot_name.c_str(), "Aliengo") == 0)
rname = UNITREE_LEGGED_SDK::LeggedType::Aliengo;
UNITREE_LEGGED_SDK::Control control(rname, UNITREE_LEGGED_SDK::LOWLEVEL);
mainHelper<UNITREE_LEGGED_SDK::LowCmd, UNITREE_LEGGED_SDK::LowState, UNITREE_LEGGED_SDK::LCM>(argc, argv);
// UNITREE_LEGGED_SDK::Control control(rname, UNITREE_LEGGED_SDK::LOWLEVEL);
UNITREE_LEGGED_SDK::InitEnvironment();
UNITREE_LEGGED_SDK::LCM roslcm(LOWLEVEL);
mainHelper<UNITREE_LEGGED_SDK::LowCmd, UNITREE_LEGGED_SDK::LowState, UNITREE_LEGGED_SDK::LCM>(argc, argv, roslcm);
}
}

View File

@ -27,7 +27,7 @@ void* update_loop(void* param)
}
template<typename TCmd, typename TState, typename TLCM>
int mainHelper(int argc, char *argv[])
int mainHelper(int argc, char *argv[], TLCM &roslcm)
{
std::cout << "WARNING: Control level is set to HIGH-level." << std::endl
<< "Make sure the robot is standing on the ground." << std::endl
@ -43,7 +43,6 @@ int mainHelper(int argc, char *argv[])
TState RecvHighLCM = {0};
unitree_legged_msgs::HighCmd SendHighROS;
unitree_legged_msgs::HighState RecvHighROS;
TLCM roslcm;
roslcm.SubscribeState();
@ -139,7 +138,8 @@ int main(int argc, char *argv[]){
if(firmwork == "3_1"){
aliengo::Control control(aliengo::HIGHLEVEL);
mainHelper<aliengo::HighCmd, aliengo::HighState, aliengo::LCM>(argc, argv);
aliengo::LCM roslcm;
mainHelper<aliengo::HighCmd, aliengo::HighState, aliengo::LCM>(argc, argv, roslcm);
}
else if(firmwork == "3_2"){
std::string robot_name;
@ -150,8 +150,9 @@ int main(int argc, char *argv[]){
else if(strcasecmp(robot_name.c_str(), "Aliengo") == 0)
rname = UNITREE_LEGGED_SDK::LeggedType::Aliengo;
UNITREE_LEGGED_SDK::Control control(rname, UNITREE_LEGGED_SDK::LOWLEVEL);
mainHelper<UNITREE_LEGGED_SDK::HighCmd, UNITREE_LEGGED_SDK::HighState, UNITREE_LEGGED_SDK::LCM>(argc, argv);
UNITREE_LEGGED_SDK::InitEnvironment();
UNITREE_LEGGED_SDK::LCM roslcm(UNITREE_LEGGED_SDK::HIGHLEVEL);
mainHelper<UNITREE_LEGGED_SDK::HighCmd, UNITREE_LEGGED_SDK::HighState, UNITREE_LEGGED_SDK::LCM>(argc, argv, roslcm);
}
}