Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -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}}
3 changes: 2 additions & 1 deletion alfred/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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})
Expand Down
1 change: 1 addition & 0 deletions alfred/build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Empty file removed alfred/build/.placeholder
Empty file.
9 changes: 7 additions & 2 deletions alfred/src/wiring_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/

#include "Arduino.h"
#include <time.h>
#include <pthread.h>

#define _BV(a) (1 << (a))

Expand All @@ -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) {
Expand All @@ -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);
}
Expand All @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions alfred/src/wiring_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion sunray/src/icm/util/ICM_20948_C.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "ICM_20948_C.h"
#include "ICM_20948_REGISTERS.h"
#include "AK09916_REGISTERS.h"
#include <string.h>

/*
* Icm20948 device require a DMP image to be loaded on init
Expand Down Expand Up @@ -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);

Expand Down
44 changes: 24 additions & 20 deletions sunray/src/lidar/lidar.cpp
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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();
}
Expand All @@ -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;
}

Expand All @@ -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(){
Expand All @@ -136,11 +140,11 @@ bool LidarBumperDriver::getLeftBumper(){

bool LidarBumperDriver::getRightBumper(){
return triggerBumper;
}
}

void LidarBumperDriver::getTriggeredBumper(bool &leftBumper, bool &rightBumper){
leftBumper = triggerBumper;
rightBumper = triggerBumper;
}
}


26 changes: 14 additions & 12 deletions sunray/src/lidar/lidar.h
Original file line number Diff line number Diff line change
@@ -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;
};

Expand All @@ -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;
};
Expand Down
21 changes: 11 additions & 10 deletions sunray/src/mpu/inv_mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@
*/
#include <Arduino.h>
//#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)
#define i2c_read(a, b, c, d) arduino_i2c_read(a, b, c, d)
#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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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:
Expand Down