MIT Cheetah-Software在Ubuntu20、Ubuntu21和ubuntu22中的环境搭建请参考优快云,但在编译时会报错,需要修改两处内容:
1、修改MIT Cheetah-Software项目中的顶级CMakeList.txt
if(MINI_CHEETAH_BUILD)
SET (THIS_COM "../" )
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
${CMAKE_BINARY_DIR}/Configuration.h)
set(CMAKE_CXX_FLAGS "-O3 -no-pie -ggdb -Wall \
-Wextra -Wcast-align -Wdisabled-optimization -Wformat=2 \
-Winit-self -Wmissing-include-dirs -Woverloaded-virtual \
-Wshadow -Wsign-promo -Werror -Wno-error=stringop-truncation")
set(CMAKE_C_FLAGS "-O3 -ggdb -std=gnu99 -I.")
message("**** Mini-Cheetah build enabled ****")
else(MINI_CHEETAH_BUILD)
SET (THIS_COM "${PROJECT_SOURCE_DIR}/" )
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
${CMAKE_BINARY_DIR}/Configuration.h)
if(CMAKE_SYSTEM_NAME MATCHES Linux)
set(CMAKE_CXX_FLAGS "-O3 -no-pie -march=native -ggdb -Wall \
-Wextra -Wcast-align -Wdisabled-optimization -Wformat=2 \
-Winit-self -Wmissing-include-dirs -Woverloaded-virtual \
-Wshadow -Wsign-promo -Werror -Wno-error=stringop-truncation")
elseif(APPLE)
set(CMAKE_CXX_FLAGS "-O3 -march=native -ggdb -Wall \
-Wextra -Wcast-align -Wdisabled-optimization -Wformat=2 \
-Winit-self -Wmissing-include-dirs -Woverloaded-virtual \
-Wshadow -Wsign-promo")
include_directories("/usr/local/include/") # lcm includes
endif()
set(CMAKE_C_FLAGS "-O3 -ggdb -march=native -std=gnu99 -I.")
message("**** Mini-Cheetah build disabled ****")
endif(MINI_CHEETAH_BUILD)
上面代码中添加了两处-Wno-error=stringop-truncation。
2、修改robot/src/rt/rt_serial.cpp
#ifdef linux
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define termios asmtermios
#include <asm/termios.h>
#undef termios
#include <termios.h>
#include <math.h>
#include <pthread.h>
#if 0
#include <stropts.h>
#else
//#include <sys/ioctl.h>
extern "C"
{
extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
}
#endif
在ubuntu20、ubuntu21和ubuntu22中不存在头文件stropts.h。因此需要将#include <stropts.h>替换成extern "C" int ioctl (int __fd, unsigned long int __request, ...) __THROW;