mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-07 17:49:49 +08:00
added sonar sensor to twog which forwards us the adc values.
This commit is contained in:
@@ -10,8 +10,9 @@
|
||||
#include "settings.h"
|
||||
|
||||
//bill laptop
|
||||
//#define GCS_HOST "10.31.4.5"
|
||||
#define GCS_HOST "192.168.2.10"
|
||||
#define GCS_HOST "10.31.4.5"
|
||||
//#define GCS_HOST "192.168.2.10"
|
||||
//#define GCS_HOST "192.168.2.1"
|
||||
//auto4
|
||||
//#define GCS_HOST "10.31.4.104"
|
||||
#define GCS_PORT 4242
|
||||
|
||||
@@ -67,6 +67,17 @@ static uint8_t donegpsconf = 0;
|
||||
#endif
|
||||
static uint8_t configgps = 0;
|
||||
|
||||
|
||||
extern float phi;
|
||||
extern float psi;
|
||||
extern float theta;
|
||||
extern uint16_t throttle;
|
||||
extern uint16_t voltage;
|
||||
extern uint16_t amps;
|
||||
extern uint16_t energy;
|
||||
extern uint16_t adc1;
|
||||
extern uint16_t adc2;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
portnum = 0;
|
||||
|
||||
@@ -118,7 +129,8 @@ int main(int argc, char *argv[]) {
|
||||
static void main_periodic(int my_sig_num) {
|
||||
|
||||
|
||||
//RunOnceEvery(50, {DOWNLINK_SEND_ALIVE(gcs_com.udp_transport, 16, MD5SUM);});
|
||||
RunOnceEvery(50, {DOWNLINK_SEND_ALIVE(gcs_com.udp_transport, 16, MD5SUM);});
|
||||
RunOnceEvery(5, {DOWNLINK_SEND_ADC_GENERIC(gcs_com.udp_transport,&adc1,&adc2);});
|
||||
|
||||
#ifdef USE_UART0
|
||||
uart0_handler();
|
||||
|
||||
@@ -48,23 +48,59 @@
|
||||
#include "downlink.h"
|
||||
|
||||
|
||||
|
||||
#define MOfCm(_x) (((float)(_x))/100.)
|
||||
|
||||
#define SenderIdOfMsg(x) (x[0])
|
||||
#define IdOfMsg(x) (x[1])
|
||||
|
||||
float phi;
|
||||
float psi;
|
||||
float theta;
|
||||
uint16_t throttle;
|
||||
uint16_t voltage;
|
||||
uint16_t amps;
|
||||
uint16_t energy;
|
||||
uint16_t adc1;
|
||||
uint16_t adc2;
|
||||
|
||||
/*
|
||||
6 ATTITUDE
|
||||
8 GPS
|
||||
10 NAVIGATION
|
||||
12 BAT
|
||||
16 DESIRED
|
||||
35
|
||||
36
|
||||
37 ENERGY
|
||||
42 ESTIMATOR
|
||||
*/
|
||||
void dl_parse_msg(void) {
|
||||
datalink_time = 0;
|
||||
uint8_t msg_id = IdOfMsg(dl_buffer);
|
||||
printf("Tiny rx id: %d\n",msg_id);
|
||||
|
||||
if (msg_id == DL_ATTITUDE) {
|
||||
float phi = DL_ATTITUDE_phi(dl_buffer);
|
||||
float psi = DL_ATTITUDE_psi(dl_buffer);
|
||||
float theta = DL_ATTITUDE_theta(dl_buffer);
|
||||
if (msg_id == DL_ATTITUDE) {
|
||||
phi = DL_ATTITUDE_phi(dl_buffer);
|
||||
psi = DL_ATTITUDE_psi(dl_buffer);
|
||||
theta = DL_ATTITUDE_theta(dl_buffer);
|
||||
printf("Attitude: %f %f %f\n", phi, psi, theta);
|
||||
} else {
|
||||
printf("Unknown msg id %d",msg_id);
|
||||
}
|
||||
if (msg_id == DL_BAT) {
|
||||
throttle = DL_BAT_throttle(dl_buffer);
|
||||
voltage = DL_BAT_voltage(dl_buffer);
|
||||
amps = DL_BAT_amps(dl_buffer);
|
||||
energy = DL_BAT_energy(dl_buffer);
|
||||
printf("BAT: %d %d %d %d\n", throttle,voltage,amps,energy);
|
||||
}
|
||||
if (msg_id == DL_ADC_GENERIC) {
|
||||
adc1 = DL_ADC_GENERIC_val1(dl_buffer);
|
||||
adc2 = DL_ADC_GENERIC_val2(dl_buffer);
|
||||
printf("ADC: %d %d\n",adc1,adc2);
|
||||
}
|
||||
|
||||
else {
|
||||
//printf("Tiny msg_id %d unknown\n",msg_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user