Hi,
I am getting error in code. The error is Unknown CONFIG_HAL_BOARD type. I have taken the code from pi quad project but its not compiling.
Hi,
I am getting error in code. The error is Unknown CONFIG_HAL_BOARD type. I have taken the code from pi quad project but its not compiling.
Code?
"pi" as in "Raspberry Pi"? - are you sure you're in the right place?
Hi,
I am new to the forum. I dont know the whether this is the right place to post. Below I posting the code of arduino and error.
<
#include <AP_Common.h>
#include <AP_Math.h>
#include <AP_Param.h>
#include <AP_Progmem.h>
#include <AP_ADC.h>
#include <AP_InertialSensor.h>
#include <AP_HAL.h>
#include <AP_HAL_AVR.h>
#include <PID.h>
// ArduPilot Hardware Abstraction Layer
const AP_HAL::HAL& hal = AP_HAL_AVR_APM2;
// MPU6050 accel/gyro chip
AP_InertialSensor_MPU6000 ins;
// Motor numbers definitions
#define MOTOR_FL 2 // Front left
#define MOTOR_FR 0 // Front right
#define MOTOR_BL 1 // back left
#define MOTOR_BR 3 // back right
// Arduino map function
long map(long x, long in_min, long in_max, long out_min, long out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
#define wrap_180(x) (x < -180 ? x+360 : (x > 180 ? x - 360: x))
// PID array (6 pids, two for each axis)
PID pids[6];
#define PID_PITCH_RATE 0
#define PID_ROLL_RATE 1
#define PID_PITCH_STAB 2
#define PID_ROLL_STAB 3
#define PID_YAW_RATE 4
#define PID_YAW_STAB 5
void setup()
{
// Enable the motors and set at 490Hz update
hal.rcout->set_freq(0xF, 490);
hal.rcout->enable_mask(0xFF);
// PID Configuration
pids[PID_PITCH_RATE].kP(0.7);
pids[PID_PITCH_RATE].kI(1);
pids[PID_PITCH_RATE].imax(50);
pids[PID_ROLL_RATE].kP(0.7);
pids[PID_ROLL_RATE].kI(1);
pids[PID_ROLL_RATE].imax(50);
pids[PID_YAW_RATE].kP(2.7);
pids[PID_YAW_RATE].kI(1);
pids[PID_YAW_RATE].imax(50);
pids[PID_PITCH_STAB].kP(4.5);
pids[PID_ROLL_STAB].kP(4.5);
pids[PID_YAW_STAB].kP(10);
// Turn off Barometer to avoid bus collisions
hal.gpio->pinMode(40, GPIO_OUTPUT);
hal.gpio->write(40, 1);
// Turn on MPU6050 - quad must be kept still as gyros will calibrate
ins.init(AP_InertialSensor::COLD_START,
AP_InertialSensor::RATE_100HZ,
NULL);
// initialise sensor fusion on MPU6050 chip (aka DigitalMotionProcessing/DMP)
hal.scheduler->suspend_timer_procs(); // stop bus collisions
ins.dmp_init();
hal.scheduler->resume_timer_procs();
hal.uartA->begin(57600); // for radios
// We're ready to go! Now over to loop()
}
// serial command buffer
char buf[255];
int buf_offset = 0;
//checksum verifier
uint8_t verify_chksum(char str, char chk) {
uint8_t nc = 0;
for(int i=0; i<strlen(str); i++)
nc = (nc + str) << 1;
long chkl = strtol(chk, NULL, 16); // supplied chksum to long*
if(chkl == (long)nc) // compare*
return true;*
return false;*
}
void loop()
{
static float yaw_target = 0; *
// Wait until new orientation data (normally 5ms max)*
while (ins.num_samples_available() == 0);*
static uint32_t lastPkt = 0;*
static int16_t channels[8] = {0,0,0,0,0,0,0,0};*
// serial bytes available?*
int bytesAvail = hal.console->available();*
if(bytesAvail > 0) {*
while(bytesAvail > 0) { //yes*
char c = (char)hal.console->read(); //read next byte*
if(c == '\n') { // new line reached - process cmd*
buf[buf_offset] = '\0'; // null terminator*
// process cmd*
_ char str = strtok(buf, ""); // str = roll,pit,thr,yaw_
_ char chk = strtok(NULL, ""); // chk = chksum_
if(verify_chksum(str,chk)) { // if chksum OK*
_ char *ch = strtok(str, ","); // first channel_
channels[0] = (uint16_t)strtol(ch, NULL, 10); // parse*
for(int i=1; i<4; i++) { // loop through final 3 channels*
_ char *ch = strtok(NULL, ",");_
channels = (uint16_t)strtol(ch, NULL, 10);
_ }_
* lastPkt = hal.scheduler->millis(); // update last valid packet*
* } else {*
* hal.console->printf("Invalid chksum\n");*
* }*
* buf_offset = 0;
_ }_
_ else if(c != '\r') {_
buf[buf_offset++] = c; // store in buffer and continue until newline*
* }*
* bytesAvail --;*
* }*
* }*
* // turn throttle off if no update for 0.5seconds*
* if(hal.scheduler->millis() - lastPkt > 500)*
* channels[2] = 0;*
* long rcthr, rcyaw, rcpit, rcroll; // Variables to store radio in*
* // Read RC transmitter*
* rcthr = channels[2];*
* rcyaw = channels[3];*
* rcpit = channels[1];*
* rcroll = channels[0];*
* // Ask MPU6050 for orientation*
* ins.update();*
* float roll,pitch,yaw; *
* ins.quaternion.to_euler(&roll, &pitch, &yaw);
_ roll = ToDeg(roll) ;_
_ pitch = ToDeg(pitch) ;_
_ yaw = ToDeg(yaw) ;*_
* // Ask MPU6050 for gyro data*
* Vector3f gyro = ins.get_gyro();
_ float gyroPitch = ToDeg(gyro.y), gyroRoll = ToDeg(gyro.x), gyroYaw = ToDeg(gyro.z);*_
* // Do the magic*
* if(rcthr > RC_THR_MIN + 100) { // Throttle raised, turn on stablisation.
_ // Stablise PIDS*_
* float pitch_stab_output = constrain(pids[PID_PITCH_STAB].get_pid((float)rcpit - pitch, 1), -250, 250);
float roll_stab_output = constrain(pids[PID_ROLL_STAB].get_pid((float)rcroll - roll, 1), -250, 250);
float yaw_stab_output = constrain(pids[PID_YAW_STAB].get_pid(wrap_180(yaw_target - yaw), 1), -360, 360);*
* // is pilot asking for yaw change - if so feed directly to rate pid (overwriting yaw stab output)*
* if(abs(rcyaw ) > 5) {*
* yaw_stab_output = rcyaw;
yaw_target = yaw; // remember this yaw for when pilot stops*
* }*
* // rate PIDS*
* long pitch_output = (long) constrain(pids[PID_PITCH_RATE].get_pid(pitch_stab_output - gyroPitch, 1), - 500, 500);
long roll_output = (long) constrain(pids[PID_ROLL_RATE].get_pid(roll_stab_output - gyroRoll, 1), -500, 500);
long yaw_output = (long) constrain(pids[PID_ROLL_RATE].get_pid(yaw_stab_output - gyroYaw, 1), -500, 500);
_ // mix pid outputs and send to the motors._
hal.rcout->write(MOTOR_FL, rcthr + roll_output + pitch_output - yaw_output);
hal.rcout->write(MOTOR_BL, rcthr + roll_output - pitch_output + yaw_output);
hal.rcout->write(MOTOR_FR, rcthr - roll_output + pitch_output + yaw_output);
hal.rcout->write(MOTOR_BR, rcthr - roll_output - pitch_output - yaw_output);
_ } else {_
_ // motors off*_
* hal.rcout->write(MOTOR_FL, 1000);
hal.rcout->write(MOTOR_BL, 1000);
hal.rcout->write(MOTOR_FR, 1000);
hal.rcout->write(MOTOR_BR, 1000);*
* // reset yaw target so we maintain this on takeoff*
* yaw_target = yaw;*
* // reset PID integrals whilst on the ground*
* for(int i=0; i<6; i++)*
pids*.reset_I();
_ }
}
AP_HAL_MAIN();
Error:_
In file included from C:\Users\Sayeed\Documents\Arduino\libraries\libraries\AP_HAL/AP_HAL.h:9:0,
from C:\Users\Sayeed\Documents\Arduino\libraries\libraries\AP_Param/AP_Param.h:24,
from C:\Users\Sayeed\Documents\Arduino\libraries\libraries\AP_Math/AP_Math.h:9,
_ from pi-quad.ino:2:_
C:\Users\Sayeed\Documents\Arduino\libraries\libraries\AP_HAL/AP_HAL_Boards.h:50:2: error: #error "Unknown CONFIG_HAL_BOARD type"
#error "Unknown CONFIG_HAL_BOARD type"
_ ^
In file included from C:\Users\Sayeed\Documents\Arduino\libraries\libraries\AP_InertialSensor/AP_InertialSensor.h:194:0,
from pi-quad.ino:6:_
C:\Users\Sayeed\Documents\Arduino\libraries\libraries\AP_InertialSensor/AP_InertialSensor_UserInteract_MAVLink.h:6:25: fatal error: GCS_MAVLink.h: No such file or directory
#include <GCS_MAVLink.h>
_ ^
compilation terminated.
Error compiling.
/>*_
C:\Users\Sayeed\Documents\Arduino\libraries\libraries\AP_InertialSensor/AP_InertialSensor_UserInteract_MAVLink.h:6:25: fatal error: GCS_MAVLink.h: No such file or directory
#include <GCS_MAVLink.h>
^
Bit of a clue there, don't you think?
Please, please use code tags when posting code.
Please edit your post and put code tags (</> above the editor window) to get rid of the italics in you code and make it readable and possible to copy/paste easily.
fatal error: GCS_MAVLink.h: No such file or directory
Do you have this file on your system ?
Hi,
I have checked the library folder the library exist there.
And did you restart the IDE after installing the library?
Hi,
I have restarted and test getting same error.
Exactly where did you put the library?
Hi,
I have not placed the library it was already exist in default location that is "Documents\Arduino\libraries".
I am sorry to be pedantic but what is the name of the library folder and which files does it contain ?
Hi,
This is the folder "Documents\Arduino\libraries\GCS_MAVLink".
Please read reply #10
Hi,
The library name GCS_MAVLink. It contains the following files.
GCS_MAVLink.h
GCS_MAVLink.cpp
generate.sh
What does the #include line for GCS_MAVLink.h look like ?
I think that you will find it in C:\Users\Sayeed\Documents\Arduino\libraries\libraries\AP_InertialSensor/AP_InertialSensor_UserInteract_MAVLink.h
Hi,
This is the code in the file.
<
#ifndef AP_INERTIAL_SENSOR_USER_INTERACT_MAVLINK_H
#define AP_INERTIAL_SENSOR_USER_INTERACT_MAVLINK_H
#include <AP_HAL.h>
#include <GCS_MAVLink.h>
#include "AP_InertialSensor_UserInteract.h"
/**
uint8_t blocking_read();
void _printf_P(const prog_char *, ...);
private:
mavlink_channel_t _chan;
};
#endif // AP_INERTIAL_SENSOR_USER_INTERACT_MAVLINK_H
/>
#include <GCS_MAVLink.h>That looks OK so I am out of ideas.
Hi,
I am attaching my code file can anybody download and check whether they are getting same error or my IDE has some issue. This is for exam and the final review is on Friday. So any help is appreciated.
pi-quad.ino (6.21 KB)
The main .ino file is not going to be any use without all of the libraries
Hi,
But all other libraries are not standard one.