Browse Source

AP_Beacon: Added Marvelmind beacon example.

This commit includes an example program to
run the code of AP_Marvelmind class.
It also includes a dump from the marvelmind
serial as well as a script that injects
this dump into the example for demonstration.
mission-4.1.18
Paulo Neves 8 years ago committed by Randy Mackay
parent
commit
3158cafefd
  1. 54
      libraries/AP_Beacon/examples/AP_Marvelmind_test/AP_Marvelmind_test.cpp
  2. 9
      libraries/AP_Beacon/examples/AP_Marvelmind_test/inject_marvelmind_dump.sh
  3. BIN
      libraries/AP_Beacon/examples/AP_Marvelmind_test/sample.dump
  4. 7
      libraries/AP_Beacon/examples/AP_Marvelmind_test/wscript

54
libraries/AP_Beacon/examples/AP_Marvelmind_test/AP_Marvelmind_test.cpp

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
/*
simple test of UART interfaces
*/
#include <AP_HAL/AP_HAL.h>
#include <AP_Beacon/AP_Beacon_Marvelmind.h>
#include <AP_Beacon/AP_Beacon.h>
#if HAL_OS_POSIX_IO
#include <stdio.h>
#endif
void setup();
void loop();
const AP_HAL::HAL& hal = AP_HAL::get_HAL();
static AP_SerialManager serial_manager;
AP_Beacon beacon{serial_manager};
// try to set the object value but provide diagnostic if it failed
void set_object_value(const void *object_pointer,
const struct AP_Param::GroupInfo *group_info,
const char *name, float value)
{
if (!AP_Param::set_object_value(object_pointer, group_info, name, value)) {
printf("WARNING: AP_Param::set object value \"%s::%s\" Failed.\n",
group_info->name, name);
}
}
void setup(void)
{
set_object_value(&beacon, beacon.var_info, "_TYPE", 2.0f);
set_object_value(&serial_manager, serial_manager.var_info, "0_PROTOCOL", 13.0f);
serial_manager.init();
beacon.init();
}
void loop(void)
{
static int count = 0;
beacon.update();
Vector3f pos;
float accuracy = 0.0f;
beacon.get_vehicle_position_ned(pos, accuracy);
if (pos.x > 0.001f) {
printf("%f %f %f\n", pos.x, pos.y, pos.z);
count++;
}
hal.scheduler->delay(1000);
if (count == 3)
exit(0);
}
AP_HAL_MAIN();

9
libraries/AP_Beacon/examples/AP_Marvelmind_test/inject_marvelmind_dump.sh

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
#!/bin/sh
./waf configure --board=linux --debug
./waf build --target=examples/AP_Marvelmind_test -j6
repo_root="$(git rev-parse --show-toplevel)/"
"$repo_root/build/linux-debug/examples/AP_Marvelmind_test" -A tcp:127.0.0.1:5111 &
sleep 1
cat ${repo_root}/libraries/AP_Beacon/examples/AP_Marvelmind_test/sample.dump| socat - tcp:127.0.0.1:5111
wait

BIN
libraries/AP_Beacon/examples/AP_Marvelmind_test/sample.dump

Binary file not shown.

7
libraries/AP_Beacon/examples/AP_Marvelmind_test/wscript

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
#!/usr/bin/env python
# encoding: utf-8
def build(bld):
bld.ap_example(
use='ap',
)
Loading…
Cancel
Save