diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 000000000..d72ca45e6 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,29 @@ +on: + push: + pull_request: + +name: Build Alfred Variants + +jobs: + alfred: + name: Alfred Config + runs-on: ubuntu-latest + strategy: + matrix: + config: [config_alfred.h, config_sim.h, config_owlmower.h, config_owl_fuxtec_ros.h] + steps: + - name: Checkout Project + uses: actions/checkout@master + + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y libbluetooth-dev + + - name: Build Project + uses: threeal/cmake-action@v2.1.0 + with: + source-dir: alfred + build-dir: alfred/build + options: | + CONFIG_FILE=${{github.workspace}}/alfred/${{matrix.config}} diff --git a/alfred/CMakeLists.txt b/alfred/CMakeLists.txt index e0d5da8dd..85303df6b 100644 --- a/alfred/CMakeLists.txt +++ b/alfred/CMakeLists.txt @@ -30,7 +30,6 @@ endif() # find_path (LIBNL_INCLUDE_DIR netlink/netlink.h libnl3) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -lbluetooth") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x c") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x c -I /usr/include/libnl3/") SET(CMAKE_BUILD_TYPE Debug) @@ -89,6 +88,8 @@ set_source_files_properties(${FIRMWARE_PATH}/sunray.ino PROPERTIES COMPILE_FLAGS add_executable(sunray ${pi_sources} ${sunray_cpp} ${sunray_c} ${FIRMWARE_PATH}/sunray.ino) target_include_directories(sunray PRIVATE src ${FIRMWARE_PATH}/src) +target_link_libraries(sunray bluetooth) +set_target_properties(sunray PROPERTIES COMPILE_FLAGS -pthread LINK_FLAGS -pthread) # target_link_libraries(sunray "${CMAKE_SOURCE_DIR}/lib/libarduino_${CMAKE_SYSTEM_PROCESSOR}.a") # target_include_directories(sunray PUBLIC ${LIBNL_INCLUDE_DIR}) diff --git a/alfred/build/.gitignore b/alfred/build/.gitignore new file mode 100644 index 000000000..72e8ffc0d --- /dev/null +++ b/alfred/build/.gitignore @@ -0,0 +1 @@ +* diff --git a/alfred/build/.placeholder b/alfred/build/.placeholder deleted file mode 100644 index e69de29bb..000000000 diff --git a/alfred/src/wiring_int.c b/alfred/src/wiring_int.c index a526373cf..ed43678de 100644 --- a/alfred/src/wiring_int.c +++ b/alfred/src/wiring_int.c @@ -18,6 +18,8 @@ */ #include "Arduino.h" +#include +#include #define _BV(a) (1 << (a)) @@ -39,6 +41,9 @@ void *isr_executor_task(void *isr_num){ } void *_isr_check_task(void *arg __attribute__((unused))){ + struct timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = 100 * 1000; while(_pin_isr_reg != 0){ uint64_t state = 0; //GPLEV0; if(_pin_isr_reg >> 32) { @@ -63,7 +68,7 @@ void *_isr_check_task(void *arg __attribute__((unused))){ } } if(_pin_isr_reg > 0) - usleep(100); + nanosleep(&ts, NULL); } pthread_exit(NULL); } @@ -78,7 +83,7 @@ void attachInterrupt(uint8_t pin, void (*userFunc)(void), int mode) { _pin_isr_last |= (digitalRead(pin) << pin); _pin_isr_reg |= _BV(pin); if(start && pthread_create(&_pin_isr_thread, NULL, _isr_check_task, NULL) == 0){ - pthread_setname_np(_pin_isr_thread, "arduino-isr"); + thread_set_name(_pin_isr_thread, "arduino-isr"); pthread_detach(_pin_isr_thread); } } diff --git a/alfred/src/wiring_thread.c b/alfred/src/wiring_thread.c index 4a4037381..6b21d8961 100644 --- a/alfred/src/wiring_thread.c +++ b/alfred/src/wiring_thread.c @@ -44,7 +44,7 @@ pthread_t thread_create(thread_fn fn, void * arg){ } int thread_set_name(pthread_t t, const char *name){ - return pthread_setname_np(t, name); + return thread_set_name(t, name); } int thread_set_priority(const int pri){ @@ -67,7 +67,7 @@ int thread_terminate(pthread_t t){ } uint8_t thread_running(pthread_t t){ - int r = pthread_tryjoin_np(t, NULL); + int r = pthread_join(t, NULL); return (r==0 || r==EBUSY); } diff --git a/sunray/src/icm/util/ICM_20948_C.c b/sunray/src/icm/util/ICM_20948_C.c index 6a98a51c8..437522e9a 100644 --- a/sunray/src/icm/util/ICM_20948_C.c +++ b/sunray/src/icm/util/ICM_20948_C.c @@ -1,6 +1,7 @@ #include "ICM_20948_C.h" #include "ICM_20948_REGISTERS.h" #include "AK09916_REGISTERS.h" +#include /* * Icm20948 device require a DMP image to be loaded on init @@ -1976,7 +1977,7 @@ ICM_20948_Status_e inv_icm20948_enable_dmp_sensor_int(ICM_20948_Device_t *pdev, data_intr_ctl[0] = (unsigned char)(delta >> 8); data_intr_ctl[1] = (unsigned char)(delta & 0xff); pdev->_dataIntrCtl = delta; // Diagnostics - + // Write the interrupt control bits into memory address DATA_INTR_CTL result = inv_icm20948_write_mems(pdev, DATA_INTR_CTL, 2, (const unsigned char *)&data_intr_ctl); diff --git a/sunray/src/lidar/lidar.cpp b/sunray/src/lidar/lidar.cpp index b181364f0..f0d2ca2bd 100644 --- a/sunray/src/lidar/lidar.cpp +++ b/sunray/src/lidar/lidar.cpp @@ -1,4 +1,4 @@ -// Ardumower Sunray +// Ardumower Sunray // Copyright (c) 2013-2020 by Alexander Grau, Grau GmbH // Licensed GPLv3 for open source use // or Grau GmbH Commercial License for commercial use (http://grauonline.de/cms2/?page_id=153) @@ -37,16 +37,16 @@ LidarGpsDriver::LidarGpsDriver() hour = 0; mins = 0; sec = 0; - dayOfWeek = 0; + dayOfWeek = 0; } void LidarGpsDriver::begin(){ - CONSOLE.println("using gps driver: LiDAR"); - + CONSOLE.println("using gps driver: LiDAR"); + } void LidarGpsDriver::begin(HardwareSerial& bus,uint32_t baud) -{ +{ CONSOLE.println("LiDAR::begin serial"); begin(); } @@ -58,32 +58,36 @@ void LidarGpsDriver::begin(Client &client, char *host, uint16_t port) begin(); } -bool LidarGpsDriver::configure(){ - CONSOLE.println("using LiDAR..."); +bool LidarGpsDriver::configure(){ + CONSOLE.println("using LiDAR..."); return true; } void LidarGpsDriver::reboot(){ - CONSOLE.println("reboot LiDAR..."); + CONSOLE.println("reboot LiDAR..."); } void LidarGpsDriver::run(){ +} +void LidarGpsDriver::send(const uint8_t *buffer, size_t size) { +} +void LidarGpsDriver::sendRTCM(const uint8_t *buffer, size_t size) { } // --------------------------------------------------------- -LidarImuDriver::LidarImuDriver(){ +LidarImuDriver::LidarImuDriver(){ dataAvail = false; imuFound = false; } -void LidarImuDriver::detect(){ +void LidarImuDriver::detect(){ } -bool LidarImuDriver::begin(){ +bool LidarImuDriver::begin(){ return true; } @@ -93,29 +97,29 @@ void LidarImuDriver::run(){ bool LidarImuDriver::isDataAvail(){ - + bool res = dataAvail; - dataAvail = false; + dataAvail = false; return res; -} - +} + void LidarImuDriver::resetData(){ - + } // --------------------------------------------------------- -LidarBumperDriver::LidarBumperDriver(){ +LidarBumperDriver::LidarBumperDriver(){ triggerBumper = false; triggerNearObstacle = false; } void LidarBumperDriver::begin(){ - CONSOLE.println("using bumper driver: LiDAR"); + CONSOLE.println("using bumper driver: LiDAR"); } void LidarBumperDriver::run(){ @@ -136,11 +140,11 @@ bool LidarBumperDriver::getLeftBumper(){ bool LidarBumperDriver::getRightBumper(){ return triggerBumper; -} +} void LidarBumperDriver::getTriggeredBumper(bool &leftBumper, bool &rightBumper){ leftBumper = triggerBumper; rightBumper = triggerBumper; -} +} diff --git a/sunray/src/lidar/lidar.h b/sunray/src/lidar/lidar.h index c8f068f8f..e360fc80a 100644 --- a/sunray/src/lidar/lidar.h +++ b/sunray/src/lidar/lidar.h @@ -1,42 +1,44 @@ /* -// Ardumower Sunray +// Ardumower Sunray // Copyright (c) 2013-2020 by Alexander Grau, Grau GmbH // Licensed GPLv3 for open source use // or Grau GmbH Commercial License for commercial use (http://grauonline.de/cms2/?page_id=153) LiDAR localization - + */ #ifndef LiDAR_h #define LiDAR_h -#include "Arduino.h" +#include "Arduino.h" #include "../../gps.h" #include "../driver/RobotDriver.h" class LidarGpsDriver : public GpsDriver { public: - LidarGpsDriver(); + LidarGpsDriver(); void begin(); void begin(Client &client, char *host, uint16_t port) override; void begin(HardwareSerial& bus,uint32_t baud) override; void run() override; - bool configure() override; + bool configure() override; void reboot() override; + void send(const uint8_t *buffer, size_t size) override; + void sendRTCM(const uint8_t*, size_t) override; private: }; -class LidarImuDriver: public ImuDriver { - public: - LidarImuDriver(); +class LidarImuDriver: public ImuDriver { + public: + LidarImuDriver(); void detect() override; - bool begin() override; + bool begin() override; void run() override; - bool isDataAvail() override; - void resetData() override; + bool isDataAvail() override; + void resetData() override; bool dataAvail; }; @@ -50,7 +52,7 @@ class LidarBumperDriver: public BumperDriver { bool obstacle() override; bool getLeftBumper() override; bool getRightBumper() override; - void getTriggeredBumper(bool &leftBumper, bool &rightBumper) override; + void getTriggeredBumper(bool &leftBumper, bool &rightBumper) override; bool triggerBumper; bool triggerNearObstacle; }; diff --git a/sunray/src/mpu/inv_mpu.c b/sunray/src/mpu/inv_mpu.c index f08c24bd2..49125782a 100644 --- a/sunray/src/mpu/inv_mpu.c +++ b/sunray/src/mpu/inv_mpu.c @@ -39,6 +39,7 @@ */ #include //#define MPU9250 +#include "arduino_mpu9250_log.h" #include "arduino_mpu9250_i2c.h" #include "arduino_mpu9250_clk.h" #define i2c_write(a, b, c, d) arduino_i2c_write(a, b, c, d) @@ -46,7 +47,7 @@ #define delay_ms arduino_delay_ms #define get_ms arduino_get_clock_ms #define log_i _MLPrintLog -#define log_e _MLPrintLog +#define log_e _MLPrintLog static inline int reg_int_cb(struct int_param_s *int_param) { return 0; @@ -434,7 +435,7 @@ const struct gyro_reg_s reg = { #endif }; const struct hw_s hw = { - .addr = MPU_ADDR, // 0x69, + .addr = MPU_ADDR, // 0x69, .max_fifo = 1024, .num_reg = 118, .temp_sens = 340, @@ -610,7 +611,7 @@ int mpu_reg_dump(void) continue; if (i2c_read(st.hw->addr, ii, 1, &data)) return -1; - log_i("%#5x: %#5x\r\n", ii, data); + log_i(ii, "tag", "%#5x: %#5x\r\n", data); } return 0; } @@ -704,7 +705,7 @@ int mpu_init(struct int_param_s *int_param) if (mpu_configure_fifo(0)) return -1; -#ifndef EMPL_TARGET_STM32F4 +#ifndef EMPL_TARGET_STM32F4 if (int_param) reg_int_cb(int_param); #endif @@ -889,7 +890,7 @@ int mpu_get_temperature(long *data, unsigned long *timestamp) /** * @brief Read biases to the accel bias 6500 registers. * This function reads from the MPU6500 accel offset cancellations registers. - * The format are G in +-8G format. The register is initialized with OTP + * The format are G in +-8G format. The register is initialized with OTP * factory trim values. * @param[in] accel_bias returned structure with the accel bias * @return 0 if successful. @@ -911,7 +912,7 @@ int mpu_read_6500_accel_bias(long *accel_bias) { /** * @brief Read biases to the accel bias 6050 registers. * This function reads from the MPU6050 accel offset cancellations registers. - * The format are G in +-8G format. The register is initialized with OTP + * The format are G in +-8G format. The register is initialized with OTP * factory trim values. * @param[in] accel_bias returned structure with the accel bias * @return 0 if successful. @@ -1936,7 +1937,7 @@ static int gyro_self_test(long *bias_regular, long *bias_st) return result; } -#endif +#endif #ifdef AK89xx_SECONDARY static int compass_self_test(void) { @@ -1983,13 +1984,13 @@ static int compass_self_test(void) result |= 0x04; #elif defined MPU9250 data = (short)(tmp[1] << 8) | tmp[0]; - if ((data > 200) || (data < -200)) + if ((data > 200) || (data < -200)) result |= 0x01; data = (short)(tmp[3] << 8) | tmp[2]; - if ((data > 200) || (data < -200)) + if ((data > 200) || (data < -200)) result |= 0x02; data = (short)(tmp[5] << 8) | tmp[4]; - if ((data > -800) || (data < -3200)) + if ((data > -800) || (data < -3200)) result |= 0x04; #endif AKM_restore: