mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 07:23:33 +08:00
delete parrot bebop board support
This target was never fully supported and is heavily dependent on a number of DriverFramework drivers that have no in tree equivalents (bebop bus, flow, rangefinder, etc). Deleting this will make it easier to fully drop DriverFramework shortly.
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2018 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
add_subdirectory(flow)
|
||||
@@ -1,41 +0,0 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2020 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
add_custom_target(upload
|
||||
COMMAND ${PX4_BOARD_DIR}/scripts/adb_upload_to_bebop.sh
|
||||
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||
/data/ftp/internal_000/px4
|
||||
DEPENDS px4 ${PX4_BOARD_DIR}/scripts/adb_upload_to_bebop.sh
|
||||
COMMENT "uploading px4"
|
||||
USES_TERMINAL
|
||||
)
|
||||
@@ -1,66 +0,0 @@
|
||||
|
||||
px4_add_board(
|
||||
VENDOR parrot
|
||||
MODEL bebop
|
||||
PLATFORM posix
|
||||
ARCHITECTURE cortex-a53
|
||||
TOOLCHAIN arm-linux-gnueabihf
|
||||
|
||||
DRIVERS
|
||||
barometer/ms5611
|
||||
gps
|
||||
linux_sbus
|
||||
pwm_out_sim
|
||||
|
||||
DF_DRIVERS # NOTE: DriverFramework is migrating to intree PX4 drivers
|
||||
mpu6050
|
||||
ak8963
|
||||
bebop_bus
|
||||
bebop_rangefinder
|
||||
mt9v117
|
||||
|
||||
MODULES
|
||||
attitude_estimator_q
|
||||
#camera_feedback
|
||||
commander
|
||||
dataman
|
||||
ekf2
|
||||
events
|
||||
#fw_att_control
|
||||
#fw_pos_control_l1
|
||||
#rover_pos_control
|
||||
land_detector
|
||||
landing_target_estimator
|
||||
load_mon
|
||||
local_position_estimator
|
||||
logger
|
||||
mavlink
|
||||
mc_att_control
|
||||
mc_rate_control
|
||||
mc_pos_control
|
||||
navigator
|
||||
rc_update
|
||||
sensors
|
||||
sih
|
||||
#vtol_att_control
|
||||
airspeed_selector
|
||||
|
||||
SYSTEMCMDS
|
||||
#config
|
||||
esc_calib
|
||||
led_control
|
||||
mixer
|
||||
motor_ramp
|
||||
param
|
||||
perf
|
||||
pwm
|
||||
reboot
|
||||
sd_bench
|
||||
#tests # tests and test runner
|
||||
top
|
||||
topic_listener
|
||||
tune_control
|
||||
ver
|
||||
work_queue
|
||||
|
||||
)
|
||||
@@ -1,47 +0,0 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2017 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
px4_add_module(
|
||||
MODULE drivers__bebop_flow
|
||||
MAIN bebop_flow
|
||||
INCLUDES
|
||||
${PX4_SOURCE_DIR}/src/lib/DriverFramework/drivers
|
||||
SRCS
|
||||
bebop_flow.cpp
|
||||
video_device.cpp
|
||||
dump_pgm.cpp
|
||||
DEPENDS
|
||||
git_driverframework
|
||||
df_driver_framework
|
||||
df_mt9v117
|
||||
)
|
||||
@@ -1,323 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file bebop_flow.cpp
|
||||
*
|
||||
* This is a wrapper around the Parrot Bebop's downward-facing camera and integrates
|
||||
* an optical flow computation.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <px4_platform_common/tasks.h>
|
||||
#include <px4_platform_common/getopt.h>
|
||||
#include <px4_platform_common/posix.h>
|
||||
|
||||
#include "video_device.h"
|
||||
#include "dump_pgm.h"
|
||||
#include <mt9v117/MT9V117.hpp>
|
||||
|
||||
extern "C" { __EXPORT int bebop_flow_main(int argc, char *argv[]); }
|
||||
|
||||
using namespace DriverFramework;
|
||||
|
||||
namespace bebop_flow
|
||||
{
|
||||
MT9V117 *image_sensor = nullptr; // I2C image sensor
|
||||
VideoDevice *g_dev = nullptr; // interface to the video device
|
||||
volatile bool _task_should_exit = false; // flag indicating if bebop flow task should exit
|
||||
static bool _is_running = false; // flag indicating if bebop flow app is running
|
||||
static px4_task_t _task_handle = -1; // handle to the task main thread
|
||||
volatile unsigned int _trigger = 0; // Number of images to write as pgm
|
||||
|
||||
const char *dev_name = "/dev/video0"; // V4L video device
|
||||
|
||||
int start();
|
||||
int stop();
|
||||
int info();
|
||||
int trigger(int count);
|
||||
int clear_errors();
|
||||
void usage();
|
||||
void task_main(int argc, char *argv[]);
|
||||
|
||||
void task_main(int argc, char *argv[])
|
||||
{
|
||||
_is_running = true;
|
||||
int ret = 0;
|
||||
struct frame_data frame {};
|
||||
uint32_t timeout_cnt = 0;
|
||||
|
||||
// Main loop
|
||||
while (!_task_should_exit) {
|
||||
|
||||
ret = g_dev->get_frame(frame);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("Get Frame failed");
|
||||
continue;
|
||||
|
||||
} else if (ret == 1) {
|
||||
// No image in buffer
|
||||
usleep(1000);
|
||||
++timeout_cnt;
|
||||
|
||||
if (timeout_cnt > 1000) {
|
||||
PX4_WARN("No frames received for 1 sec");
|
||||
timeout_cnt = 0;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
timeout_cnt = 0;
|
||||
|
||||
// Write images into a file
|
||||
if (_trigger > 0) {
|
||||
PX4_INFO("Trigger camera");
|
||||
|
||||
dump_pgm(frame.data, frame.bytes, frame.seq, frame.timestamp);
|
||||
--_trigger;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* Optical Flow computation
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
ret = g_dev->put_frame(frame);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("Put Frame failed");
|
||||
}
|
||||
}
|
||||
|
||||
_is_running = false;
|
||||
}
|
||||
|
||||
int start()
|
||||
{
|
||||
if (_is_running) {
|
||||
PX4_WARN("bebop_flow already running");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Prepare the I2C device
|
||||
image_sensor = new MT9V117(IMAGE_DEVICE_PATH);
|
||||
|
||||
if (image_sensor == nullptr) {
|
||||
PX4_ERR("failed instantiating image sensor object");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = image_sensor->start();
|
||||
|
||||
if (ret != 0) {
|
||||
PX4_ERR("Image sensor start failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Start the video device
|
||||
g_dev = new VideoDevice(dev_name, 6);
|
||||
|
||||
if (g_dev == nullptr) {
|
||||
PX4_ERR("failed instantiating video device object");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = g_dev->start();
|
||||
|
||||
if (ret != 0) {
|
||||
PX4_ERR("Video device start failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* start the task */
|
||||
_task_handle = px4_task_spawn_cmd("bebop_flow",
|
||||
SCHED_DEFAULT,
|
||||
SCHED_PRIORITY_DEFAULT,
|
||||
2000,
|
||||
(px4_main_t)&task_main,
|
||||
nullptr);
|
||||
|
||||
if (_task_handle < 0) {
|
||||
PX4_WARN("task start failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stop()
|
||||
{
|
||||
// Stop bebop flow task
|
||||
_task_should_exit = true;
|
||||
|
||||
while (_is_running) {
|
||||
usleep(200000);
|
||||
PX4_INFO(".");
|
||||
}
|
||||
|
||||
_task_handle = -1;
|
||||
_task_should_exit = false;
|
||||
_trigger = 0;
|
||||
|
||||
if (g_dev == nullptr) {
|
||||
PX4_ERR("driver not running");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = g_dev->stop();
|
||||
|
||||
if (ret != 0) {
|
||||
PX4_ERR("driver could not be stopped");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (image_sensor == nullptr) {
|
||||
PX4_ERR("Image sensor not running");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = image_sensor->stop();
|
||||
|
||||
if (ret != 0) {
|
||||
PX4_ERR("Image sensor driver could not be stopped");
|
||||
return ret;
|
||||
}
|
||||
|
||||
delete g_dev;
|
||||
delete image_sensor;
|
||||
g_dev = nullptr;
|
||||
image_sensor = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a little info about the driver.
|
||||
*/
|
||||
int
|
||||
info()
|
||||
{
|
||||
if (g_dev == nullptr) {
|
||||
PX4_ERR("driver not running");
|
||||
return 1;
|
||||
}
|
||||
|
||||
PX4_DEBUG("state @ %p", g_dev);
|
||||
|
||||
int ret = g_dev->print_info();
|
||||
|
||||
if (ret != 0) {
|
||||
PX4_ERR("Unable to print info");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int trigger(int count)
|
||||
{
|
||||
if (_is_running) {
|
||||
_trigger = count;
|
||||
|
||||
} else {
|
||||
PX4_WARN("bebop_flow is not running");
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
PX4_INFO("Usage: bebop_flow 'start', 'info', 'stop', 'trigger [-n #]'");
|
||||
}
|
||||
|
||||
} /* bebop flow namespace*/
|
||||
|
||||
int
|
||||
bebop_flow_main(int argc, char *argv[])
|
||||
{
|
||||
int ch;
|
||||
int ret = 0;
|
||||
int myoptind = 1;
|
||||
const char *myoptarg = NULL;
|
||||
unsigned int trigger_count = 1;
|
||||
|
||||
/* jump over start/off/etc and look at options first */
|
||||
while ((ch = px4_getopt(argc, argv, "n:", &myoptind, &myoptarg)) != EOF) {
|
||||
switch (ch) {
|
||||
case 'n':
|
||||
trigger_count = atoi(myoptarg);
|
||||
break;
|
||||
|
||||
default:
|
||||
bebop_flow::usage();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc <= 1) {
|
||||
bebop_flow::usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *verb = argv[myoptind];
|
||||
|
||||
if (!strcmp(verb, "start")) {
|
||||
ret = bebop_flow::start();
|
||||
}
|
||||
|
||||
else if (!strcmp(verb, "stop")) {
|
||||
ret = bebop_flow::stop();
|
||||
}
|
||||
|
||||
else if (!strcmp(verb, "info")) {
|
||||
ret = bebop_flow::info();
|
||||
}
|
||||
|
||||
else if (!strcmp(verb, "trigger")) {
|
||||
ret = bebop_flow::trigger(trigger_count);
|
||||
}
|
||||
|
||||
else {
|
||||
bebop_flow::usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "dump_pgm.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <px4_platform_common/posix.h>
|
||||
|
||||
#define HRES_STR "320"
|
||||
#define VRES_STR "240"
|
||||
|
||||
char pgm_header[] = "P5\n#99999999999999 usec \n" HRES_STR " " VRES_STR "\n255\n";
|
||||
char pgm_dumpname[] = "image";
|
||||
char pgm_path[] = "/home/root/images/";
|
||||
|
||||
void dump_pgm(const void *data, uint32_t size, uint32_t seq, uint32_t timestamp)
|
||||
{
|
||||
// Check if dump directory exists
|
||||
struct stat sb = {};
|
||||
|
||||
if (!(stat(pgm_path, &sb) == 0 && S_ISDIR(sb.st_mode))) {
|
||||
PX4_ERR("Dump directory does not exist: %s", pgm_path);
|
||||
PX4_ERR("No images are written!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct the absolute filename
|
||||
char file_path[100] = {0};
|
||||
snprintf(file_path, sizeof(file_path), "%s%s%08u.pgm", pgm_path, pgm_dumpname, seq);
|
||||
PX4_INFO("%s", file_path);
|
||||
|
||||
int fd = open(file_path, O_WRONLY | O_NONBLOCK | O_CREAT, 00666);
|
||||
|
||||
if (fd < 0) {
|
||||
PX4_ERR("Dump: Unable to open file");
|
||||
return;
|
||||
}
|
||||
|
||||
// Write pgm header
|
||||
snprintf(&pgm_header[4], 15, "%014d", (int)timestamp);
|
||||
size_t written = write(fd, pgm_header, sizeof(pgm_header));
|
||||
|
||||
// Write image data
|
||||
size_t total = 0;
|
||||
|
||||
do {
|
||||
written = write(fd, data, size);
|
||||
total += written;
|
||||
} while (total < size);
|
||||
|
||||
PX4_INFO("Wrote %d bytes\n", total);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* @file dump_pgm.h
|
||||
*
|
||||
* This is a simple implementation to write an image into a pgm file.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void dump_pgm(const void *data, uint32_t size, uint32_t seq, uint32_t timestamp);
|
||||
@@ -1,390 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file video_device.cpp
|
||||
*
|
||||
* Wrapper for a V4L2 device using the memory mapped interface.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "video_device.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include <px4_platform_common/posix.h>
|
||||
|
||||
int VideoDevice::start()
|
||||
{
|
||||
int ret = open_device();
|
||||
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = init_device();
|
||||
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return start_capturing();
|
||||
}
|
||||
|
||||
int VideoDevice::stop()
|
||||
{
|
||||
|
||||
int result = stop_capturing();
|
||||
|
||||
if (result < 0) {
|
||||
PX4_ERR("Error stop stream");
|
||||
}
|
||||
|
||||
// Unmap buffers
|
||||
for (unsigned int i = 0; i < _n_buffers; ++i) {
|
||||
result = munmap(_buffers[i].start, _buffers[i].length);
|
||||
|
||||
if (result < 0) {
|
||||
PX4_ERR("Error: Unmapping buffer");
|
||||
}
|
||||
}
|
||||
|
||||
free(_buffers);
|
||||
|
||||
result = close_device();
|
||||
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int VideoDevice::print_info()
|
||||
{
|
||||
PX4_INFO("Device: %s", _dev_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VideoDevice::open_device()
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
// Check if device is usable
|
||||
int ret = stat(_dev_name, &st);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("Cannot identify %s: %d", _dev_name, errno);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (!S_ISCHR(st.st_mode)) {
|
||||
PX4_ERR("%s is no device", _dev_name);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
// Open V4L2 device nonblocking
|
||||
_fd = open(_dev_name, O_RDWR | O_NONBLOCK);
|
||||
|
||||
if (_fd < 0) {
|
||||
PX4_ERR("Unable to open %s", _dev_name);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int VideoDevice::close_device()
|
||||
{
|
||||
int ret = close(_fd);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("Error closing %s", _dev_name);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int VideoDevice::init_device()
|
||||
{
|
||||
struct v4l2_capability cap {};
|
||||
|
||||
int ret = ioctl(_fd, VIDIOC_QUERYCAP, &cap);
|
||||
|
||||
if (ret < 0) {
|
||||
if (EINVAL == errno) {
|
||||
PX4_ERR("No V4L2 device: %s", _dev_name);
|
||||
return -EINVAL;
|
||||
|
||||
} else {
|
||||
PX4_ERR("VIDIOC_QUERYCAP failed: %s", _dev_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
|
||||
PX4_ERR("Device is no video capture device: %s", _dev_name);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
ret = init_crop();
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("Error when setting image crop");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return init_buffers();
|
||||
}
|
||||
|
||||
int VideoDevice::init_crop()
|
||||
{
|
||||
struct v4l2_cropcap cropcap {};
|
||||
struct v4l2_crop crop {};
|
||||
|
||||
cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
int ret = ioctl(_fd, VIDIOC_CROPCAP, &cropcap);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_WARN("CROPCAP failed");
|
||||
}
|
||||
|
||||
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
crop.c = cropcap.defrect; // reset to default
|
||||
ret = ioctl(_fd, VIDIOC_S_CROP, &crop);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_WARN("S_CROP failed");
|
||||
}
|
||||
|
||||
return init_format();
|
||||
}
|
||||
|
||||
int VideoDevice::init_format()
|
||||
{
|
||||
usleep(10000);
|
||||
struct v4l2_format fmt {};
|
||||
|
||||
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
fmt.fmt.pix.width = VIDEO_DEVICE_IMAGE_WIDTH;
|
||||
fmt.fmt.pix.height = VIDEO_DEVICE_IMAGE_HEIGHT;
|
||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_NV12;
|
||||
fmt.fmt.pix.colorspace = V4L2_COLORSPACE_REC709;
|
||||
|
||||
int ret = ioctl(_fd, VIDIOC_S_FMT, &fmt);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("Unable to set format");
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *format_string;
|
||||
|
||||
switch (fmt.fmt.pix.pixelformat) {
|
||||
case V4L2_PIX_FMT_YUYV:
|
||||
format_string = "YUYV";
|
||||
break;
|
||||
|
||||
case V4L2_PIX_FMT_YVYU:
|
||||
format_string = "YVYU";
|
||||
break;
|
||||
|
||||
case V4L2_PIX_FMT_NV12:
|
||||
format_string = "NV12";
|
||||
break;
|
||||
|
||||
default:
|
||||
format_string = "None";
|
||||
}
|
||||
|
||||
PX4_INFO("Set image format: %ux%u\n Format: %s\n Size: %u",
|
||||
fmt.fmt.pix.width,
|
||||
fmt.fmt.pix.height,
|
||||
format_string,
|
||||
fmt.fmt.pix.sizeimage);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int VideoDevice::init_buffers()
|
||||
{
|
||||
struct v4l2_requestbuffers req {};
|
||||
|
||||
req.count = _n_buffers;
|
||||
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
req.memory = V4L2_MEMORY_MMAP;
|
||||
|
||||
int ret = ioctl(_fd, VIDIOC_REQBUFS, &req);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("Unable to request buffers: %s", _dev_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
_buffers = (struct buffer *) malloc(_n_buffers * sizeof(_buffers[0]));
|
||||
|
||||
if (_buffers == nullptr) {
|
||||
PX4_ERR("Unable to allocate buffers");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < _n_buffers; ++i) {
|
||||
struct v4l2_buffer buf {};
|
||||
|
||||
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
buf.memory = V4L2_MEMORY_MMAP;
|
||||
buf.index = i;
|
||||
|
||||
ret = ioctl(_fd, VIDIOC_QUERYBUF, &buf);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("Error QUERYBUF");
|
||||
return -1;
|
||||
}
|
||||
|
||||
_buffers[i].length = buf.length;
|
||||
_buffers[i].start = mmap(nullptr, buf.length, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, _fd, buf.m.offset);
|
||||
|
||||
if (_buffers[i].start == MAP_FAILED) {
|
||||
PX4_ERR("Out of memory");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int VideoDevice::start_capturing()
|
||||
{
|
||||
for (unsigned int i = 0; i < _n_buffers; ++i) {
|
||||
struct v4l2_buffer buf {};
|
||||
|
||||
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
buf.memory = V4L2_MEMORY_MMAP;
|
||||
buf.index = i;
|
||||
|
||||
int ret = ioctl(_fd, VIDIOC_QBUF, &buf);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("Unable to queue buffer: %d", i);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
int ret = ioctl(_fd, VIDIOC_STREAMON, &type);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("Unable to start streaming");
|
||||
return -1;
|
||||
}
|
||||
|
||||
PX4_INFO("Streaming started: %s", _dev_name);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int VideoDevice::stop_capturing()
|
||||
{
|
||||
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
int ret = ioctl(_fd, VIDIOC_STREAMOFF, &type);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("Unable to stop streaming");
|
||||
return -1;
|
||||
}
|
||||
|
||||
PX4_INFO("Streaming stopped: %s", _dev_name);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int VideoDevice::get_frame(struct frame_data &frame)
|
||||
{
|
||||
struct v4l2_buffer buf {};
|
||||
|
||||
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
buf.memory = V4L2_MEMORY_MMAP;
|
||||
|
||||
int ret = ioctl(_fd, VIDIOC_DQBUF, &buf);
|
||||
|
||||
if (ret < 0) {
|
||||
if (errno == EAGAIN) {
|
||||
//PX4_INFO("No frame ready");
|
||||
return 1;
|
||||
|
||||
} else if (errno == EIO) {
|
||||
PX4_INFO("EIO");
|
||||
return 1;
|
||||
|
||||
} else {
|
||||
PX4_ERR("Buffer deque error");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
frame.data = _buffers[buf.index].start;
|
||||
frame.seq = buf.sequence;
|
||||
frame.timestamp = buf.timestamp.tv_sec * 1000000 + buf.timestamp.tv_usec;
|
||||
frame.bytes = buf.bytesused;
|
||||
frame.index = buf.index;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VideoDevice::put_frame(struct frame_data &frame)
|
||||
{
|
||||
struct v4l2_buffer buf {};
|
||||
|
||||
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
buf.memory = V4L2_MEMORY_MMAP;
|
||||
buf.index = frame.index;
|
||||
buf.length = _buffers[frame.index].length;
|
||||
|
||||
int ret = ioctl(_fd, VIDIOC_QBUF, &buf);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("Buffer deque error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define VIDEO_DEVICE_IMAGE_WIDTH 320
|
||||
#define VIDEO_DEVICE_IMAGE_HEIGHT 240
|
||||
|
||||
struct frame_data {
|
||||
uint32_t timestamp;
|
||||
uint32_t seq;
|
||||
uint32_t bytes;
|
||||
uint32_t index;
|
||||
void *data;
|
||||
};
|
||||
|
||||
struct buffer {
|
||||
void *start;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
class VideoDevice
|
||||
{
|
||||
public:
|
||||
VideoDevice(char const *dev_name, uint32_t n_buffers) :
|
||||
_fd(-1), _dev_name(dev_name), _n_buffers(n_buffers), _buffers(nullptr) {}
|
||||
|
||||
~VideoDevice() = default;
|
||||
|
||||
/// Start the device
|
||||
int start();
|
||||
|
||||
/// Stop the device
|
||||
int stop();
|
||||
|
||||
/// Print various infos
|
||||
int print_info();
|
||||
|
||||
/// Non-blocking call to fetch an image. Returns 0 if the images was read, -1 on error
|
||||
/// and 1 no new image is ready.
|
||||
int get_frame(struct frame_data &frame);
|
||||
|
||||
/// Return a frame when the data is not needed any more.
|
||||
int put_frame(struct frame_data &frame);
|
||||
|
||||
private:
|
||||
int _fd;
|
||||
const char *_dev_name;
|
||||
uint32_t _n_buffers;
|
||||
struct buffer *_buffers;
|
||||
|
||||
int open_device();
|
||||
int close_device();
|
||||
int init_device();
|
||||
int init_buffers();
|
||||
int init_crop();
|
||||
int init_format();
|
||||
int start_capturing();
|
||||
int stop_capturing();
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$#" < 2 ]]; then
|
||||
echo "usage: adb_upload.sh SRC1 [SRC2 ...] DEST"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Get last argument
|
||||
for last; do true; done
|
||||
|
||||
echo "Wait for device..."
|
||||
adb wait-for-device
|
||||
|
||||
echo "Creating folder structure..."
|
||||
adb shell mkdir -p $last
|
||||
|
||||
echo "Uploading..."
|
||||
# Go through source files and push them one by one.
|
||||
i=0
|
||||
for arg
|
||||
do
|
||||
if [[ $((i+1)) == "$#" ]]; then
|
||||
break
|
||||
fi
|
||||
echo "Pushing $arg to $last"
|
||||
adb push $arg $last
|
||||
((i+=1))
|
||||
done
|
||||
|
||||
# Make sure they are synced to the file system
|
||||
echo "Syncing FS..."
|
||||
adb shell sync
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SRC_DIR="$BASEDIR/../../../../"
|
||||
|
||||
if [ -z ${BEBOP_IP+x} ]; then
|
||||
ip=192.168.42.1
|
||||
echo "\$BEBOP_IP is not set (use default: $ip)"
|
||||
else
|
||||
ip=$BEBOP_IP
|
||||
echo "\$BEBOP_IP is set to $ip"
|
||||
fi
|
||||
port=9050
|
||||
|
||||
echo "Connecting to bebop: $ip:$port"
|
||||
|
||||
# adb returns also 0 as exit status if the connection fails
|
||||
adb_return=$(adb connect $ip:$port)
|
||||
adb_status=$(echo $adb_return | cut -f 1 -d " ")
|
||||
|
||||
if [[ $adb_status == "unable" ]]; then
|
||||
|
||||
echo ""
|
||||
echo "Connection with Parrot Bebop could not be established:"
|
||||
echo " Make sure you are connected with the Bebop's WiFi and"
|
||||
echo " enable access to the board by pressing the power button 4 times."
|
||||
echo ""
|
||||
exit 50
|
||||
|
||||
fi
|
||||
|
||||
echo "Connection successfully established"
|
||||
|
||||
sleep 1
|
||||
|
||||
adb shell mount -o remount,rw /
|
||||
adb shell touch /home/root/parameters
|
||||
adb shell mkdir -p /data/ftp/internal_000/fs/microsd
|
||||
|
||||
# kill PX4 if it is already running from autostart
|
||||
restart_px4=false
|
||||
adb_return=$(adb shell killall -KILL px4)
|
||||
if [[ $adb_return == "" ]]; then
|
||||
echo "Killed running PX4 process"
|
||||
restart_px4=true
|
||||
fi
|
||||
|
||||
# upload PX4
|
||||
$BASEDIR/adb_upload.sh $@
|
||||
|
||||
# upload mixer and config files
|
||||
echo "Uploading mixer and config files to /home/root"
|
||||
adb push $SRC_DIR/ROMFS/px4fmu_common/mixers/bebop.main.mix /home/root
|
||||
adb push $SRC_DIR/posix-configs/bebop/px4.config /home/root
|
||||
|
||||
# restart the process after uploading
|
||||
if [ "$restart_px4" = true ]; then
|
||||
echo "Restarting PX4 process"
|
||||
adb shell /etc/init.d/rcS_mode_default 2>/dev/null 1>/dev/null &
|
||||
fi
|
||||
|
||||
# make sure all buffered blocks are written to disk
|
||||
echo "Syncing FS..."
|
||||
adb shell sync
|
||||
|
||||
echo "Disconnecting from Bebop"
|
||||
adb disconnect
|
||||
|
||||
echo ""
|
||||
echo "To start PX4, run the following command on the Bebop:"
|
||||
echo "/data/ftp/internal_000/px4/px4 -s /home/root/px4.config /data/ftp/internal_000/px4/"
|
||||
@@ -1,36 +0,0 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2017 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
add_library(drivers_board
|
||||
empty.c
|
||||
)
|
||||
@@ -1,57 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file board_config.h
|
||||
*
|
||||
* BEBOP internal definitions
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define BOARD_OVERRIDE_UUID "BEBOPID000000000" // must be of length 16
|
||||
#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_BEBOP
|
||||
|
||||
#define BOARD_HAS_NO_RESET
|
||||
#define BOARD_HAS_NO_BOOTLOADER
|
||||
|
||||
#define BOARD_NUMBER_BRICKS 0
|
||||
|
||||
/*
|
||||
* I2C busses
|
||||
*/
|
||||
#define PX4_I2C_BUS_EXPANSION 1
|
||||
#define PX4_NUMBER_I2C_BUSES 1
|
||||
|
||||
#include <system_config.h>
|
||||
#include <px4_platform_common/board_common.h>
|
||||
Reference in New Issue
Block a user