Compare commits

...

90 Commits

Author SHA1 Message Date
Alexey Rogachevskiy
1447e73fed aruco_pose, clever: Minor cleanups 2019-12-24 19:52:41 +03:00
Alexey Rogachevskiy
75278552b3 builder: Use buster distribution for clever repository 2019-12-24 13:34:36 +03:00
Oleg Kalachev
320f7a43ce docs: fix raspistill example 2019-12-23 18:11:11 +03:00
Alexey Rogachevskiy
26e9ab0c7f docs: Add porting guide for Jetson Nano (#198)
* docs: Add porting guide for Jetson Nano (en)

* docs/jetson_nano: Add missing Jetson Nano image

* docs/jetson_nano: More explicit initial setup

* docs/jetson_nano: imx219 -> IMX219

* docs/jetson_nano: Make lack of LED strip support more clear

* docs: Add porting guide for Jetson Nano (ru)
2019-12-19 18:07:48 +03:00
Alexey Rogachevskiy
fb0e841bd4 clever/rc: Allow disabling GCS thread (#197)
* clever/rc: Allow disabling GCS thread

Currently spawning GCS thread results in ROS TCP errors. This patch allows a user to turn off this thread if it's not required.

The thread is turned off by default, since it's not required for our PX4 firmware.

* clever/rc: Code style
2019-12-16 20:37:11 +03:00
Alexey Rogachevskiy
361b365f86 clever: Use explicit camera device path
This fixes issues with spurious OpenCV/GStreamer errors.
2019-12-16 17:30:31 +03:00
Alexey Rogachevskiy
9487966b57 network: Allow WPA (non-WPA2) clients to connect
This allows Windows clients to connect to our image. Looks like WPA2 is broken for now (not sure on which side), so this is more of a workaround.
2019-12-16 16:13:45 +03:00
Alexey Rogachevskiy
a75a0e12a0 docs: Fix file paths in aruco articles (en) 2019-12-12 20:10:55 +03:00
Alexey Rogachevskiy
aa835fcdff docs: Add note about camera screws (en/ru) 2019-12-10 13:46:21 +03:00
Oleg Kalachev
7fcbe95a80 docs: fix links 2019-12-10 06:25:05 +03:00
Alexey Rogachevskiy
9f097f56c5 image: Install python3-opencv 2019-12-09 20:13:04 +03:00
Alexey Rogachevskiy
0fb22e817d rsyslog: Don't try to set rate limits
The way this was implemented didn't work anyway and produced spurious errors, we can probably live without that for now.
2019-12-09 19:50:03 +03:00
Oleg Kalachev
b8a8e7339d docs: fix typo 2019-12-08 23:52:36 +03:00
Alexey Rogachevskiy
e1ab0e63b5 Limit syslog size (#195)
* builder: Put file size limits in rsyslog.conf

* rsyslog: Add simple log rotation script

* rsyslog: Add rate limiting
2019-12-06 21:29:52 +03:00
Alexey Rogachevskiy
4a23a9274a Move to Raspbian Buster (#193)
* builder: Build against Buster

* builder: Use correct repository specifications

* builder: Move ld.so.preload to have less errors

* builder: Use coex repo to install Monkey

* builder: Search for buster ROS packages

* aruco_pose: Vendor in aruco library from OpenCV 3.4.6

* builder: Move to ROS Melodic

* builder: Update kernel version

* aruco_pose, clever: Remove opencv3 ROS dependency

* builder: Update rosdep

* travis: Disable eclint for vendored aruco library

* tests: Don't try to locate opencv in ros

* roscore: Use melodic distribution

* Revert "aruco_pose: Vendor in aruco library from OpenCV 3.4.6"

This reverts commit 9c14a8c002bb3396f9a7d9b2ba39969207f066ba.

* aruco_pose: Vendor opencv_contrib/aruco again

* builder: Add led packages

* builder: Remove unused builder code

* travis: Add native tests

* builder: Set permissions for standalone-install

* builder: Use -y for package installation

* builder: Add repo for standalone build

* builder: Use correct file types for standalone install

* aruco_pose: Accept rgb8 map images

* builder: Disable mjpg_streamer test

* aruco_pose: Allow rgb8 map images (again)

* builder: Re-add mjpgstreamer

* builder: Install tornado==4.2.1 for rosbridge_suite

* builder: Use more recent base image

* builder: Use default kernel

* builder: Move ld.so.preload back after tests

* builder: Disable catkin tests

These tests fail on a remote machine but seem to pass just fine on real hardware. Something must have changed between Kinetic and Melodic, and we must investigate more, but for now we just need a working image.

* aruco_pose: Remove unused vendored code

* selfcheck: Update systemd-analyze regex

* builder: Add opencv repository

* rosdep: Update package definitions for Melodic

* rosdep: Use proper yaml formatting

* travis: Remove unnecessary space

* docs: Reference Melodic wherever possible
2019-12-06 21:25:19 +03:00
Oleg Kalachev
5bc7443a7b Adjust default vl53l1x rangefinder parameters 2019-12-06 20:40:47 +03:00
Oleg Kalachev
5fe18152f0 selfcheck.py: fix letters case 2019-12-06 01:14:17 +03:00
Oleg Kalachev
b8d4a7fdcc selfcheck.py: don’t fall with exception if cell voltage array is empty 2019-12-06 01:11:48 +03:00
timkondratiev
c3a4f674ec docs: fix tf2 code snippet (#194)
* fix transform code

* fix transform code

* docs: import PoseStamped directly from geometry_msgs
2019-12-03 01:19:50 +03:00
Oleg Kalachev
591d57e2b2 selfcheck.py: correct case 2019-11-26 19:30:23 +03:00
Alexey Rogachevskiy
4a67783706 selfcheck.py: add hardware health checks (#192)
* selfcheck: Add hardware health checks

* docs: Update selfcheck documentation (en/ru)

* selfcheck: "Hardware health" -> "RPi health"
2019-11-25 20:51:27 +03:00
Alexey Rogachevskiy
7dc82e8154 docs: English translation updates (#190)
* docs: Add CLI article (en)

* docs: Update frames article (en)

* docs: Add article about part models (en)

* docs: Update Raspberry Pi article (en)

* docs: Remove unused raspberry3.jpg

* docs: Add COEX Pix article (en)

* docs: Add CopterHack 2019 article (en)

* docs: Update connection article (en)

* docs: Add programming overview (en)

* docs: Add anchor in modes article

* docs: Fix link in auto_setup, add editing ID (en)

* docs: Rearrange summary to match Russian version (en)

* docs/camera_frame: Add link to cli#editing (en)

* docs/wifi: Fix link to next article (en)

* docs: Add "next" links where appropriate (en)
2019-11-25 20:22:41 +03:00
Alexey Rogachevskiy
4feac879eb docs: Fix incorrect path and link 2019-11-25 18:40:18 +03:00
Alamoris
6c883cab67 builder: Fix typo 2019-11-23 16:26:28 +03:00
Oleg Kalachev
00048d4dfe ci: ignore .dxf-files in editorconfig-checker 2019-11-23 14:17:54 +03:00
Alamoris
a635b9d21d builder: Ignore app and clever/www directory by catkin 2019-11-22 14:48:59 +03:00
Oleg Kalachev
de693e3e58 docs: fix 2019-11-21 17:15:12 +03:00
Oleg Kalachev
9e2707ad6b docs: fix 2019-11-21 16:54:14 +03:00
Oleg Kalachev
a7e04fe22a docs: fix 2019-11-21 16:44:41 +03:00
Oleg Kalachev
3647337455 docs: fix 2019-11-21 16:42:23 +03:00
Oleg Kalachev
b771fbb398 docs: add dxf files files 2019-11-21 16:33:05 +03:00
Oleg Kalachev
7ed2dd398c docs: fix link 2019-11-21 16:32:05 +03:00
Oleg Kalachev
45e6f396d0 image: remove after=network.target from service files to speed up booting 2019-11-20 17:31:05 +03:00
Oleg Kalachev
0574f4cc46 selfcheck.py: add network check 2019-11-15 09:58:36 +03:00
Oleg Kalachev
f574637a3f gitbook: add redirect from hostname/ 2019-11-15 09:45:57 +03:00
Oleg Kalachev
6ede041c8a docs: little fix 2019-11-14 21:30:40 +03:00
Oleg Kalachev
0fda24c63c docs: add programming intro and re-arrange articles in programming section 2019-11-14 21:13:27 +03:00
Oleg Kalachev
a01c2b8d6c docs: add next links 2019-11-14 21:11:25 +03:00
Oleg Kalachev
5ce348d14c docs: id for editing section in cli article 2019-11-14 21:09:34 +03:00
Oleg Kalachev
5736c7acfb docs: fix editing links 2019-11-14 21:06:50 +03:00
Oleg Kalachev
c6b3e837e3 docs: fix next link in wifi article 2019-11-14 21:05:06 +03:00
Oleg Kalachev
78e42df0f2 docs: id for auto mode in modes article 2019-11-14 21:04:52 +03:00
Oleg Kalachev
a8824a696d docs: rework connection article 2019-11-14 21:04:36 +03:00
Oleg Kalachev
7a216ede07 docs: update raspberry article 2019-11-14 20:48:56 +03:00
Oleg Kalachev
b68e42bfcc docs: replace editing article with cli article 2019-11-14 19:30:54 +03:00
Oleg Kalachev
fdeab48bf5 docs: add aruco-related frames to frames article 2019-11-14 17:55:20 +03:00
Oleg Kalachev
5c1b19d9c9 docs: fix set_velocity call 2019-11-14 15:47:52 +03:00
Oleg Kalachev
7d25898694 led: don’t indicate low voltage lower than 2.0 2019-11-13 19:27:13 +03:00
Oleg Kalachev
2c6780202a Disable led for sitl 2019-11-12 00:15:51 +03:00
Alexey Rogachevskiy
cab76dea16 Assembly images updates (#188)
* docs: Update LED connection images

* docs: Add motor direction and USB connection

* docs: Crop props_rotation.png

* docs: Add RPi microSD installation (en/ru)

* docs: Add note about FCU microSD (en/ru)
2019-11-11 15:14:09 +03:00
Oleg Kalachev
0e0b0aa90b docs: update models article 2019-11-08 00:20:06 +03:00
Oleg Kalachev
e85be7ae49 Merge pull request #189 from Alamoris/change_led_state 2019-11-07 23:36:24 +03:00
Oleg Kalachev
bb99d68ff4 led: decrease default brightness to 64 2019-11-07 23:34:39 +03:00
Oleg Kalachev
ae077304bb docs: restored link to 3d-scanner article 2019-11-07 21:14:03 +03:00
Alamoris
0baadf73a2 launch: change defaul led node status 2019-11-07 12:48:27 +03:00
Oleg Kalachev
f0917347be docs: replace link to battery_holder.stl 2019-11-07 05:32:19 +03:00
Oleg Kalachev
eba8c7fc6a docs: add stl-models page link to summary 2019-11-07 05:01:12 +03:00
Oleg Kalachev
36573c12ee ci: ignore .stl-files in editoconfig-checker 2019-11-07 04:59:25 +03:00
Oleg Kalachev
e293e54353 docs: ignore battery_holder size 2019-11-07 04:46:11 +03:00
Oleg Kalachev
35801346d9 docs: add page for STL-models, add battery holder model 2019-11-07 04:41:46 +03:00
Oleg Kalachev
660b90a353 docs: remove link to unexisting arucogenmap article 2019-11-07 01:00:31 +03:00
Oleg Kalachev
f88d9eea2e mavros.launch: add fcu_conn option for sitl since PX4 1.9.0 2019-11-06 22:54:38 +03:00
Oleg Kalachev
5ab5418866 docs: remove english textbook from summary 2019-10-31 01:07:34 +03:00
timkondratiev
910e3590b3 docs: update article name (#187) 2019-10-30 18:08:52 +03:00
Alexey Rogachevskiy
5ad08785c4 docs: translation updates (#186)
* docs: Update frames article (en)

* docs: Add navigate_target notes to simple_offboard (en)

* docs: Update note about single-marker navigation

* docs: Add note about auto parameters in PX4 (en)
2019-10-29 23:40:30 +03:00
Oleg Kalachev
b75a40b9ad image: make documentation files ignored by catkin for speeding up roslaunch (#184) 2019-10-29 23:05:45 +03:00
Oleg Kalachev
7bbbba31be docs: fix typos 2019-10-29 21:32:56 +03:00
Oleg Kalachev
241264a1d2 docs: fix link 2019-10-27 18:13:09 +03:00
Oleg Kalachev
5c78b01b7b gitbook: switch to last markdownlint-cli as the issue is fixed 2019-10-27 18:05:12 +03:00
Ilya Petrov
dab4e69be1 docs: little description mistake fix (#185) 2019-10-25 15:34:47 +03:00
Oleg Kalachev
753e0a8ab4 selfcheck.py: report magnetometer weight parameter 2019-10-25 02:59:08 +03:00
stinger000
112c51a2b9 docs: update coex_pix.md (#183) 2019-10-25 01:02:27 +03:00
Oleg Kalachev
9c6cb4cc38 docs: small fix 2019-10-23 01:13:04 +03:00
Oleg Kalachev
b337dfa4c3 docs: small fix 2019-10-23 01:06:01 +03:00
Oleg Kalachev
22607c5390 docs: add COEX Pix article to summary 2019-10-23 01:03:34 +03:00
Oleg Kalachev
0f837d96a6 docs: small fix in COEX Pix article 2019-10-23 00:57:16 +03:00
Oleg Kalachev
3fa5ee99c4 docs: add COEX Pix article 2019-10-23 00:52:21 +03:00
Oleg Kalachev
8749f1523e gitbook: revert to markdownlint-cli@0.18.0 as the latest version has false positives on MD044 2019-10-22 01:47:26 +03:00
Oleg Kalachev
8b3a9dc07a docs: fix navigate examples in aruco maps navigating 2019-10-21 23:44:08 +03:00
Oleg Kalachev
a9b3613726 docs: add winners to copter hack 2019 2019-10-15 17:59:31 +03:00
Oleg Kalachev
3530c9999e docs: add info on bugs to copter hack 2019 pag 2019-10-13 15:04:09 +03:00
Alexey Rogachevskiy
244005c9f7 docs: Fix XML in camera.md 2019-10-12 22:05:10 +03:00
Oleg Kalachev
761ab42a63 docs: update copter hack 2019 article 2019-10-12 17:56:03 +03:00
Oleg Kalachev
86feac089a docs: update copter hack 2019 article 2019-10-12 17:53:38 +03:00
Oleg Kalachev
13a5a0ea05 docs: update optical flow article 2019-10-12 16:54:38 +03:00
Oleg Kalachev
dfefad297c docs: update copter hack 2019 2019-10-12 16:51:46 +03:00
Oleg Kalachev
cb9924d083 docs: add note about flying to marker in markers map 2019-10-12 14:55:52 +03:00
Oleg Kalachev
13599a1b2e docs: note about autmatic parameters for flow in clever PX4 2019-10-12 14:49:11 +03:00
Oleg Kalachev
a46a96f729 docs: add notes about navigate_target frame 2019-10-12 14:26:47 +03:00
Arthur Golubtsov
b7a811d4d4 Add information about image versions 2019-10-12 10:04:38 +03:00
135 changed files with 190928 additions and 601 deletions

1
.gitattributes vendored
View File

@@ -3,3 +3,4 @@ roslib.js linguist-vendored
eventemitter2.js linguist-vendored
ros3d.js linguist-vendored
three.min.js linguist-vendored
aruco_pose/vendor/* linguist-vendored

View File

@@ -20,6 +20,7 @@
"MAVLink",
"ROS",
"ROS Kinetic",
"ROS Melodic",
"OpenCV",
"Gazebo",
"GitHub",
@@ -104,7 +105,8 @@
"TCP",
"UDP",
"QR",
"Li-ion"
"Li-ion",
"Nvidia"
],
"code_blocks": false
},

View File

@@ -50,6 +50,22 @@ jobs:
tags: true
draft: true
name: ${TRAVIS_TAG}
- stage: Build
name: "Native Kinetic build"
env:
- NATIVE_DOCKER=ros:kinetic-ros-base
before_script:
- docker pull ${NATIVE_DOCKER}
script:
- docker run --rm -v $(pwd):/root/catkin_ws/src/clever ${NATIVE_DOCKER} /root/catkin_ws/src/clever/builder/standalone-install.sh
- stage: Build
name: "Native Melodic build"
env:
- NATIVE_DOCKER=ros:melodic-ros-base
before_script:
- docker pull ${NATIVE_DOCKER}
script:
- docker run --rm -v $(pwd):/root/catkin_ws/src/clever ${NATIVE_DOCKER} /root/catkin_ws/src/clever/builder/standalone-install.sh
- stage: Build
name: "Documentation"
language: node_js
@@ -93,7 +109,7 @@ jobs:
- wget https://github.com/okalachev/editorconfig-checker/releases/download/1.2.1-disable-spaces-amount/ec-linux-amd64
- chmod +x ec-linux-amd64
script:
- ./ec-linux-amd64 -spaces-after-tabs -e "roslib.js|ros3d.js|eventemitter2.js|draw.cpp|BinUtils.swift|\.idea|apps/android/app|Assets.xcassets|test_parser_pass.txt|test_node_failure.txt"
- ./ec-linux-amd64 -spaces-after-tabs -e "roslib.js|ros3d.js|eventemitter2.js|draw.cpp|BinUtils.swift|\.idea|apps/android/app|Assets.xcassets|test_parser_pass.txt|test_node_failure.txt|aruco_pose/vendor|\.stl|\.dxf"
stages:
- Build
- Annotate

View File

@@ -18,8 +18,8 @@ Use it to learn how to assemble, configure, pilot and program autonomous CLEVER
Image includes:
* Raspbian Stretch
* ROS Kinetic
* Raspbian Buster
* ROS Melodic
* Configured networking
* OpenCV
* mavros
@@ -30,7 +30,7 @@ API description (in Russian) for autonomous flights is available [on GitBook](ht
## Manual installation
Install ROS Kinetic according to the [documentation](http://wiki.ros.org/kinetic/Installation), then [create a Catkin workspace](http://wiki.ros.org/catkin/Tutorials/create_a_workspace).
Install ROS Melodic according to the [documentation](http://wiki.ros.org/melodic/Installation), then [create a Catkin workspace](http://wiki.ros.org/catkin/Tutorials/create_a_workspace).
Clone this repo to directory `~/catkin_ws/src/clever`:

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.0)
project(aruco_pose)
add_definitions(-std=c++11 -Wall -g)
@@ -23,7 +23,16 @@ find_package(catkin REQUIRED COMPONENTS
message_generation
)
find_package(OpenCV 3 REQUIRED)
find_package(OpenCV 3 REQUIRED COMPONENTS core imgproc calib3d)
if ("${OpenCV_VERSION_MINOR}" LESS "3")
message(STATUS "OpenCV version too low, using vendored ArUco package")
include(vendor/VendorOpenCV.cmake)
else()
message(STATUS "Using system OpenCV ArUco package")
find_package(OpenCV 3 REQUIRED COMPONENTS aruco)
endif()
message(STATUS "OpenCV include dirs: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "OpenCV libraries: ${OpenCV_LIBRARIES}")
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)

View File

@@ -18,7 +18,6 @@
<depend>tf2</depend>
<depend>tf2_ros</depend>
<depend>tf2_geometry_msgs</depend>
<depend>opencv3</depend>
<depend>cv_bridge</depend>
<depend>image_transport</depend>
<depend>message_generation</depend>

33
aruco_pose/vendor/VendorOpenCV.cmake vendored Normal file
View File

@@ -0,0 +1,33 @@
# There should be a better way to add ArUco libraries,
# but I have not found it yet.
# -- sfalexrog, 2019.09.11
if (NOT OpenCV_LIBRARIES OR NOT OpenCV_INCLUDE_DIRS)
message(FATAL_ERROR "OpenCV was not found - cannot continue")
endif()
message(STATUS "Adding vendored aruco_pose OpenCV module")
add_library(_opencv_aruco STATIC
vendor/aruco/src/aruco.cpp
vendor/aruco/src/charuco.cpp
vendor/aruco/src/dictionary.cpp
vendor/aruco/src/zmaxheap.cpp
)
target_include_directories(_opencv_aruco PRIVATE
${OpenCV_INCLUDE_DIRS}
)
target_link_libraries(_opencv_aruco PRIVATE
${OpenCV_LIBRARIES}
)
target_compile_definitions(_opencv_aruco PRIVATE
CV_OVERRIDE=override
)
target_compile_options(_opencv_aruco PRIVATE
-fpic -fPIC
)
target_include_directories(_opencv_aruco PUBLIC
vendor/aruco/include
)
set(OpenCV_LIBRARIES "_opencv_aruco;${OpenCV_LIBRARIES}")

View File

@@ -0,0 +1,2 @@
set(the_description "ArUco Marker Detection")
ocv_define_module(aruco opencv_core opencv_imgproc opencv_calib3d WRAP python java)

12
aruco_pose/vendor/aruco/README.md vendored Normal file
View File

@@ -0,0 +1,12 @@
ArUco Marker Detection
======================
**ArUco**
ArUco markers are easy to detect pattern grids that yield up to 1024 different patterns. They were built for augmented reality and later used for camera calibration. Since the grid uniquely orients the square, the detection algorithm can determing the pose of the grid.
**ChArUco**
ArUco markers were improved by interspersing them inside a checkerboard called ChArUco. Checkerboard corner intersectionsa provide more stable corners because the edge location bias on one square is countered by the opposite edge orientation in the connecting square. By interspersing ArUco markers inside the checkerboard, each checkerboard corner gets a label which enables it to be used in complex calibration or pose scenarios where you cannot see all the corners of the checkerboard.
The smallest ChArUco board is 5 checkers and 4 markers called a "Diamond Marker".

View File

@@ -0,0 +1,604 @@
/*
By downloading, copying, installing or using the software you agree to this
license. If you do not agree to this license, do not download, install,
copy or use the software.
License Agreement
For Open Source Computer Vision Library
(3-clause BSD License)
Copyright (C) 2013, OpenCV Foundation, all rights reserved.
Third party copyrights are property of their respective owners.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the names of the copyright holders nor the names of the 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 copyright holders 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.
*/
#ifndef __OPENCV_ARUCO_HPP__
#define __OPENCV_ARUCO_HPP__
#include <opencv2/core.hpp>
#include <vector>
#include "opencv2/aruco/dictionary.hpp"
/**
* @defgroup aruco ArUco Marker Detection
* This module is dedicated to square fiducial markers (also known as Augmented Reality Markers)
* These markers are useful for easy, fast and robust camera pose estimation.ç
*
* The main functionalities are:
* - Detection of markers in an image
* - Pose estimation from a single marker or from a board/set of markers
* - Detection of ChArUco board for high subpixel accuracy
* - Camera calibration from both, ArUco boards and ChArUco boards.
* - Detection of ChArUco diamond markers
* The samples directory includes easy examples of how to use the module.
*
* The implementation is based on the ArUco Library by R. Muñoz-Salinas and S. Garrido-Jurado @cite Aruco2014.
*
* Markers can also be detected based on the AprilTag 2 @cite wang2016iros fiducial detection method.
*
* @sa S. Garrido-Jurado, R. Muñoz-Salinas, F. J. Madrid-Cuevas, and M. J. Marín-Jiménez. 2014.
* "Automatic generation and detection of highly reliable fiducial markers under occlusion".
* Pattern Recogn. 47, 6 (June 2014), 2280-2292. DOI=10.1016/j.patcog.2014.01.005
*
* @sa http://www.uco.es/investiga/grupos/ava/node/26
*
* This module has been originally developed by Sergio Garrido-Jurado as a project
* for Google Summer of Code 2015 (GSoC 15).
*
*
*/
namespace cv {
namespace aruco {
//! @addtogroup aruco
//! @{
enum CornerRefineMethod{
CORNER_REFINE_NONE, ///< Tag and corners detection based on the ArUco approach
CORNER_REFINE_SUBPIX, ///< ArUco approach and refine the corners locations using corner subpixel accuracy
CORNER_REFINE_CONTOUR, ///< ArUco approach and refine the corners locations using the contour-points line fitting
CORNER_REFINE_APRILTAG, ///< Tag and corners detection based on the AprilTag 2 approach @cite wang2016iros
};
/**
* @brief Parameters for the detectMarker process:
* - adaptiveThreshWinSizeMin: minimum window size for adaptive thresholding before finding
* contours (default 3).
* - adaptiveThreshWinSizeMax: maximum window size for adaptive thresholding before finding
* contours (default 23).
* - adaptiveThreshWinSizeStep: increments from adaptiveThreshWinSizeMin to adaptiveThreshWinSizeMax
* during the thresholding (default 10).
* - adaptiveThreshConstant: constant for adaptive thresholding before finding contours (default 7)
* - minMarkerPerimeterRate: determine minimum perimeter for marker contour to be detected. This
* is defined as a rate respect to the maximum dimension of the input image (default 0.03).
* - maxMarkerPerimeterRate: determine maximum perimeter for marker contour to be detected. This
* is defined as a rate respect to the maximum dimension of the input image (default 4.0).
* - polygonalApproxAccuracyRate: minimum accuracy during the polygonal approximation process to
* determine which contours are squares.
* - minCornerDistanceRate: minimum distance between corners for detected markers relative to its
* perimeter (default 0.05)
* - minDistanceToBorder: minimum distance of any corner to the image border for detected markers
* (in pixels) (default 3)
* - minMarkerDistanceRate: minimum mean distance beetween two marker corners to be considered
* similar, so that the smaller one is removed. The rate is relative to the smaller perimeter
* of the two markers (default 0.05).
* - cornerRefinementMethod: corner refinement method. (CORNER_REFINE_NONE, no refinement.
* CORNER_REFINE_SUBPIX, do subpixel refinement. CORNER_REFINE_CONTOUR use contour-Points,
* CORNER_REFINE_APRILTAG use the AprilTag2 approach)
* - cornerRefinementWinSize: window size for the corner refinement process (in pixels) (default 5).
* - cornerRefinementMaxIterations: maximum number of iterations for stop criteria of the corner
* refinement process (default 30).
* - cornerRefinementMinAccuracy: minimum error for the stop cristeria of the corner refinement
* process (default: 0.1)
* - markerBorderBits: number of bits of the marker border, i.e. marker border width (default 1).
* - perspectiveRemovePixelPerCell: number of bits (per dimension) for each cell of the marker
* when removing the perspective (default 8).
* - perspectiveRemoveIgnoredMarginPerCell: width of the margin of pixels on each cell not
* considered for the determination of the cell bit. Represents the rate respect to the total
* size of the cell, i.e. perspectiveRemovePixelPerCell (default 0.13)
* - maxErroneousBitsInBorderRate: maximum number of accepted erroneous bits in the border (i.e.
* number of allowed white bits in the border). Represented as a rate respect to the total
* number of bits per marker (default 0.35).
* - minOtsuStdDev: minimun standard deviation in pixels values during the decodification step to
* apply Otsu thresholding (otherwise, all the bits are set to 0 or 1 depending on mean higher
* than 128 or not) (default 5.0)
* - errorCorrectionRate error correction rate respect to the maximun error correction capability
* for each dictionary. (default 0.6).
* - aprilTagMinClusterPixels: reject quads containing too few pixels.
* - aprilTagMaxNmaxima: how many corner candidates to consider when segmenting a group of pixels into a quad.
* - aprilTagCriticalRad: Reject quads where pairs of edges have angles that are close to straight or close to
* 180 degrees. Zero means that no quads are rejected. (In radians).
* - aprilTagMaxLineFitMse: When fitting lines to the contours, what is the maximum mean squared error
* allowed? This is useful in rejecting contours that are far from being quad shaped; rejecting
* these quads "early" saves expensive decoding processing.
* - aprilTagMinWhiteBlackDiff: When we build our model of black & white pixels, we add an extra check that
* the white model must be (overall) brighter than the black model. How much brighter? (in pixel values, [0,255]).
* - aprilTagDeglitch: should the thresholded image be deglitched? Only useful for very noisy images
* - aprilTagQuadDecimate: Detection of quads can be done on a lower-resolution image, improving speed at a
* cost of pose accuracy and a slight decrease in detection rate. Decoding the binary payload is still
* done at full resolution.
* - aprilTagQuadSigma: What Gaussian blur should be applied to the segmented image (used for quad detection?)
* Parameter is the standard deviation in pixels. Very noisy images benefit from non-zero values (e.g. 0.8).
* - detectInvertedMarker: to check if there is a white marker. In order to generate a "white" marker just
* invert a normal marker by using a tilde, ~markerImage. (default false)
*/
struct CV_EXPORTS_W DetectorParameters {
DetectorParameters();
CV_WRAP static Ptr<DetectorParameters> create();
CV_PROP_RW int adaptiveThreshWinSizeMin;
CV_PROP_RW int adaptiveThreshWinSizeMax;
CV_PROP_RW int adaptiveThreshWinSizeStep;
CV_PROP_RW double adaptiveThreshConstant;
CV_PROP_RW double minMarkerPerimeterRate;
CV_PROP_RW double maxMarkerPerimeterRate;
CV_PROP_RW double polygonalApproxAccuracyRate;
CV_PROP_RW double minCornerDistanceRate;
CV_PROP_RW int minDistanceToBorder;
CV_PROP_RW double minMarkerDistanceRate;
CV_PROP_RW int cornerRefinementMethod;
CV_PROP_RW int cornerRefinementWinSize;
CV_PROP_RW int cornerRefinementMaxIterations;
CV_PROP_RW double cornerRefinementMinAccuracy;
CV_PROP_RW int markerBorderBits;
CV_PROP_RW int perspectiveRemovePixelPerCell;
CV_PROP_RW double perspectiveRemoveIgnoredMarginPerCell;
CV_PROP_RW double maxErroneousBitsInBorderRate;
CV_PROP_RW double minOtsuStdDev;
CV_PROP_RW double errorCorrectionRate;
// April :: User-configurable parameters.
CV_PROP_RW float aprilTagQuadDecimate;
CV_PROP_RW float aprilTagQuadSigma;
// April :: Internal variables
CV_PROP_RW int aprilTagMinClusterPixels;
CV_PROP_RW int aprilTagMaxNmaxima;
CV_PROP_RW float aprilTagCriticalRad;
CV_PROP_RW float aprilTagMaxLineFitMse;
CV_PROP_RW int aprilTagMinWhiteBlackDiff;
CV_PROP_RW int aprilTagDeglitch;
// to detect white (inverted) markers
CV_PROP_RW bool detectInvertedMarker;
};
/**
* @brief Basic marker detection
*
* @param image input image
* @param dictionary indicates the type of markers that will be searched
* @param corners vector of detected marker corners. For each marker, its four corners
* are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
* the dimensions of this array is Nx4. The order of the corners is clockwise.
* @param ids vector of identifiers of the detected markers. The identifier is of type int
* (e.g. std::vector<int>). For N detected markers, the size of ids is also N.
* The identifiers have the same order than the markers in the imgPoints array.
* @param parameters marker detection parameters
* @param rejectedImgPoints contains the imgPoints of those squares whose inner code has not a
* correct codification. Useful for debugging purposes.
* @param cameraMatrix optional input 3x3 floating-point camera matrix
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
* @param distCoeff optional vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
*
* Performs marker detection in the input image. Only markers included in the specific dictionary
* are searched. For each detected marker, it returns the 2D position of its corner in the image
* and its corresponding identifier.
* Note that this function does not perform pose estimation.
* @sa estimatePoseSingleMarkers, estimatePoseBoard
*
*/
CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr<Dictionary> &dictionary, OutputArrayOfArrays corners,
OutputArray ids, const Ptr<DetectorParameters> &parameters = DetectorParameters::create(),
OutputArrayOfArrays rejectedImgPoints = noArray(), InputArray cameraMatrix= noArray(), InputArray distCoeff= noArray());
/**
* @brief Pose estimation for single markers
*
* @param corners vector of already detected markers corners. For each marker, its four corners
* are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
* the dimensions of this array should be Nx4. The order of the corners should be clockwise.
* @sa detectMarkers
* @param markerLength the length of the markers' side. The returning translation vectors will
* be in the same unit. Normally, unit is meters.
* @param cameraMatrix input 3x3 floating-point camera matrix
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
* @param distCoeffs vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param rvecs array of output rotation vectors (@sa Rodrigues) (e.g. std::vector<cv::Vec3d>).
* Each element in rvecs corresponds to the specific marker in imgPoints.
* @param tvecs array of output translation vectors (e.g. std::vector<cv::Vec3d>).
* Each element in tvecs corresponds to the specific marker in imgPoints.
* @param _objPoints array of object points of all the marker corners
*
* This function receives the detected markers and returns their pose estimation respect to
* the camera individually. So for each marker, one rotation and translation vector is returned.
* The returned transformation is the one that transforms points from each marker coordinate system
* to the camera coordinate system.
* The marker corrdinate system is centered on the middle of the marker, with the Z axis
* perpendicular to the marker plane.
* The coordinates of the four corners of the marker in its own coordinate system are:
* (-markerLength/2, markerLength/2, 0), (markerLength/2, markerLength/2, 0),
* (markerLength/2, -markerLength/2, 0), (-markerLength/2, -markerLength/2, 0)
*/
CV_EXPORTS_W void estimatePoseSingleMarkers(InputArrayOfArrays corners, float markerLength,
InputArray cameraMatrix, InputArray distCoeffs,
OutputArray rvecs, OutputArray tvecs, OutputArray _objPoints = noArray());
/**
* @brief Board of markers
*
* A board is a set of markers in the 3D space with a common coordinate system.
* The common form of a board of marker is a planar (2D) board, however any 3D layout can be used.
* A Board object is composed by:
* - The object points of the marker corners, i.e. their coordinates respect to the board system.
* - The dictionary which indicates the type of markers of the board
* - The identifier of all the markers in the board.
*/
class CV_EXPORTS_W Board {
public:
/**
* @brief Provide way to create Board by passing necessary data. Specially needed in Python.
*
* @param objPoints array of object points of all the marker corners in the board
* @param dictionary the dictionary of markers employed for this board
* @param ids vector of the identifiers of the markers in the board
*
*/
CV_WRAP static Ptr<Board> create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &dictionary, InputArray ids);
/// array of object points of all the marker corners in the board
/// each marker include its 4 corners in CCW order. For M markers, the size is Mx4.
CV_PROP std::vector< std::vector< Point3f > > objPoints;
/// the dictionary of markers employed for this board
CV_PROP Ptr<Dictionary> dictionary;
/// vector of the identifiers of the markers in the board (same size than objPoints)
/// The identifiers refers to the board dictionary
CV_PROP std::vector< int > ids;
};
/**
* @brief Planar board with grid arrangement of markers
* More common type of board. All markers are placed in the same plane in a grid arrangement.
* The board can be drawn using drawPlanarBoard() function (@sa drawPlanarBoard)
*/
class CV_EXPORTS_W GridBoard : public Board {
public:
/**
* @brief Draw a GridBoard
*
* @param outSize size of the output image in pixels.
* @param img output image with the board. The size of this image will be outSize
* and the board will be on the center, keeping the board proportions.
* @param marginSize minimum margins (in pixels) of the board in the output image
* @param borderBits width of the marker borders.
*
* This function return the image of the GridBoard, ready to be printed.
*/
CV_WRAP void draw(Size outSize, OutputArray img, int marginSize = 0, int borderBits = 1);
/**
* @brief Create a GridBoard object
*
* @param markersX number of markers in X direction
* @param markersY number of markers in Y direction
* @param markerLength marker side length (normally in meters)
* @param markerSeparation separation between two markers (same unit as markerLength)
* @param dictionary dictionary of markers indicating the type of markers
* @param firstMarker id of first marker in dictionary to use on board.
* @return the output GridBoard object
*
* This functions creates a GridBoard object given the number of markers in each direction and
* the marker size and marker separation.
*/
CV_WRAP static Ptr<GridBoard> create(int markersX, int markersY, float markerLength,
float markerSeparation, const Ptr<Dictionary> &dictionary, int firstMarker = 0);
/**
*
*/
CV_WRAP Size getGridSize() const { return Size(_markersX, _markersY); }
/**
*
*/
CV_WRAP float getMarkerLength() const { return _markerLength; }
/**
*
*/
CV_WRAP float getMarkerSeparation() const { return _markerSeparation; }
private:
// number of markers in X and Y directions
int _markersX, _markersY;
// marker side lenght (normally in meters)
float _markerLength;
// separation between markers in the grid
float _markerSeparation;
};
/**
* @brief Pose estimation for a board of markers
*
* @param corners vector of already detected markers corners. For each marker, its four corners
* are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the
* dimensions of this array should be Nx4. The order of the corners should be clockwise.
* @param ids list of identifiers for each marker in corners
* @param board layout of markers in the board. The layout is composed by the marker identifiers
* and the positions of each marker corner in the board reference system.
* @param cameraMatrix input 3x3 floating-point camera matrix
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
* @param distCoeffs vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
* (see cv::Rodrigues). Used as initial guess if not empty.
* @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
* @param useExtrinsicGuess defines whether initial guess for \b rvec and \b tvec will be used or not.
* Used as initial guess if not empty.
*
* This function receives the detected markers and returns the pose of a marker board composed
* by those markers.
* A Board of marker has a single world coordinate system which is defined by the board layout.
* The returned transformation is the one that transforms points from the board coordinate system
* to the camera coordinate system.
* Input markers that are not included in the board layout are ignored.
* The function returns the number of markers from the input employed for the board pose estimation.
* Note that returning a 0 means the pose has not been estimated.
*/
CV_EXPORTS_W int estimatePoseBoard(InputArrayOfArrays corners, InputArray ids, const Ptr<Board> &board,
InputArray cameraMatrix, InputArray distCoeffs, OutputArray rvec,
OutputArray tvec, bool useExtrinsicGuess = false);
/**
* @brief Refind not detected markers based on the already detected and the board layout
*
* @param image input image
* @param board layout of markers in the board.
* @param detectedCorners vector of already detected marker corners.
* @param detectedIds vector of already detected marker identifiers.
* @param rejectedCorners vector of rejected candidates during the marker detection process.
* @param cameraMatrix optional input 3x3 floating-point camera matrix
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
* @param distCoeffs optional vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param minRepDistance minimum distance between the corners of the rejected candidate and the
* reprojected marker in order to consider it as a correspondence.
* @param errorCorrectionRate rate of allowed erroneous bits respect to the error correction
* capability of the used dictionary. -1 ignores the error correction step.
* @param checkAllOrders Consider the four posible corner orders in the rejectedCorners array.
* If it set to false, only the provided corner order is considered (default true).
* @param recoveredIdxs Optional array to returns the indexes of the recovered candidates in the
* original rejectedCorners array.
* @param parameters marker detection parameters
*
* This function tries to find markers that were not detected in the basic detecMarkers function.
* First, based on the current detected marker and the board layout, the function interpolates
* the position of the missing markers. Then it tries to find correspondence between the reprojected
* markers and the rejected candidates based on the minRepDistance and errorCorrectionRate
* parameters.
* If camera parameters and distortion coefficients are provided, missing markers are reprojected
* using projectPoint function. If not, missing marker projections are interpolated using global
* homography, and all the marker corners in the board must have the same Z coordinate.
*/
CV_EXPORTS_W void refineDetectedMarkers(
InputArray image,const Ptr<Board> &board, InputOutputArrayOfArrays detectedCorners,
InputOutputArray detectedIds, InputOutputArrayOfArrays rejectedCorners,
InputArray cameraMatrix = noArray(), InputArray distCoeffs = noArray(),
float minRepDistance = 10.f, float errorCorrectionRate = 3.f, bool checkAllOrders = true,
OutputArray recoveredIdxs = noArray(), const Ptr<DetectorParameters> &parameters = DetectorParameters::create());
/**
* @brief Draw detected markers in image
*
* @param image input/output image. It must have 1 or 3 channels. The number of channels is not
* altered.
* @param corners positions of marker corners on input image.
* (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the dimensions of
* this array should be Nx4. The order of the corners should be clockwise.
* @param ids vector of identifiers for markers in markersCorners .
* Optional, if not provided, ids are not painted.
* @param borderColor color of marker borders. Rest of colors (text color and first corner color)
* are calculated based on this one to improve visualization.
*
* Given an array of detected marker corners and its corresponding ids, this functions draws
* the markers in the image. The marker borders are painted and the markers identifiers if provided.
* Useful for debugging purposes.
*/
CV_EXPORTS_W void drawDetectedMarkers(InputOutputArray image, InputArrayOfArrays corners,
InputArray ids = noArray(),
Scalar borderColor = Scalar(0, 255, 0));
/**
* @brief Draw coordinate system axis from pose estimation
*
* @param image input/output image. It must have 1 or 3 channels. The number of channels is not
* altered.
* @param cameraMatrix input 3x3 floating-point camera matrix
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
* @param distCoeffs vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param rvec rotation vector of the coordinate system that will be drawn. (@sa Rodrigues).
* @param tvec translation vector of the coordinate system that will be drawn.
* @param length length of the painted axis in the same unit than tvec (usually in meters)
*
* Given the pose estimation of a marker or board, this function draws the axis of the world
* coordinate system, i.e. the system centered on the marker/board. Useful for debugging purposes.
*
* @deprecated use cv::drawFrameAxes
*/
CV_EXPORTS_W void drawAxis(InputOutputArray image, InputArray cameraMatrix, InputArray distCoeffs,
InputArray rvec, InputArray tvec, float length);
/**
* @brief Draw a canonical marker image
*
* @param dictionary dictionary of markers indicating the type of markers
* @param id identifier of the marker that will be returned. It has to be a valid id
* in the specified dictionary.
* @param sidePixels size of the image in pixels
* @param img output image with the marker
* @param borderBits width of the marker border.
*
* This function returns a marker image in its canonical form (i.e. ready to be printed)
*/
CV_EXPORTS_W void drawMarker(const Ptr<Dictionary> &dictionary, int id, int sidePixels, OutputArray img,
int borderBits = 1);
/**
* @brief Draw a planar board
* @sa _drawPlanarBoardImpl
*
* @param board layout of the board that will be drawn. The board should be planar,
* z coordinate is ignored
* @param outSize size of the output image in pixels.
* @param img output image with the board. The size of this image will be outSize
* and the board will be on the center, keeping the board proportions.
* @param marginSize minimum margins (in pixels) of the board in the output image
* @param borderBits width of the marker borders.
*
* This function return the image of a planar board, ready to be printed. It assumes
* the Board layout specified is planar by ignoring the z coordinates of the object points.
*/
CV_EXPORTS_W void drawPlanarBoard(const Ptr<Board> &board, Size outSize, OutputArray img,
int marginSize = 0, int borderBits = 1);
/**
* @brief Implementation of drawPlanarBoard that accepts a raw Board pointer.
*/
void _drawPlanarBoardImpl(Board *board, Size outSize, OutputArray img,
int marginSize = 0, int borderBits = 1);
/**
* @brief Calibrate a camera using aruco markers
*
* @param corners vector of detected marker corners in all frames.
* The corners should have the same format returned by detectMarkers (see #detectMarkers).
* @param ids list of identifiers for each marker in corners
* @param counter number of markers in each frame so that corners and ids can be split
* @param board Marker Board layout
* @param imageSize Size of the image used only to initialize the intrinsic camera matrix.
* @param cameraMatrix Output 3x3 floating-point camera matrix
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . If CV\_CALIB\_USE\_INTRINSIC\_GUESS
* and/or CV_CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
* initialized before calling the function.
* @param distCoeffs Output vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each board view
* (e.g. std::vector<cv::Mat>>). That is, each k-th rotation vector together with the corresponding
* k-th translation vector (see the next output parameter description) brings the board pattern
* from the model coordinate space (in which object points are specified) to the world coordinate
* space, that is, a real position of the board pattern in the k-th pattern view (k=0.. *M* -1).
* @param tvecs Output vector of translation vectors estimated for each pattern view.
* @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
* Order of deviations values:
* \f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3,
* s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero.
* @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
* Order of deviations values: \f$(R_1, T_1, \dotsc , R_M, T_M)\f$ where M is number of pattern views,
* \f$R_i, T_i\f$ are concatenated 1x3 vectors.
* @param perViewErrors Output vector of average re-projection errors estimated for each pattern view.
* @param flags flags Different flags for the calibration process (see #calibrateCamera for details).
* @param criteria Termination criteria for the iterative optimization algorithm.
*
* This function calibrates a camera using an Aruco Board. The function receives a list of
* detected markers from several views of the Board. The process is similar to the chessboard
* calibration in calibrateCamera(). The function returns the final re-projection error.
*/
CV_EXPORTS_AS(calibrateCameraArucoExtended) double calibrateCameraAruco(
InputArrayOfArrays corners, InputArray ids, InputArray counter, const Ptr<Board> &board,
Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
OutputArray stdDeviationsIntrinsics, OutputArray stdDeviationsExtrinsics,
OutputArray perViewErrors, int flags = 0,
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
/** @brief It's the same function as #calibrateCameraAruco but without calibration error estimation.
*/
CV_EXPORTS_W double calibrateCameraAruco(
InputArrayOfArrays corners, InputArray ids, InputArray counter, const Ptr<Board> &board,
Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
OutputArrayOfArrays rvecs = noArray(), OutputArrayOfArrays tvecs = noArray(), int flags = 0,
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
/**
* @brief Given a board configuration and a set of detected markers, returns the corresponding
* image points and object points to call solvePnP
*
* @param board Marker board layout.
* @param detectedCorners List of detected marker corners of the board.
* @param detectedIds List of identifiers for each marker.
* @param objPoints Vector of vectors of board marker points in the board coordinate space.
* @param imgPoints Vector of vectors of the projections of board marker corner points.
*/
CV_EXPORTS_W void getBoardObjectAndImagePoints(const Ptr<Board> &board, InputArrayOfArrays detectedCorners,
InputArray detectedIds, OutputArray objPoints, OutputArray imgPoints);
//! @}
}
}
#endif

View File

@@ -0,0 +1,343 @@
/*
By downloading, copying, installing or using the software you agree to this
license. If you do not agree to this license, do not download, install,
copy or use the software.
License Agreement
For Open Source Computer Vision Library
(3-clause BSD License)
Copyright (C) 2013, OpenCV Foundation, all rights reserved.
Third party copyrights are property of their respective owners.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the names of the copyright holders nor the names of the 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 copyright holders 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.
*/
#ifndef __OPENCV_CHARUCO_HPP__
#define __OPENCV_CHARUCO_HPP__
#include <opencv2/core.hpp>
#include <vector>
#include <opencv2/aruco.hpp>
namespace cv {
namespace aruco {
//! @addtogroup aruco
//! @{
/**
* @brief ChArUco board
* Specific class for ChArUco boards. A ChArUco board is a planar board where the markers are placed
* inside the white squares of a chessboard. The benefits of ChArUco boards is that they provide
* both, ArUco markers versatility and chessboard corner precision, which is important for
* calibration and pose estimation.
* This class also allows the easy creation and drawing of ChArUco boards.
*/
class CV_EXPORTS_W CharucoBoard : public Board {
public:
// vector of chessboard 3D corners precalculated
CV_PROP std::vector< Point3f > chessboardCorners;
// for each charuco corner, nearest marker id and nearest marker corner id of each marker
CV_PROP std::vector< std::vector< int > > nearestMarkerIdx;
CV_PROP std::vector< std::vector< int > > nearestMarkerCorners;
/**
* @brief Draw a ChArUco board
*
* @param outSize size of the output image in pixels.
* @param img output image with the board. The size of this image will be outSize
* and the board will be on the center, keeping the board proportions.
* @param marginSize minimum margins (in pixels) of the board in the output image
* @param borderBits width of the marker borders.
*
* This function return the image of the ChArUco board, ready to be printed.
*/
CV_WRAP void draw(Size outSize, OutputArray img, int marginSize = 0, int borderBits = 1);
/**
* @brief Create a CharucoBoard object
*
* @param squaresX number of chessboard squares in X direction
* @param squaresY number of chessboard squares in Y direction
* @param squareLength chessboard square side length (normally in meters)
* @param markerLength marker side length (same unit than squareLength)
* @param dictionary dictionary of markers indicating the type of markers.
* The first markers in the dictionary are used to fill the white chessboard squares.
* @return the output CharucoBoard object
*
* This functions creates a CharucoBoard object given the number of squares in each direction
* and the size of the markers and chessboard squares.
*/
CV_WRAP static Ptr<CharucoBoard> create(int squaresX, int squaresY, float squareLength,
float markerLength, const Ptr<Dictionary> &dictionary);
/**
*
*/
CV_WRAP Size getChessboardSize() const { return Size(_squaresX, _squaresY); }
/**
*
*/
CV_WRAP float getSquareLength() const { return _squareLength; }
/**
*
*/
CV_WRAP float getMarkerLength() const { return _markerLength; }
private:
void _getNearestMarkerCorners();
// number of markers in X and Y directions
int _squaresX, _squaresY;
// size of chessboard squares side (normally in meters)
float _squareLength;
// marker side lenght (normally in meters)
float _markerLength;
};
/**
* @brief Interpolate position of ChArUco board corners
* @param markerCorners vector of already detected markers corners. For each marker, its four
* corners are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the
* dimensions of this array should be Nx4. The order of the corners should be clockwise.
* @param markerIds list of identifiers for each marker in corners
* @param image input image necesary for corner refinement. Note that markers are not detected and
* should be sent in corners and ids parameters.
* @param board layout of ChArUco board.
* @param charucoCorners interpolated chessboard corners
* @param charucoIds interpolated chessboard corners identifiers
* @param cameraMatrix optional 3x3 floating-point camera matrix
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
* @param distCoeffs optional vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param minMarkers number of adjacent markers that must be detected to return a charuco corner
*
* This function receives the detected markers and returns the 2D position of the chessboard corners
* from a ChArUco board using the detected Aruco markers. If camera parameters are provided,
* the process is based in an approximated pose estimation, else it is based on local homography.
* Only visible corners are returned. For each corner, its corresponding identifier is
* also returned in charucoIds.
* The function returns the number of interpolated corners.
*/
CV_EXPORTS_W int interpolateCornersCharuco(InputArrayOfArrays markerCorners, InputArray markerIds,
InputArray image, const Ptr<CharucoBoard> &board,
OutputArray charucoCorners, OutputArray charucoIds,
InputArray cameraMatrix = noArray(),
InputArray distCoeffs = noArray(), int minMarkers = 2);
/**
* @brief Pose estimation for a ChArUco board given some of their corners
* @param charucoCorners vector of detected charuco corners
* @param charucoIds list of identifiers for each corner in charucoCorners
* @param board layout of ChArUco board.
* @param cameraMatrix input 3x3 floating-point camera matrix
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
* @param distCoeffs vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
* (see cv::Rodrigues).
* @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
* @param useExtrinsicGuess defines whether initial guess for \b rvec and \b tvec will be used or not.
*
* This function estimates a Charuco board pose from some detected corners.
* The function checks if the input corners are enough and valid to perform pose estimation.
* If pose estimation is valid, returns true, else returns false.
*/
CV_EXPORTS_W bool estimatePoseCharucoBoard(InputArray charucoCorners, InputArray charucoIds,
const Ptr<CharucoBoard> &board, InputArray cameraMatrix,
InputArray distCoeffs, OutputArray rvec, OutputArray tvec,
bool useExtrinsicGuess = false);
/**
* @brief Draws a set of Charuco corners
* @param image input/output image. It must have 1 or 3 channels. The number of channels is not
* altered.
* @param charucoCorners vector of detected charuco corners
* @param charucoIds list of identifiers for each corner in charucoCorners
* @param cornerColor color of the square surrounding each corner
*
* This function draws a set of detected Charuco corners. If identifiers vector is provided, it also
* draws the id of each corner.
*/
CV_EXPORTS_W void drawDetectedCornersCharuco(InputOutputArray image, InputArray charucoCorners,
InputArray charucoIds = noArray(),
Scalar cornerColor = Scalar(255, 0, 0));
/**
* @brief Calibrate a camera using Charuco corners
*
* @param charucoCorners vector of detected charuco corners per frame
* @param charucoIds list of identifiers for each corner in charucoCorners per frame
* @param board Marker Board layout
* @param imageSize input image size
* @param cameraMatrix Output 3x3 floating-point camera matrix
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . If CV\_CALIB\_USE\_INTRINSIC\_GUESS
* and/or CV_CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
* initialized before calling the function.
* @param distCoeffs Output vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each board view
* (e.g. std::vector<cv::Mat>>). That is, each k-th rotation vector together with the corresponding
* k-th translation vector (see the next output parameter description) brings the board pattern
* from the model coordinate space (in which object points are specified) to the world coordinate
* space, that is, a real position of the board pattern in the k-th pattern view (k=0.. *M* -1).
* @param tvecs Output vector of translation vectors estimated for each pattern view.
* @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
* Order of deviations values:
* \f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3,
* s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero.
* @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
* Order of deviations values: \f$(R_1, T_1, \dotsc , R_M, T_M)\f$ where M is number of pattern views,
* \f$R_i, T_i\f$ are concatenated 1x3 vectors.
* @param perViewErrors Output vector of average re-projection errors estimated for each pattern view.
* @param flags flags Different flags for the calibration process (see #calibrateCamera for details).
* @param criteria Termination criteria for the iterative optimization algorithm.
*
* This function calibrates a camera using a set of corners of a Charuco Board. The function
* receives a list of detected corners and its identifiers from several views of the Board.
* The function returns the final re-projection error.
*/
CV_EXPORTS_AS(calibrateCameraCharucoExtended) double calibrateCameraCharuco(
InputArrayOfArrays charucoCorners, InputArrayOfArrays charucoIds, const Ptr<CharucoBoard> &board,
Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
OutputArray stdDeviationsIntrinsics, OutputArray stdDeviationsExtrinsics,
OutputArray perViewErrors, int flags = 0,
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
/** @brief It's the same function as #calibrateCameraCharuco but without calibration error estimation.
*/
CV_EXPORTS_W double calibrateCameraCharuco(
InputArrayOfArrays charucoCorners, InputArrayOfArrays charucoIds, const Ptr<CharucoBoard> &board,
Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
OutputArrayOfArrays rvecs = noArray(), OutputArrayOfArrays tvecs = noArray(), int flags = 0,
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
/**
* @brief Detect ChArUco Diamond markers
*
* @param image input image necessary for corner subpixel.
* @param markerCorners list of detected marker corners from detectMarkers function.
* @param markerIds list of marker ids in markerCorners.
* @param squareMarkerLengthRate rate between square and marker length:
* squareMarkerLengthRate = squareLength/markerLength. The real units are not necessary.
* @param diamondCorners output list of detected diamond corners (4 corners per diamond). The order
* is the same than in marker corners: top left, top right, bottom right and bottom left. Similar
* format than the corners returned by detectMarkers (e.g std::vector<std::vector<cv::Point2f> > ).
* @param diamondIds ids of the diamonds in diamondCorners. The id of each diamond is in fact of
* type Vec4i, so each diamond has 4 ids, which are the ids of the aruco markers composing the
* diamond.
* @param cameraMatrix Optional camera calibration matrix.
* @param distCoeffs Optional camera distortion coefficients.
*
* This function detects Diamond markers from the previous detected ArUco markers. The diamonds
* are returned in the diamondCorners and diamondIds parameters. If camera calibration parameters
* are provided, the diamond search is based on reprojection. If not, diamond search is based on
* homography. Homography is faster than reprojection but can slightly reduce the detection rate.
*/
CV_EXPORTS_W void detectCharucoDiamond(InputArray image, InputArrayOfArrays markerCorners,
InputArray markerIds, float squareMarkerLengthRate,
OutputArrayOfArrays diamondCorners, OutputArray diamondIds,
InputArray cameraMatrix = noArray(),
InputArray distCoeffs = noArray());
/**
* @brief Draw a set of detected ChArUco Diamond markers
*
* @param image input/output image. It must have 1 or 3 channels. The number of channels is not
* altered.
* @param diamondCorners positions of diamond corners in the same format returned by
* detectCharucoDiamond(). (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
* the dimensions of this array should be Nx4. The order of the corners should be clockwise.
* @param diamondIds vector of identifiers for diamonds in diamondCorners, in the same format
* returned by detectCharucoDiamond() (e.g. std::vector<Vec4i>).
* Optional, if not provided, ids are not painted.
* @param borderColor color of marker borders. Rest of colors (text color and first corner color)
* are calculated based on this one.
*
* Given an array of detected diamonds, this functions draws them in the image. The marker borders
* are painted and the markers identifiers if provided.
* Useful for debugging purposes.
*/
CV_EXPORTS_W void drawDetectedDiamonds(InputOutputArray image, InputArrayOfArrays diamondCorners,
InputArray diamondIds = noArray(),
Scalar borderColor = Scalar(0, 0, 255));
/**
* @brief Draw a ChArUco Diamond marker
*
* @param dictionary dictionary of markers indicating the type of markers.
* @param ids list of 4 ids for each ArUco marker in the ChArUco marker.
* @param squareLength size of the chessboard squares in pixels.
* @param markerLength size of the markers in pixels.
* @param img output image with the marker. The size of this image will be
* 3*squareLength + 2*marginSize,.
* @param marginSize minimum margins (in pixels) of the marker in the output image
* @param borderBits width of the marker borders.
*
* This function return the image of a ChArUco marker, ready to be printed.
*/
// TODO cannot be exported yet; conversion from/to Vec4i is not wrapped in core
CV_EXPORTS void drawCharucoDiamond(const Ptr<Dictionary> &dictionary, Vec4i ids, int squareLength,
int markerLength, OutputArray img, int marginSize = 0,
int borderBits = 1);
//! @}
}
}
#endif

View File

@@ -0,0 +1,212 @@
/*
By downloading, copying, installing or using the software you agree to this
license. If you do not agree to this license, do not download, install,
copy or use the software.
License Agreement
For Open Source Computer Vision Library
(3-clause BSD License)
Copyright (C) 2013, OpenCV Foundation, all rights reserved.
Third party copyrights are property of their respective owners.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the names of the copyright holders nor the names of the 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 copyright holders 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.
*/
#ifndef __OPENCV_DICTIONARY_HPP__
#define __OPENCV_DICTIONARY_HPP__
#include <opencv2/core.hpp>
namespace cv {
namespace aruco {
//! @addtogroup aruco
//! @{
/**
* @brief Dictionary/Set of markers. It contains the inner codification
*
* bytesList contains the marker codewords where
* - bytesList.rows is the dictionary size
* - each marker is encoded using `nbytes = ceil(markerSize*markerSize/8.)`
* - each row contains all 4 rotations of the marker, so its length is `4*nbytes`
*
* `bytesList.ptr(i)[k*nbytes + j]` is then the j-th byte of i-th marker, in its k-th rotation.
*/
class CV_EXPORTS_W Dictionary {
public:
CV_PROP_RW Mat bytesList; // marker code information
CV_PROP_RW int markerSize; // number of bits per dimension
CV_PROP_RW int maxCorrectionBits; // maximum number of bits that can be corrected
/**
*/
Dictionary(const Mat &_bytesList = Mat(), int _markerSize = 0, int _maxcorr = 0);
/**
Dictionary(const Dictionary &_dictionary);
*/
/**
*/
Dictionary(const Ptr<Dictionary> &_dictionary);
/**
* @see generateCustomDictionary
*/
CV_WRAP_AS(create) static Ptr<Dictionary> create(int nMarkers, int markerSize, int randomSeed=0);
/**
* @see generateCustomDictionary
*/
CV_WRAP_AS(create_from) static Ptr<Dictionary> create(int nMarkers, int markerSize,
const Ptr<Dictionary> &baseDictionary, int randomSeed=0);
/**
* @see getPredefinedDictionary
*/
CV_WRAP static Ptr<Dictionary> get(int dict);
/**
* @brief Given a matrix of bits. Returns whether if marker is identified or not.
* It returns by reference the correct id (if any) and the correct rotation
*/
bool identify(const Mat &onlyBits, int &idx, int &rotation, double maxCorrectionRate) const;
/**
* @brief Returns the distance of the input bits to the specific id. If allRotations is true,
* the four posible bits rotation are considered
*/
int getDistanceToId(InputArray bits, int id, bool allRotations = true) const;
/**
* @brief Draw a canonical marker image
*/
CV_WRAP void drawMarker(int id, int sidePixels, OutputArray _img, int borderBits = 1) const;
/**
* @brief Transform matrix of bits to list of bytes in the 4 rotations
*/
CV_WRAP static Mat getByteListFromBits(const Mat &bits);
/**
* @brief Transform list of bytes to matrix of bits
*/
CV_WRAP static Mat getBitsFromByteList(const Mat &byteList, int markerSize);
};
/**
* @brief Predefined markers dictionaries/sets
* Each dictionary indicates the number of bits and the number of markers contained
* - DICT_ARUCO_ORIGINAL: standard ArUco Library Markers. 1024 markers, 5x5 bits, 0 minimum
distance
*/
enum PREDEFINED_DICTIONARY_NAME {
DICT_4X4_50 = 0,
DICT_4X4_100,
DICT_4X4_250,
DICT_4X4_1000,
DICT_5X5_50,
DICT_5X5_100,
DICT_5X5_250,
DICT_5X5_1000,
DICT_6X6_50,
DICT_6X6_100,
DICT_6X6_250,
DICT_6X6_1000,
DICT_7X7_50,
DICT_7X7_100,
DICT_7X7_250,
DICT_7X7_1000,
DICT_ARUCO_ORIGINAL,
DICT_APRILTAG_16h5, ///< 4x4 bits, minimum hamming distance between any two codes = 5, 30 codes
DICT_APRILTAG_25h9, ///< 5x5 bits, minimum hamming distance between any two codes = 9, 35 codes
DICT_APRILTAG_36h10, ///< 6x6 bits, minimum hamming distance between any two codes = 10, 2320 codes
DICT_APRILTAG_36h11 ///< 6x6 bits, minimum hamming distance between any two codes = 11, 587 codes
};
/**
* @brief Returns one of the predefined dictionaries defined in PREDEFINED_DICTIONARY_NAME
*/
CV_EXPORTS Ptr<Dictionary> getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME name);
/**
* @brief Returns one of the predefined dictionaries referenced by DICT_*.
*/
CV_EXPORTS_W Ptr<Dictionary> getPredefinedDictionary(int dict);
/**
* @see generateCustomDictionary
*/
CV_EXPORTS_AS(custom_dictionary) Ptr<Dictionary> generateCustomDictionary(
int nMarkers,
int markerSize,
int randomSeed=0);
/**
* @brief Generates a new customizable marker dictionary
*
* @param nMarkers number of markers in the dictionary
* @param markerSize number of bits per dimension of each markers
* @param baseDictionary Include the markers in this dictionary at the beginning (optional)
* @param randomSeed a user supplied seed for theRNG()
*
* This function creates a new dictionary composed by nMarkers markers and each markers composed
* by markerSize x markerSize bits. If baseDictionary is provided, its markers are directly
* included and the rest are generated based on them. If the size of baseDictionary is higher
* than nMarkers, only the first nMarkers in baseDictionary are taken and no new marker is added.
*/
CV_EXPORTS_AS(custom_dictionary_from) Ptr<Dictionary> generateCustomDictionary(
int nMarkers,
int markerSize,
const Ptr<Dictionary> &baseDictionary,
int randomSeed=0);
//! @}
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,125 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2013-2016, The Regents of The University of Michigan.
//
// This software was developed in the APRIL Robotics Lab under the
// direction of Edwin Olson, ebolson@umich.edu. This software may be
// available under alternative licensing terms; contact the address above.
//
// The views and conclusions contained in the software and documentation are those
// of the authors and should not be interpreted as representing official policies,
// either expressed or implied, of the Regents of The University of Michigan.
// limitation: image size must be <32768 in width and height. This is
// because we use a fixed-point 16 bit integer representation with one
// fractional bit.
#ifndef _OPENCV_APRIL_QUAD_THRESH_HPP_
#define _OPENCV_APRIL_QUAD_THRESH_HPP_
#include "opencv2/aruco.hpp"
#include "unionfind.hpp"
#include "zmaxheap.hpp"
#include "zarray.hpp"
namespace cv {
namespace aruco {
static inline uint32_t u64hash_2(uint64_t x) {
return uint32_t((2654435761UL * x) >> 32);
}
struct uint64_zarray_entry{
uint64_t id;
zarray_t *cluster;
struct uint64_zarray_entry *next;
};
struct pt{
// Note: these represent 2*actual value.
uint16_t x, y;
float theta;
int16_t gx, gy;
};
struct remove_vertex{
int i; // which vertex to remove?
int left, right; // left vertex, right vertex
double err;
};
struct segment{
int is_vertex;
// always greater than zero, but right can be > size, which denotes
// a wrap around back to the beginning of the points. and left < right.
int left, right;
};
struct line_fit_pt{
double Mx, My;
double Mxx, Myy, Mxy;
double W; // total weight
};
/**
* lfps contains *cumulative* moments for N points, with
* index j reflecting points [0,j] (inclusive).
* fit a line to the points [i0, i1] (inclusive). i0, i1 are both (0, sz)
* if i1 < i0, we treat this as a wrap around.
*/
void fit_line(struct line_fit_pt *lfps, int sz, int i0, int i1, double *lineparm, double *err, double *mse);
int err_compare_descending(const void *_a, const void *_b);
/**
1. Identify A) white points near a black point and B) black points near a white point.
2. Find the connected components within each of the classes above,
yielding clusters of "white-near-black" and
"black-near-white". (These two classes are kept separate). Each
segment has a unique id.
3. For every pair of "white-near-black" and "black-near-white"
clusters, find the set of points that are in one and adjacent to the
other. In other words, a "boundary" layer between the two
clusters. (This is actually performed by iterating over the pixels,
rather than pairs of clusters.) Critically, this helps keep nearby
edges from becoming connected.
**/
int quad_segment_maxima(const Ptr<DetectorParameters> &td, int sz, struct line_fit_pt *lfps, int indices[4]);
/**
* returns 0 if the cluster looks bad.
*/
int quad_segment_agg(int sz, struct line_fit_pt *lfps, int indices[4]);
/**
* return 1 if the quad looks okay, 0 if it should be discarded
* quad
**/
int fit_quad(const Ptr<DetectorParameters> &_params, const Mat im, zarray_t *cluster, struct sQuad *quad);
/**
*
* @param mIm
* @param parameters
* @param mThresh
*/
void threshold(const Mat mIm, const Ptr<DetectorParameters> &parameters, Mat& mThresh);
/**
*
* @param parameters
* @param mImg
* @param contours
* @return
*/
zarray_t *apriltag_quad_thresh(const Ptr<DetectorParameters> &parameters, const Mat & mImg, std::vector< std::vector< Point > > &contours);
}}
#endif

1916
aruco_pose/vendor/aruco/src/aruco.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

934
aruco_pose/vendor/aruco/src/charuco.cpp vendored Normal file
View File

@@ -0,0 +1,934 @@
/*
By downloading, copying, installing or using the software you agree to this
license. If you do not agree to this license, do not download, install,
copy or use the software.
License Agreement
For Open Source Computer Vision Library
(3-clause BSD License)
Copyright (C) 2013, OpenCV Foundation, all rights reserved.
Third party copyrights are property of their respective owners.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the names of the copyright holders nor the names of the 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 copyright holders 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 "precomp.hpp"
#include "opencv2/aruco/charuco.hpp"
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
namespace cv {
namespace aruco {
using namespace std;
/**
*/
void CharucoBoard::draw(Size outSize, OutputArray _img, int marginSize, int borderBits) {
/* NOTE: OpenCV v<3.3 does not have .empty() as a Size member */
CV_Assert(outSize.height > 0 && outSize.width > 0);
CV_Assert(marginSize >= 0);
_img.create(outSize, CV_8UC1);
_img.setTo(255);
Mat out = _img.getMat();
Mat noMarginsImg =
out.colRange(marginSize, out.cols - marginSize).rowRange(marginSize, out.rows - marginSize);
double totalLengthX, totalLengthY;
totalLengthX = _squareLength * _squaresX;
totalLengthY = _squareLength * _squaresY;
// proportional transformation
double xReduction = totalLengthX / double(noMarginsImg.cols);
double yReduction = totalLengthY / double(noMarginsImg.rows);
// determine the zone where the chessboard is placed
Mat chessboardZoneImg;
if(xReduction > yReduction) {
int nRows = int(totalLengthY / xReduction);
int rowsMargins = (noMarginsImg.rows - nRows) / 2;
chessboardZoneImg = noMarginsImg.rowRange(rowsMargins, noMarginsImg.rows - rowsMargins);
} else {
int nCols = int(totalLengthX / yReduction);
int colsMargins = (noMarginsImg.cols - nCols) / 2;
chessboardZoneImg = noMarginsImg.colRange(colsMargins, noMarginsImg.cols - colsMargins);
}
// determine the margins to draw only the markers
// take the minimum just to be sure
double squareSizePixels = min(double(chessboardZoneImg.cols) / double(_squaresX),
double(chessboardZoneImg.rows) / double(_squaresY));
double diffSquareMarkerLength = (_squareLength - _markerLength) / 2;
int diffSquareMarkerLengthPixels =
int(diffSquareMarkerLength * squareSizePixels / _squareLength);
// draw markers
Mat markersImg;
aruco::_drawPlanarBoardImpl(this, chessboardZoneImg.size(), markersImg,
diffSquareMarkerLengthPixels, borderBits);
markersImg.copyTo(chessboardZoneImg);
// now draw black squares
for(int y = 0; y < _squaresY; y++) {
for(int x = 0; x < _squaresX; x++) {
if(y % 2 != x % 2) continue; // white corner, dont do anything
double startX, startY;
startX = squareSizePixels * double(x);
startY = double(chessboardZoneImg.rows) - squareSizePixels * double(y + 1);
Mat squareZone = chessboardZoneImg.rowRange(int(startY), int(startY + squareSizePixels))
.colRange(int(startX), int(startX + squareSizePixels));
squareZone.setTo(0);
}
}
}
/**
*/
Ptr<CharucoBoard> CharucoBoard::create(int squaresX, int squaresY, float squareLength,
float markerLength, const Ptr<Dictionary> &dictionary) {
CV_Assert(squaresX > 1 && squaresY > 1 && markerLength > 0 && squareLength > markerLength);
Ptr<CharucoBoard> res = makePtr<CharucoBoard>();
res->_squaresX = squaresX;
res->_squaresY = squaresY;
res->_squareLength = squareLength;
res->_markerLength = markerLength;
res->dictionary = dictionary;
float diffSquareMarkerLength = (squareLength - markerLength) / 2;
// calculate Board objPoints
for(int y = squaresY - 1; y >= 0; y--) {
for(int x = 0; x < squaresX; x++) {
if(y % 2 == x % 2) continue; // black corner, no marker here
vector< Point3f > corners;
corners.resize(4);
corners[0] = Point3f(x * squareLength + diffSquareMarkerLength,
y * squareLength + diffSquareMarkerLength + markerLength, 0);
corners[1] = corners[0] + Point3f(markerLength, 0, 0);
corners[2] = corners[0] + Point3f(markerLength, -markerLength, 0);
corners[3] = corners[0] + Point3f(0, -markerLength, 0);
res->objPoints.push_back(corners);
// first ids in dictionary
int nextId = (int)res->ids.size();
res->ids.push_back(nextId);
}
}
// now fill chessboardCorners
for(int y = 0; y < squaresY - 1; y++) {
for(int x = 0; x < squaresX - 1; x++) {
Point3f corner;
corner.x = (x + 1) * squareLength;
corner.y = (y + 1) * squareLength;
corner.z = 0;
res->chessboardCorners.push_back(corner);
}
}
res->_getNearestMarkerCorners();
return res;
}
/**
* Fill nearestMarkerIdx and nearestMarkerCorners arrays
*/
void CharucoBoard::_getNearestMarkerCorners() {
nearestMarkerIdx.resize(chessboardCorners.size());
nearestMarkerCorners.resize(chessboardCorners.size());
unsigned int nMarkers = (unsigned int)ids.size();
unsigned int nCharucoCorners = (unsigned int)chessboardCorners.size();
for(unsigned int i = 0; i < nCharucoCorners; i++) {
double minDist = -1; // distance of closest markers
Point3f charucoCorner = chessboardCorners[i];
for(unsigned int j = 0; j < nMarkers; j++) {
// calculate distance from marker center to charuco corner
Point3f center = Point3f(0, 0, 0);
for(unsigned int k = 0; k < 4; k++)
center += objPoints[j][k];
center /= 4.;
double sqDistance;
Point3f distVector = charucoCorner - center;
sqDistance = distVector.x * distVector.x + distVector.y * distVector.y;
if(j == 0 || fabs(sqDistance - minDist) < cv::pow(0.01 * _squareLength, 2)) {
// if same minimum distance (or first iteration), add to nearestMarkerIdx vector
nearestMarkerIdx[i].push_back(j);
minDist = sqDistance;
} else if(sqDistance < minDist) {
// if finding a closest marker to the charuco corner
nearestMarkerIdx[i].clear(); // remove any previous added marker
nearestMarkerIdx[i].push_back(j); // add the new closest marker index
minDist = sqDistance;
}
}
// for each of the closest markers, search the marker corner index closer
// to the charuco corner
for(unsigned int j = 0; j < nearestMarkerIdx[i].size(); j++) {
nearestMarkerCorners[i].resize(nearestMarkerIdx[i].size());
double minDistCorner = -1;
for(unsigned int k = 0; k < 4; k++) {
double sqDistance;
Point3f distVector = charucoCorner - objPoints[nearestMarkerIdx[i][j]][k];
sqDistance = distVector.x * distVector.x + distVector.y * distVector.y;
if(k == 0 || sqDistance < minDistCorner) {
// if this corner is closer to the charuco corner, assing its index
// to nearestMarkerCorners
minDistCorner = sqDistance;
nearestMarkerCorners[i][j] = k;
}
}
}
}
}
/**
* Remove charuco corners if any of their minMarkers closest markers has not been detected
*/
static int _filterCornersWithoutMinMarkers(const Ptr<CharucoBoard> &_board,
InputArray _allCharucoCorners,
InputArray _allCharucoIds,
InputArray _allArucoIds, int minMarkers,
OutputArray _filteredCharucoCorners,
OutputArray _filteredCharucoIds) {
CV_Assert(minMarkers >= 0 && minMarkers <= 2);
vector< Point2f > filteredCharucoCorners;
vector< int > filteredCharucoIds;
// for each charuco corner
for(unsigned int i = 0; i < _allCharucoIds.getMat().total(); i++) {
int currentCharucoId = _allCharucoIds.getMat().at< int >(i);
int totalMarkers = 0; // nomber of closest marker detected
// look for closest markers
for(unsigned int m = 0; m < _board->nearestMarkerIdx[currentCharucoId].size(); m++) {
int markerId = _board->ids[_board->nearestMarkerIdx[currentCharucoId][m]];
bool found = false;
for(unsigned int k = 0; k < _allArucoIds.getMat().total(); k++) {
if(_allArucoIds.getMat().at< int >(k) == markerId) {
found = true;
break;
}
}
if(found) totalMarkers++;
}
// if enough markers detected, add the charuco corner to the final list
if(totalMarkers >= minMarkers) {
filteredCharucoIds.push_back(currentCharucoId);
filteredCharucoCorners.push_back(_allCharucoCorners.getMat().at< Point2f >(i));
}
}
// parse output
Mat(filteredCharucoCorners).copyTo(_filteredCharucoCorners);
Mat(filteredCharucoIds).copyTo(_filteredCharucoIds);
return (int)_filteredCharucoIds.total();
}
/**
* ParallelLoopBody class for the parallelization of the charuco corners subpixel refinement
* Called from function _selectAndRefineChessboardCorners()
*/
class CharucoSubpixelParallel : public ParallelLoopBody {
public:
CharucoSubpixelParallel(const Mat *_grey, vector< Point2f > *_filteredChessboardImgPoints,
vector< Size > *_filteredWinSizes, const Ptr<DetectorParameters> &_params)
: grey(_grey), filteredChessboardImgPoints(_filteredChessboardImgPoints),
filteredWinSizes(_filteredWinSizes), params(_params) {}
void operator()(const Range &range) const CV_OVERRIDE {
const int begin = range.start;
const int end = range.end;
for(int i = begin; i < end; i++) {
vector< Point2f > in;
in.push_back((*filteredChessboardImgPoints)[i]);
Size winSize = (*filteredWinSizes)[i];
if(winSize.height == -1 || winSize.width == -1)
winSize = Size(params->cornerRefinementWinSize, params->cornerRefinementWinSize);
cornerSubPix(*grey, in, winSize, Size(),
TermCriteria(TermCriteria::MAX_ITER | TermCriteria::EPS,
params->cornerRefinementMaxIterations,
params->cornerRefinementMinAccuracy));
(*filteredChessboardImgPoints)[i] = in[0];
}
}
private:
CharucoSubpixelParallel &operator=(const CharucoSubpixelParallel &); // to quiet MSVC
const Mat *grey;
vector< Point2f > *filteredChessboardImgPoints;
vector< Size > *filteredWinSizes;
const Ptr<DetectorParameters> &params;
};
/**
* @brief From all projected chessboard corners, select those inside the image and apply subpixel
* refinement. Returns number of valid corners.
*/
static int _selectAndRefineChessboardCorners(InputArray _allCorners, InputArray _image,
OutputArray _selectedCorners,
OutputArray _selectedIds,
const vector< Size > &winSizes) {
const int minDistToBorder = 2; // minimum distance of the corner to the image border
// remaining corners, ids and window refinement sizes after removing corners outside the image
vector< Point2f > filteredChessboardImgPoints;
vector< Size > filteredWinSizes;
vector< int > filteredIds;
// filter corners outside the image
Rect innerRect(minDistToBorder, minDistToBorder, _image.getMat().cols - 2 * minDistToBorder,
_image.getMat().rows - 2 * minDistToBorder);
for(unsigned int i = 0; i < _allCorners.getMat().total(); i++) {
if(innerRect.contains(_allCorners.getMat().at< Point2f >(i))) {
filteredChessboardImgPoints.push_back(_allCorners.getMat().at< Point2f >(i));
filteredIds.push_back(i);
filteredWinSizes.push_back(winSizes[i]);
}
}
// if none valid, return 0
if(filteredChessboardImgPoints.size() == 0) return 0;
// corner refinement, first convert input image to grey
Mat grey;
if(_image.type() == CV_8UC3)
cvtColor(_image, grey, COLOR_BGR2GRAY);
else
_image.copyTo(grey);
const Ptr<DetectorParameters> params = DetectorParameters::create(); // use default params for corner refinement
//// For each of the charuco corners, apply subpixel refinement using its correspondind winSize
// for(unsigned int i=0; i<filteredChessboardImgPoints.size(); i++) {
// vector<Point2f> in;
// in.push_back(filteredChessboardImgPoints[i]);
// Size winSize = filteredWinSizes[i];
// if(winSize.height == -1 || winSize.width == -1)
// winSize = Size(params.cornerRefinementWinSize, params.cornerRefinementWinSize);
// cornerSubPix(grey, in, winSize, Size(),
// TermCriteria(TermCriteria::MAX_ITER | TermCriteria::EPS,
// params->cornerRefinementMaxIterations,
// params->cornerRefinementMinAccuracy));
// filteredChessboardImgPoints[i] = in[0];
//}
// this is the parallel call for the previous commented loop (result is equivalent)
parallel_for_(
Range(0, (int)filteredChessboardImgPoints.size()),
CharucoSubpixelParallel(&grey, &filteredChessboardImgPoints, &filteredWinSizes, params));
// parse output
Mat(filteredChessboardImgPoints).copyTo(_selectedCorners);
Mat(filteredIds).copyTo(_selectedIds);
return (int)filteredChessboardImgPoints.size();
}
/**
* Calculate the maximum window sizes for corner refinement for each charuco corner based on the
* distance to their closest markers
*/
static void _getMaximumSubPixWindowSizes(InputArrayOfArrays markerCorners, InputArray markerIds,
InputArray charucoCorners, const Ptr<CharucoBoard> &board,
vector< Size > &sizes) {
unsigned int nCharucoCorners = (unsigned int)charucoCorners.getMat().total();
sizes.resize(nCharucoCorners, Size(-1, -1));
for(unsigned int i = 0; i < nCharucoCorners; i++) {
if(charucoCorners.getMat().at< Point2f >(i) == Point2f(-1, -1)) continue;
if(board->nearestMarkerIdx[i].size() == 0) continue;
double minDist = -1;
int counter = 0;
// calculate the distance to each of the closest corner of each closest marker
for(unsigned int j = 0; j < board->nearestMarkerIdx[i].size(); j++) {
// find marker
int markerId = board->ids[board->nearestMarkerIdx[i][j]];
int markerIdx = -1;
for(unsigned int k = 0; k < markerIds.getMat().total(); k++) {
if(markerIds.getMat().at< int >(k) == markerId) {
markerIdx = k;
break;
}
}
if(markerIdx == -1) continue;
Point2f markerCorner =
markerCorners.getMat(markerIdx).at< Point2f >(board->nearestMarkerCorners[i][j]);
Point2f charucoCorner = charucoCorners.getMat().at< Point2f >(i);
double dist = norm(markerCorner - charucoCorner);
if(minDist == -1) minDist = dist; // if first distance, just assign it
minDist = min(dist, minDist);
counter++;
}
// if this is the first closest marker, dont do anything
if(counter == 0)
continue;
else {
// else, calculate the maximum window size
int winSizeInt = int(minDist - 2); // remove 2 pixels for safety
if(winSizeInt < 1) winSizeInt = 1; // minimum size is 1
if(winSizeInt > 10) winSizeInt = 10; // maximum size is 10
sizes[i] = Size(winSizeInt, winSizeInt);
}
}
}
/**
* Interpolate charuco corners using approximated pose estimation
*/
static int _interpolateCornersCharucoApproxCalib(InputArrayOfArrays _markerCorners,
InputArray _markerIds, InputArray _image,
const Ptr<CharucoBoard> &_board,
InputArray _cameraMatrix, InputArray _distCoeffs,
OutputArray _charucoCorners,
OutputArray _charucoIds) {
CV_Assert(_image.getMat().channels() == 1 || _image.getMat().channels() == 3);
CV_Assert(_markerCorners.total() == _markerIds.getMat().total() &&
_markerIds.getMat().total() > 0);
// approximated pose estimation using marker corners
Mat approximatedRvec, approximatedTvec;
int detectedBoardMarkers;
Ptr<Board> _b = _board.staticCast<Board>();
detectedBoardMarkers =
aruco::estimatePoseBoard(_markerCorners, _markerIds, _b,
_cameraMatrix, _distCoeffs, approximatedRvec, approximatedTvec);
if(detectedBoardMarkers == 0) return 0;
// project chessboard corners
vector< Point2f > allChessboardImgPoints;
projectPoints(_board->chessboardCorners, approximatedRvec, approximatedTvec, _cameraMatrix,
_distCoeffs, allChessboardImgPoints);
// calculate maximum window sizes for subpixel refinement. The size is limited by the distance
// to the closes marker corner to avoid erroneous displacements to marker corners
vector< Size > subPixWinSizes;
_getMaximumSubPixWindowSizes(_markerCorners, _markerIds, allChessboardImgPoints, _board,
subPixWinSizes);
// filter corners outside the image and subpixel-refine charuco corners
return _selectAndRefineChessboardCorners(allChessboardImgPoints, _image, _charucoCorners,
_charucoIds, subPixWinSizes);
}
/**
* Interpolate charuco corners using local homography
*/
static int _interpolateCornersCharucoLocalHom(InputArrayOfArrays _markerCorners,
InputArray _markerIds, InputArray _image,
const Ptr<CharucoBoard> &_board,
OutputArray _charucoCorners,
OutputArray _charucoIds) {
CV_Assert(_image.getMat().channels() == 1 || _image.getMat().channels() == 3);
CV_Assert(_markerCorners.total() == _markerIds.getMat().total() &&
_markerIds.getMat().total() > 0);
unsigned int nMarkers = (unsigned int)_markerIds.getMat().total();
// calculate local homographies for each marker
vector< Mat > transformations;
transformations.resize(nMarkers);
for(unsigned int i = 0; i < nMarkers; i++) {
vector< Point2f > markerObjPoints2D;
int markerId = _markerIds.getMat().at< int >(i);
vector< int >::const_iterator it = find(_board->ids.begin(), _board->ids.end(), markerId);
if(it == _board->ids.end()) continue;
int boardIdx = (int)std::distance<std::vector<int>::const_iterator>(_board->ids.begin(), it);
markerObjPoints2D.resize(4);
for(unsigned int j = 0; j < 4; j++)
markerObjPoints2D[j] =
Point2f(_board->objPoints[boardIdx][j].x, _board->objPoints[boardIdx][j].y);
transformations[i] = getPerspectiveTransform(markerObjPoints2D, _markerCorners.getMat(i));
}
unsigned int nCharucoCorners = (unsigned int)_board->chessboardCorners.size();
vector< Point2f > allChessboardImgPoints(nCharucoCorners, Point2f(-1, -1));
// for each charuco corner, calculate its interpolation position based on the closest markers
// homographies
for(unsigned int i = 0; i < nCharucoCorners; i++) {
Point2f objPoint2D = Point2f(_board->chessboardCorners[i].x, _board->chessboardCorners[i].y);
vector< Point2f > interpolatedPositions;
for(unsigned int j = 0; j < _board->nearestMarkerIdx[i].size(); j++) {
int markerId = _board->ids[_board->nearestMarkerIdx[i][j]];
int markerIdx = -1;
for(unsigned int k = 0; k < _markerIds.getMat().total(); k++) {
if(_markerIds.getMat().at< int >(k) == markerId) {
markerIdx = k;
break;
}
}
if(markerIdx != -1) {
vector< Point2f > in, out;
in.push_back(objPoint2D);
perspectiveTransform(in, out, transformations[markerIdx]);
interpolatedPositions.push_back(out[0]);
}
}
// none of the closest markers detected
if(interpolatedPositions.size() == 0) continue;
// more than one closest marker detected, take middle point
if(interpolatedPositions.size() > 1) {
allChessboardImgPoints[i] = (interpolatedPositions[0] + interpolatedPositions[1]) / 2.;
}
// a single closest marker detected
else allChessboardImgPoints[i] = interpolatedPositions[0];
}
// calculate maximum window sizes for subpixel refinement. The size is limited by the distance
// to the closes marker corner to avoid erroneous displacements to marker corners
vector< Size > subPixWinSizes;
_getMaximumSubPixWindowSizes(_markerCorners, _markerIds, allChessboardImgPoints, _board,
subPixWinSizes);
// filter corners outside the image and subpixel-refine charuco corners
return _selectAndRefineChessboardCorners(allChessboardImgPoints, _image, _charucoCorners,
_charucoIds, subPixWinSizes);
}
/**
*/
int interpolateCornersCharuco(InputArrayOfArrays _markerCorners, InputArray _markerIds,
InputArray _image, const Ptr<CharucoBoard> &_board,
OutputArray _charucoCorners, OutputArray _charucoIds,
InputArray _cameraMatrix, InputArray _distCoeffs, int minMarkers) {
// if camera parameters are avaible, use approximated calibration
if(_cameraMatrix.total() != 0) {
_interpolateCornersCharucoApproxCalib(_markerCorners, _markerIds, _image, _board,
_cameraMatrix, _distCoeffs, _charucoCorners,
_charucoIds);
}
// else use local homography
else {
_interpolateCornersCharucoLocalHom(_markerCorners, _markerIds, _image, _board,
_charucoCorners, _charucoIds);
}
// to return a charuco corner, its closest aruco markers should have been detected
return _filterCornersWithoutMinMarkers(_board, _charucoCorners, _charucoIds, _markerIds,
minMarkers, _charucoCorners, _charucoIds);
}
/**
*/
void drawDetectedCornersCharuco(InputOutputArray _image, InputArray _charucoCorners,
InputArray _charucoIds, Scalar cornerColor) {
CV_Assert(_image.getMat().total() != 0 &&
(_image.getMat().channels() == 1 || _image.getMat().channels() == 3));
CV_Assert((_charucoCorners.getMat().total() == _charucoIds.getMat().total()) ||
_charucoIds.getMat().total() == 0);
unsigned int nCorners = (unsigned int)_charucoCorners.getMat().total();
for(unsigned int i = 0; i < nCorners; i++) {
Point2f corner = _charucoCorners.getMat().at< Point2f >(i);
// draw first corner mark
rectangle(_image, corner - Point2f(3, 3), corner + Point2f(3, 3), cornerColor, 1, LINE_AA);
// draw ID
if(_charucoIds.total() != 0) {
int id = _charucoIds.getMat().at< int >(i);
stringstream s;
s << "id=" << id;
putText(_image, s.str(), corner + Point2f(5, -5), FONT_HERSHEY_SIMPLEX, 0.5,
cornerColor, 2);
}
}
}
/**
* Check if a set of 3d points are enough for calibration. Z coordinate is ignored.
* Only axis paralel lines are considered
*/
static bool _arePointsEnoughForPoseEstimation(const vector< Point3f > &points) {
if(points.size() < 4) return false;
vector< double > sameXValue; // different x values in points
vector< int > sameXCounter; // number of points with the x value in sameXValue
for(unsigned int i = 0; i < points.size(); i++) {
bool found = false;
for(unsigned int j = 0; j < sameXValue.size(); j++) {
if(sameXValue[j] == points[i].x) {
found = true;
sameXCounter[j]++;
}
}
if(!found) {
sameXValue.push_back(points[i].x);
sameXCounter.push_back(1);
}
}
// count how many x values has more than 2 points
int moreThan2 = 0;
for(unsigned int i = 0; i < sameXCounter.size(); i++) {
if(sameXCounter[i] >= 2) moreThan2++;
}
// if we have more than 1 two xvalues with more than 2 points, calibration is ok
if(moreThan2 > 1)
return true;
else
return false;
}
/**
*/
bool estimatePoseCharucoBoard(InputArray _charucoCorners, InputArray _charucoIds,
const Ptr<CharucoBoard> &_board, InputArray _cameraMatrix, InputArray _distCoeffs,
OutputArray _rvec, OutputArray _tvec, bool useExtrinsicGuess) {
CV_Assert((_charucoCorners.getMat().total() == _charucoIds.getMat().total()));
// need, at least, 4 corners
if(_charucoIds.getMat().total() < 4) return false;
vector< Point3f > objPoints;
objPoints.reserve(_charucoIds.getMat().total());
for(unsigned int i = 0; i < _charucoIds.getMat().total(); i++) {
int currId = _charucoIds.getMat().at< int >(i);
CV_Assert(currId >= 0 && currId < (int)_board->chessboardCorners.size());
objPoints.push_back(_board->chessboardCorners[currId]);
}
// points need to be in different lines, check if detected points are enough
if(!_arePointsEnoughForPoseEstimation(objPoints)) return false;
solvePnP(objPoints, _charucoCorners, _cameraMatrix, _distCoeffs, _rvec, _tvec, useExtrinsicGuess);
return true;
}
/**
*/
double calibrateCameraCharuco(InputArrayOfArrays _charucoCorners, InputArrayOfArrays _charucoIds,
const Ptr<CharucoBoard> &_board, Size imageSize,
InputOutputArray _cameraMatrix, InputOutputArray _distCoeffs,
OutputArrayOfArrays _rvecs, OutputArrayOfArrays _tvecs,
OutputArray _stdDeviationsIntrinsics,
OutputArray _stdDeviationsExtrinsics,
OutputArray _perViewErrors,
int flags, TermCriteria criteria) {
CV_Assert(_charucoIds.total() > 0 && (_charucoIds.total() == _charucoCorners.total()));
// Join object points of charuco corners in a single vector for calibrateCamera() function
vector< vector< Point3f > > allObjPoints;
allObjPoints.resize(_charucoIds.total());
for(unsigned int i = 0; i < _charucoIds.total(); i++) {
unsigned int nCorners = (unsigned int)_charucoIds.getMat(i).total();
CV_Assert(nCorners > 0 && nCorners == _charucoCorners.getMat(i).total());
allObjPoints[i].reserve(nCorners);
for(unsigned int j = 0; j < nCorners; j++) {
int pointId = _charucoIds.getMat(i).at< int >(j);
CV_Assert(pointId >= 0 && pointId < (int)_board->chessboardCorners.size());
allObjPoints[i].push_back(_board->chessboardCorners[pointId]);
}
}
return calibrateCamera(allObjPoints, _charucoCorners, imageSize, _cameraMatrix, _distCoeffs,
_rvecs, _tvecs, _stdDeviationsIntrinsics, _stdDeviationsExtrinsics,
_perViewErrors, flags, criteria);
}
/**
*/
double calibrateCameraCharuco(InputArrayOfArrays _charucoCorners, InputArrayOfArrays _charucoIds,
const Ptr<CharucoBoard> &_board, Size imageSize,
InputOutputArray _cameraMatrix, InputOutputArray _distCoeffs,
OutputArrayOfArrays _rvecs, OutputArrayOfArrays _tvecs, int flags,
TermCriteria criteria) {
return calibrateCameraCharuco(_charucoCorners, _charucoIds, _board, imageSize, _cameraMatrix, _distCoeffs, _rvecs,
_tvecs, noArray(), noArray(), noArray(), flags, criteria);
}
/**
*/
void detectCharucoDiamond(InputArray _image, InputArrayOfArrays _markerCorners,
InputArray _markerIds, float squareMarkerLengthRate,
OutputArrayOfArrays _diamondCorners, OutputArray _diamondIds,
InputArray _cameraMatrix, InputArray _distCoeffs) {
CV_Assert(_markerIds.total() > 0 && _markerIds.total() == _markerCorners.total());
const float minRepDistanceRate = 1.302455f;
// create Charuco board layout for diamond (3x3 layout)
Ptr<Dictionary> dict = getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME(0));
Ptr<CharucoBoard> _charucoDiamondLayout = CharucoBoard::create(3, 3, squareMarkerLengthRate, 1., dict);
vector< vector< Point2f > > diamondCorners;
vector< Vec4i > diamondIds;
// stores if the detected markers have been assigned or not to a diamond
vector< bool > assigned(_markerIds.total(), false);
if(_markerIds.total() < 4) return; // a diamond need at least 4 markers
// convert input image to grey
Mat grey;
if(_image.type() == CV_8UC3)
cvtColor(_image, grey, COLOR_BGR2GRAY);
else
_image.copyTo(grey);
// for each of the detected markers, try to find a diamond
for(unsigned int i = 0; i < _markerIds.total(); i++) {
if(assigned[i]) continue;
// calculate marker perimeter
float perimeterSq = 0;
Mat corners = _markerCorners.getMat(i);
for(int c = 0; c < 4; c++) {
Point2f edge = corners.at< Point2f >(c) - corners.at< Point2f >((c + 1) % 4);
perimeterSq += edge.x*edge.x + edge.y*edge.y;
}
// maximum reprojection error relative to perimeter
float minRepDistance = sqrt(perimeterSq) * minRepDistanceRate;
int currentId = _markerIds.getMat().at< int >(i);
// prepare data to call refineDetectedMarkers()
// detected markers (only the current one)
vector< Mat > currentMarker;
vector< int > currentMarkerId;
currentMarker.push_back(_markerCorners.getMat(i));
currentMarkerId.push_back(currentId);
// marker candidates (the rest of markers if they have not been assigned)
vector< Mat > candidates;
vector< int > candidatesIdxs;
for(unsigned int k = 0; k < assigned.size(); k++) {
if(k == i) continue;
if(!assigned[k]) {
candidates.push_back(_markerCorners.getMat(k));
candidatesIdxs.push_back(k);
}
}
if(candidates.size() < 3) break; // we need at least 3 free markers
// modify charuco layout id to make sure all the ids are different than current id
for(int k = 1; k < 4; k++)
_charucoDiamondLayout->ids[k] = currentId + 1 + k;
// current id is assigned to [0], so it is the marker on the top
_charucoDiamondLayout->ids[0] = currentId;
// try to find the rest of markers in the diamond
vector< int > acceptedIdxs;
Ptr<Board> _b = _charucoDiamondLayout.staticCast<Board>();
aruco::refineDetectedMarkers(grey, _b,
currentMarker, currentMarkerId,
candidates, noArray(), noArray(), minRepDistance, -1, false,
acceptedIdxs);
// if found, we have a diamond
if(currentMarker.size() == 4) {
assigned[i] = true;
// calculate diamond id, acceptedIdxs array indicates the markers taken from candidates
// array
Vec4i markerId;
markerId[0] = currentId;
for(int k = 1; k < 4; k++) {
int currentMarkerIdx = candidatesIdxs[acceptedIdxs[k - 1]];
markerId[k] = _markerIds.getMat().at< int >(currentMarkerIdx);
assigned[currentMarkerIdx] = true;
}
// interpolate the charuco corners of the diamond
vector< Point2f > currentMarkerCorners;
Mat aux;
interpolateCornersCharuco(currentMarker, currentMarkerId, grey, _charucoDiamondLayout,
currentMarkerCorners, aux, _cameraMatrix, _distCoeffs);
// if everything is ok, save the diamond
if(currentMarkerCorners.size() > 0) {
// reorder corners
vector< Point2f > currentMarkerCornersReorder;
currentMarkerCornersReorder.resize(4);
currentMarkerCornersReorder[0] = currentMarkerCorners[2];
currentMarkerCornersReorder[1] = currentMarkerCorners[3];
currentMarkerCornersReorder[2] = currentMarkerCorners[1];
currentMarkerCornersReorder[3] = currentMarkerCorners[0];
diamondCorners.push_back(currentMarkerCornersReorder);
diamondIds.push_back(markerId);
}
}
}
if(diamondIds.size() > 0) {
// parse output
Mat(diamondIds).copyTo(_diamondIds);
_diamondCorners.create((int)diamondCorners.size(), 1, CV_32FC2);
for(unsigned int i = 0; i < diamondCorners.size(); i++) {
_diamondCorners.create(4, 1, CV_32FC2, i, true);
for(int j = 0; j < 4; j++) {
_diamondCorners.getMat(i).at< Point2f >(j) = diamondCorners[i][j];
}
}
}
}
/**
*/
void drawCharucoDiamond(const Ptr<Dictionary> &dictionary, Vec4i ids, int squareLength, int markerLength,
OutputArray _img, int marginSize, int borderBits) {
CV_Assert(squareLength > 0 && markerLength > 0 && squareLength > markerLength);
CV_Assert(marginSize >= 0 && borderBits > 0);
// create a charuco board similar to a charuco marker and print it
Ptr<CharucoBoard> board =
CharucoBoard::create(3, 3, (float)squareLength, (float)markerLength, dictionary);
// assign the charuco marker ids
for(int i = 0; i < 4; i++)
board->ids[i] = ids[i];
Size outSize(3 * squareLength + 2 * marginSize, 3 * squareLength + 2 * marginSize);
board->draw(outSize, _img, marginSize, borderBits);
}
/**
*/
void drawDetectedDiamonds(InputOutputArray _image, InputArrayOfArrays _corners,
InputArray _ids, Scalar borderColor) {
CV_Assert(_image.getMat().total() != 0 &&
(_image.getMat().channels() == 1 || _image.getMat().channels() == 3));
CV_Assert((_corners.total() == _ids.total()) || _ids.total() == 0);
// calculate colors
Scalar textColor, cornerColor;
textColor = cornerColor = borderColor;
swap(textColor.val[0], textColor.val[1]); // text color just sawp G and R
swap(cornerColor.val[1], cornerColor.val[2]); // corner color just sawp G and B
int nMarkers = (int)_corners.total();
for(int i = 0; i < nMarkers; i++) {
Mat currentMarker = _corners.getMat(i);
CV_Assert(currentMarker.total() == 4 && currentMarker.type() == CV_32FC2);
// draw marker sides
for(int j = 0; j < 4; j++) {
Point2f p0, p1;
p0 = currentMarker.at< Point2f >(j);
p1 = currentMarker.at< Point2f >((j + 1) % 4);
line(_image, p0, p1, borderColor, 1);
}
// draw first corner mark
rectangle(_image, currentMarker.at< Point2f >(0) - Point2f(3, 3),
currentMarker.at< Point2f >(0) + Point2f(3, 3), cornerColor, 1, LINE_AA);
// draw id composed by four numbers
if(_ids.total() != 0) {
Point2f cent(0, 0);
for(int p = 0; p < 4; p++)
cent += currentMarker.at< Point2f >(p);
cent = cent / 4.;
stringstream s;
s << "id=" << _ids.getMat().at< Vec4i >(i);
putText(_image, s.str(), cent, FONT_HERSHEY_SIMPLEX, 0.5, textColor, 2);
}
}
}
}
}

View File

@@ -0,0 +1,494 @@
/*
By downloading, copying, installing or using the software you agree to this
license. If you do not agree to this license, do not download, install,
copy or use the software.
License Agreement
For Open Source Computer Vision Library
(3-clause BSD License)
Copyright (C) 2013, OpenCV Foundation, all rights reserved.
Third party copyrights are property of their respective owners.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the names of the copyright holders nor the names of the 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 copyright holders 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 "precomp.hpp"
#include "opencv2/aruco/dictionary.hpp"
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include "predefined_dictionaries.hpp"
#include "predefined_dictionaries_apriltag.hpp"
#include "opencv2/core/hal/hal.hpp"
namespace cv {
namespace aruco {
using namespace std;
/**
*/
Dictionary::Dictionary(const Ptr<Dictionary> &_dictionary) {
markerSize = _dictionary->markerSize;
maxCorrectionBits = _dictionary->maxCorrectionBits;
bytesList = _dictionary->bytesList.clone();
}
/**
*/
Dictionary::Dictionary(const Mat &_bytesList, int _markerSize, int _maxcorr) {
markerSize = _markerSize;
maxCorrectionBits = _maxcorr;
bytesList = _bytesList;
}
/**
*/
Ptr<Dictionary> Dictionary::create(int nMarkers, int markerSize, int randomSeed) {
const Ptr<Dictionary> baseDictionary = makePtr<Dictionary>();
return create(nMarkers, markerSize, baseDictionary, randomSeed);
}
/**
*/
Ptr<Dictionary> Dictionary::create(int nMarkers, int markerSize,
const Ptr<Dictionary> &baseDictionary, int randomSeed) {
return generateCustomDictionary(nMarkers, markerSize, baseDictionary, randomSeed);
}
/**
*/
Ptr<Dictionary> Dictionary::get(int dict) {
return getPredefinedDictionary(dict);
}
/**
*/
bool Dictionary::identify(const Mat &onlyBits, int &idx, int &rotation,
double maxCorrectionRate) const {
CV_Assert(onlyBits.rows == markerSize && onlyBits.cols == markerSize);
int maxCorrectionRecalculed = int(double(maxCorrectionBits) * maxCorrectionRate);
// get as a byte list
Mat candidateBytes = getByteListFromBits(onlyBits);
idx = -1; // by default, not found
// search closest marker in dict
for(int m = 0; m < bytesList.rows; m++) {
int currentMinDistance = markerSize * markerSize + 1;
int currentRotation = -1;
for(unsigned int r = 0; r < 4; r++) {
int currentHamming = cv::hal::normHamming(
bytesList.ptr(m)+r*candidateBytes.cols,
candidateBytes.ptr(),
candidateBytes.cols);
if(currentHamming < currentMinDistance) {
currentMinDistance = currentHamming;
currentRotation = r;
}
}
// if maxCorrection is fullfilled, return this one
if(currentMinDistance <= maxCorrectionRecalculed) {
idx = m;
rotation = currentRotation;
break;
}
}
return idx != -1;
}
/**
*/
int Dictionary::getDistanceToId(InputArray bits, int id, bool allRotations) const {
CV_Assert(id >= 0 && id < bytesList.rows);
unsigned int nRotations = 4;
if(!allRotations) nRotations = 1;
Mat candidateBytes = getByteListFromBits(bits.getMat());
int currentMinDistance = int(bits.total() * bits.total());
for(unsigned int r = 0; r < nRotations; r++) {
int currentHamming = cv::hal::normHamming(
bytesList.ptr(id) + r*candidateBytes.cols,
candidateBytes.ptr(),
candidateBytes.cols);
if(currentHamming < currentMinDistance) {
currentMinDistance = currentHamming;
}
}
return currentMinDistance;
}
/**
* @brief Draw a canonical marker image
*/
void Dictionary::drawMarker(int id, int sidePixels, OutputArray _img, int borderBits) const {
CV_Assert(sidePixels >= (markerSize + 2*borderBits));
CV_Assert(id < bytesList.rows);
CV_Assert(borderBits > 0);
_img.create(sidePixels, sidePixels, CV_8UC1);
// create small marker with 1 pixel per bin
Mat tinyMarker(markerSize + 2 * borderBits, markerSize + 2 * borderBits, CV_8UC1,
Scalar::all(0));
Mat innerRegion = tinyMarker.rowRange(borderBits, tinyMarker.rows - borderBits)
.colRange(borderBits, tinyMarker.cols - borderBits);
// put inner bits
Mat bits = 255 * getBitsFromByteList(bytesList.rowRange(id, id + 1), markerSize);
CV_Assert(innerRegion.total() == bits.total());
bits.copyTo(innerRegion);
// resize tiny marker to output size
cv::resize(tinyMarker, _img.getMat(), _img.getMat().size(), 0, 0, INTER_NEAREST);
}
/**
* @brief Transform matrix of bits to list of bytes in the 4 rotations
*/
Mat Dictionary::getByteListFromBits(const Mat &bits) {
// integer ceil
int nbytes = (bits.cols * bits.rows + 8 - 1) / 8;
Mat candidateByteList(1, nbytes, CV_8UC4, Scalar::all(0));
unsigned char currentBit = 0;
int currentByte = 0;
// the 4 rotations
uchar* rot0 = candidateByteList.ptr();
uchar* rot1 = candidateByteList.ptr() + 1*nbytes;
uchar* rot2 = candidateByteList.ptr() + 2*nbytes;
uchar* rot3 = candidateByteList.ptr() + 3*nbytes;
for(int row = 0; row < bits.rows; row++) {
for(int col = 0; col < bits.cols; col++) {
// circular shift
rot0[currentByte] <<= 1;
rot1[currentByte] <<= 1;
rot2[currentByte] <<= 1;
rot3[currentByte] <<= 1;
// set bit
rot0[currentByte] |= bits.at<uchar>(row, col);
rot1[currentByte] |= bits.at<uchar>(col, bits.cols - 1 - row);
rot2[currentByte] |= bits.at<uchar>(bits.rows - 1 - row, bits.cols - 1 - col);
rot3[currentByte] |= bits.at<uchar>(bits.rows - 1 - col, row);
currentBit++;
if(currentBit == 8) {
// next byte
currentBit = 0;
currentByte++;
}
}
}
return candidateByteList;
}
/**
* @brief Transform list of bytes to matrix of bits
*/
Mat Dictionary::getBitsFromByteList(const Mat &byteList, int markerSize) {
CV_Assert(byteList.total() > 0 &&
byteList.total() >= (unsigned int)markerSize * markerSize / 8 &&
byteList.total() <= (unsigned int)markerSize * markerSize / 8 + 1);
Mat bits(markerSize, markerSize, CV_8UC1, Scalar::all(0));
unsigned char base2List[] = { 128, 64, 32, 16, 8, 4, 2, 1 };
int currentByteIdx = 0;
// we only need the bytes in normal rotation
unsigned char currentByte = byteList.ptr()[0];
int currentBit = 0;
for(int row = 0; row < bits.rows; row++) {
for(int col = 0; col < bits.cols; col++) {
if(currentByte >= base2List[currentBit]) {
bits.at< unsigned char >(row, col) = 1;
currentByte -= base2List[currentBit];
}
currentBit++;
if(currentBit == 8) {
currentByteIdx++;
currentByte = byteList.ptr()[currentByteIdx];
// if not enough bits for one more byte, we are in the end
// update bit position accordingly
if(8 * (currentByteIdx + 1) > (int)bits.total())
currentBit = 8 * (currentByteIdx + 1) - (int)bits.total();
else
currentBit = 0; // ok, bits enough for next byte
}
}
}
return bits;
}
// DictionaryData constructors calls
const Dictionary DICT_ARUCO_DATA = Dictionary(Mat(1024, (5*5 + 7)/8, CV_8UC4, (uchar*)DICT_ARUCO_BYTES), 5, 0);
const Dictionary DICT_4X4_50_DATA = Dictionary(Mat(50, (4*4 + 7)/8, CV_8UC4, (uchar*)DICT_4X4_1000_BYTES), 4, 1);
const Dictionary DICT_4X4_100_DATA = Dictionary(Mat(100, (4*4 + 7)/8, CV_8UC4, (uchar*)DICT_4X4_1000_BYTES), 4, 1);
const Dictionary DICT_4X4_250_DATA = Dictionary(Mat(250, (4*4 + 7)/8, CV_8UC4, (uchar*)DICT_4X4_1000_BYTES), 4, 1);
const Dictionary DICT_4X4_1000_DATA = Dictionary(Mat(1000, (4*4 + 7)/8, CV_8UC4, (uchar*)DICT_4X4_1000_BYTES), 4, 0);
const Dictionary DICT_5X5_50_DATA = Dictionary(Mat(50, (5*5 + 7)/8, CV_8UC4, (uchar*)DICT_5X5_1000_BYTES), 5, 3);
const Dictionary DICT_5X5_100_DATA = Dictionary(Mat(100, (5*5 + 7)/8, CV_8UC4, (uchar*)DICT_5X5_1000_BYTES), 5, 3);
const Dictionary DICT_5X5_250_DATA = Dictionary(Mat(250, (5*5 + 7)/8, CV_8UC4, (uchar*)DICT_5X5_1000_BYTES), 5, 2);
const Dictionary DICT_5X5_1000_DATA = Dictionary(Mat(1000, (5*5 + 7)/8, CV_8UC4, (uchar*)DICT_5X5_1000_BYTES), 5, 2);
const Dictionary DICT_6X6_50_DATA = Dictionary(Mat(50, (6*6 + 7)/8 ,CV_8UC4, (uchar*)DICT_6X6_1000_BYTES), 6, 6);
const Dictionary DICT_6X6_100_DATA = Dictionary(Mat(100, (6*6 + 7)/8 ,CV_8UC4, (uchar*)DICT_6X6_1000_BYTES), 6, 5);
const Dictionary DICT_6X6_250_DATA = Dictionary(Mat(250, (6*6 + 7)/8 ,CV_8UC4, (uchar*)DICT_6X6_1000_BYTES), 6, 5);
const Dictionary DICT_6X6_1000_DATA = Dictionary(Mat(1000, (6*6 + 7)/8 ,CV_8UC4, (uchar*)DICT_6X6_1000_BYTES), 6, 4);
const Dictionary DICT_7X7_50_DATA = Dictionary(Mat(50, (7*7 + 7)/8 ,CV_8UC4, (uchar*)DICT_7X7_1000_BYTES), 7, 9);
const Dictionary DICT_7X7_100_DATA = Dictionary(Mat(100, (7*7 + 7)/8 ,CV_8UC4, (uchar*)DICT_7X7_1000_BYTES), 7, 8);
const Dictionary DICT_7X7_250_DATA = Dictionary(Mat(250, (7*7 + 7)/8 ,CV_8UC4, (uchar*)DICT_7X7_1000_BYTES), 7, 8);
const Dictionary DICT_7X7_1000_DATA = Dictionary(Mat(1000, (7*7 + 7)/8 ,CV_8UC4, (uchar*)DICT_7X7_1000_BYTES), 7, 6);
const Dictionary DICT_APRILTAG_16h5_DATA = Dictionary(Mat(30, (4*4 + 7)/8, CV_8UC4, (uchar*)DICT_APRILTAG_16h5_BYTES), 4, 0);
const Dictionary DICT_APRILTAG_25h9_DATA = Dictionary(Mat(35, (5*5 + 7)/8, CV_8UC4, (uchar*)DICT_APRILTAG_25h9_BYTES), 5, 0);
const Dictionary DICT_APRILTAG_36h10_DATA = Dictionary(Mat(2320, (6*6 + 7)/8, CV_8UC4, (uchar*)DICT_APRILTAG_36h10_BYTES), 6, 0);
const Dictionary DICT_APRILTAG_36h11_DATA = Dictionary(Mat(587, (6*6 + 7)/8, CV_8UC4, (uchar*)DICT_APRILTAG_36h11_BYTES), 6, 0);
Ptr<Dictionary> getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME name) {
switch(name) {
case DICT_ARUCO_ORIGINAL:
return makePtr<Dictionary>(DICT_ARUCO_DATA);
case DICT_4X4_50:
return makePtr<Dictionary>(DICT_4X4_50_DATA);
case DICT_4X4_100:
return makePtr<Dictionary>(DICT_4X4_100_DATA);
case DICT_4X4_250:
return makePtr<Dictionary>(DICT_4X4_250_DATA);
case DICT_4X4_1000:
return makePtr<Dictionary>(DICT_4X4_1000_DATA);
case DICT_5X5_50:
return makePtr<Dictionary>(DICT_5X5_50_DATA);
case DICT_5X5_100:
return makePtr<Dictionary>(DICT_5X5_100_DATA);
case DICT_5X5_250:
return makePtr<Dictionary>(DICT_5X5_250_DATA);
case DICT_5X5_1000:
return makePtr<Dictionary>(DICT_5X5_1000_DATA);
case DICT_6X6_50:
return makePtr<Dictionary>(DICT_6X6_50_DATA);
case DICT_6X6_100:
return makePtr<Dictionary>(DICT_6X6_100_DATA);
case DICT_6X6_250:
return makePtr<Dictionary>(DICT_6X6_250_DATA);
case DICT_6X6_1000:
return makePtr<Dictionary>(DICT_6X6_1000_DATA);
case DICT_7X7_50:
return makePtr<Dictionary>(DICT_7X7_50_DATA);
case DICT_7X7_100:
return makePtr<Dictionary>(DICT_7X7_100_DATA);
case DICT_7X7_250:
return makePtr<Dictionary>(DICT_7X7_250_DATA);
case DICT_7X7_1000:
return makePtr<Dictionary>(DICT_7X7_1000_DATA);
case DICT_APRILTAG_16h5:
return makePtr<Dictionary>(DICT_APRILTAG_16h5_DATA);
case DICT_APRILTAG_25h9:
return makePtr<Dictionary>(DICT_APRILTAG_25h9_DATA);
case DICT_APRILTAG_36h10:
return makePtr<Dictionary>(DICT_APRILTAG_36h10_DATA);
case DICT_APRILTAG_36h11:
return makePtr<Dictionary>(DICT_APRILTAG_36h11_DATA);
}
return makePtr<Dictionary>(DICT_4X4_50_DATA);
}
Ptr<Dictionary> getPredefinedDictionary(int dict) {
return getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME(dict));
}
/**
* @brief Generates a random marker Mat of size markerSize x markerSize
*/
static Mat _generateRandomMarker(int markerSize, RNG &rng) {
Mat marker(markerSize, markerSize, CV_8UC1, Scalar::all(0));
for(int i = 0; i < markerSize; i++) {
for(int j = 0; j < markerSize; j++) {
unsigned char bit = (unsigned char) (rng.uniform(0,2));
marker.at< unsigned char >(i, j) = bit;
}
}
return marker;
}
/**
* @brief Calculate selfDistance of the codification of a marker Mat. Self distance is the Hamming
* distance of the marker to itself in the other rotations.
* See S. Garrido-Jurado, R. Muñoz-Salinas, F. J. Madrid-Cuevas, and M. J. Marín-Jiménez. 2014.
* "Automatic generation and detection of highly reliable fiducial markers under occlusion".
* Pattern Recogn. 47, 6 (June 2014), 2280-2292. DOI=10.1016/j.patcog.2014.01.005
*/
static int _getSelfDistance(const Mat &marker) {
Mat bytes = Dictionary::getByteListFromBits(marker);
int minHamming = (int)marker.total() + 1;
for(int r = 1; r < 4; r++) {
int currentHamming = cv::hal::normHamming(bytes.ptr(), bytes.ptr() + bytes.cols*r, bytes.cols);
if(currentHamming < minHamming) minHamming = currentHamming;
}
return minHamming;
}
/**
*/
Ptr<Dictionary> generateCustomDictionary(int nMarkers, int markerSize,
const Ptr<Dictionary> &baseDictionary, int randomSeed) {
RNG rng((uint64)(randomSeed));
Ptr<Dictionary> out = makePtr<Dictionary>();
out->markerSize = markerSize;
// theoretical maximum intermarker distance
// See S. Garrido-Jurado, R. Muñoz-Salinas, F. J. Madrid-Cuevas, and M. J. Marín-Jiménez. 2014.
// "Automatic generation and detection of highly reliable fiducial markers under occlusion".
// Pattern Recogn. 47, 6 (June 2014), 2280-2292. DOI=10.1016/j.patcog.2014.01.005
int C = (int)std::floor(float(markerSize * markerSize) / 4.f);
int tau = 2 * (int)std::floor(float(C) * 4.f / 3.f);
// if baseDictionary is provided, calculate its intermarker distance
if(baseDictionary->bytesList.rows > 0) {
CV_Assert(baseDictionary->markerSize == markerSize);
out->bytesList = baseDictionary->bytesList.clone();
int minDistance = markerSize * markerSize + 1;
for(int i = 0; i < out->bytesList.rows; i++) {
Mat markerBytes = out->bytesList.rowRange(i, i + 1);
Mat markerBits = Dictionary::getBitsFromByteList(markerBytes, markerSize);
minDistance = min(minDistance, _getSelfDistance(markerBits));
for(int j = i + 1; j < out->bytesList.rows; j++) {
minDistance = min(minDistance, out->getDistanceToId(markerBits, j));
}
}
tau = minDistance;
}
// current best option
int bestTau = 0;
Mat bestMarker;
// after these number of unproductive iterations, the best option is accepted
const int maxUnproductiveIterations = 5000;
int unproductiveIterations = 0;
while(out->bytesList.rows < nMarkers) {
Mat currentMarker = _generateRandomMarker(markerSize, rng);
int selfDistance = _getSelfDistance(currentMarker);
int minDistance = selfDistance;
// if self distance is better or equal than current best option, calculate distance
// to previous accepted markers
if(selfDistance >= bestTau) {
for(int i = 0; i < out->bytesList.rows; i++) {
int currentDistance = out->getDistanceToId(currentMarker, i);
minDistance = min(currentDistance, minDistance);
if(minDistance <= bestTau) {
break;
}
}
}
// if distance is high enough, accept the marker
if(minDistance >= tau) {
unproductiveIterations = 0;
bestTau = 0;
Mat bytes = Dictionary::getByteListFromBits(currentMarker);
out->bytesList.push_back(bytes);
} else {
unproductiveIterations++;
// if distance is not enough, but is better than the current best option
if(minDistance > bestTau) {
bestTau = minDistance;
bestMarker = currentMarker;
}
// if number of unproductive iterarions has been reached, accept the current best option
if(unproductiveIterations == maxUnproductiveIterations) {
unproductiveIterations = 0;
tau = bestTau;
bestTau = 0;
Mat bytes = Dictionary::getByteListFromBits(bestMarker);
out->bytesList.push_back(bytes);
}
}
}
// update the maximum number of correction bits for the generated dictionary
out->maxCorrectionBits = (tau - 1) / 2;
return out;
}
/**
*/
Ptr<Dictionary> generateCustomDictionary(int nMarkers, int markerSize, int randomSeed) {
Ptr<Dictionary> baseDictionary = makePtr<Dictionary>();
return generateCustomDictionary(nMarkers, markerSize, baseDictionary, randomSeed);
}
}
}

49
aruco_pose/vendor/aruco/src/precomp.hpp vendored Normal file
View File

@@ -0,0 +1,49 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of the copyright holders may not 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 Intel Corporation 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.
//
//M*/
#ifndef __OPENCV_CCALIB_PRECOMP__
#define __OPENCV_CCALIB_PRECOMP__
#include <opencv2/core.hpp>
#include <opencv2/calib3d.hpp>
#include <vector>
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,133 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2013-2016, The Regents of The University of Michigan.
//
// This software was developed in the APRIL Robotics Lab under the
// direction of Edwin Olson, ebolson@umich.edu. This software may be
// available under alternative licensing terms; contact the address above.
//
// The views and conclusions contained in the software and documentation are those
// of the authors and should not be interpreted as representing official policies,
// either expressed or implied, of the Regents of The University of Michigan.
#ifndef _OPENCV_UNIONFIND_HPP_
#define _OPENCV_UNIONFIND_HPP_
#include <stdint.h>
#include <stdlib.h>
namespace cv {
namespace aruco {
typedef struct unionfind unionfind_t;
struct unionfind{
uint32_t maxid;
struct ufrec *data;
};
struct ufrec{
// the parent of this node. If a node's parent is its own index,
// then it is a root.
uint32_t parent;
// for the root of a connected component, the number of components
// connected to it. For intermediate values, it's not meaningful.
uint32_t size;
};
static inline unionfind_t *unionfind_create(uint32_t maxid){
unionfind_t *uf = (unionfind_t*) calloc(1, sizeof(unionfind_t));
uf->maxid = maxid;
uf->data = (struct ufrec*) malloc((maxid+1) * sizeof(struct ufrec));
for (unsigned int i = 0; i <= maxid; i++) {
uf->data[i].size = 1;
uf->data[i].parent = i;
}
return uf;
}
static inline void unionfind_destroy(unionfind_t *uf){
free(uf->data);
free(uf);
}
/*
static inline uint32_t unionfind_get_representative(unionfind_t *uf, uint32_t id)
{
// base case: a node is its own parent
if (uf->data[id].parent == id)
return id;
// otherwise, recurse
uint32_t root = unionfind_get_representative(uf, uf->data[id].parent);
// short circuit the path. [XXX This write prevents tail recursion]
uf->data[id].parent = root;
return root;
}
*/
// this one seems to be every-so-slightly faster than the recursive
// version above.
static inline uint32_t unionfind_get_representative(unionfind_t *uf, uint32_t id){
uint32_t root = id;
// chase down the root
while (uf->data[root].parent != root) {
root = uf->data[root].parent;
}
// go back and collapse the tree.
//
// XXX: on some of our workloads that have very shallow trees
// (e.g. image segmentation), we are actually faster not doing
// this...
while (uf->data[id].parent != root) {
uint32_t tmp = uf->data[id].parent;
uf->data[id].parent = root;
id = tmp;
}
return root;
}
static inline uint32_t unionfind_get_set_size(unionfind_t *uf, uint32_t id){
uint32_t repid = unionfind_get_representative(uf, id);
return uf->data[repid].size;
}
static inline uint32_t unionfind_connect(unionfind_t *uf, uint32_t aid, uint32_t bid){
uint32_t aroot = unionfind_get_representative(uf, aid);
uint32_t broot = unionfind_get_representative(uf, bid);
if (aroot == broot)
return aroot;
// we don't perform "union by rank", but we perform a similar
// operation (but probably without the same asymptotic guarantee):
// We join trees based on the number of *elements* (as opposed to
// rank) contained within each tree. I.e., we use size as a proxy
// for rank. In my testing, it's often *faster* to use size than
// rank, perhaps because the rank of the tree isn't that critical
// if there are very few nodes in it.
uint32_t asize = uf->data[aroot].size;
uint32_t bsize = uf->data[broot].size;
// optimization idea: We could shortcut some or all of the tree
// that is grafted onto the other tree. Pro: those nodes were just
// read and so are probably in cache. Con: it might end up being
// wasted effort -- the tree might be grafted onto another tree in
// a moment!
if (asize > bsize) {
uf->data[broot].parent = aroot;
uf->data[aroot].size += bsize;
return aroot;
} else {
uf->data[aroot].parent = broot;
uf->data[broot].size += asize;
return broot;
}
}
}}
#endif

150
aruco_pose/vendor/aruco/src/zarray.hpp vendored Normal file
View File

@@ -0,0 +1,150 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2013-2016, The Regents of The University of Michigan.
//
// This software was developed in the APRIL Robotics Lab under the
// direction of Edwin Olson, ebolson@umich.edu. This software may be
// available under alternative licensing terms; contact the address above.
//
// The views and conclusions contained in the software and documentation are those
// of the authors and should not be interpreted as representing official policies,
// either expressed or implied, of the Regents of The University of Michigan.
#ifndef _OPENCV_ZARRAY_HPP_
#define _OPENCV_ZARRAY_HPP_
#include <stdlib.h>
#include <string.h>
namespace cv {
namespace aruco {
struct sQuad{
float p[4][2]; // corners
};
/**
* Defines a structure which acts as a resize-able array ala Java's ArrayList.
*/
typedef struct zarray zarray_t;
struct zarray{
size_t el_sz; // size of each element
int size; // how many elements?
int alloc; // we've allocated storage for how many elements?
char *data;
};
/**
* Creates and returns a variable array structure capable of holding elements of
* the specified size. It is the caller's responsibility to call zarray_destroy()
* on the returned array when it is no longer needed.
*/
inline static zarray_t *_zarray_create(size_t el_sz){
zarray_t *za = (zarray_t*) calloc(1, sizeof(zarray_t));
za->el_sz = el_sz;
return za;
}
/**
* Frees all resources associated with the variable array structure which was
* created by zarray_create(). After calling, 'za' will no longer be valid for storage.
*/
inline static void _zarray_destroy(zarray_t *za){
if (za == NULL)
return;
if (za->data != NULL)
free(za->data);
memset(za, 0, sizeof(zarray_t));
free(za);
}
/**
* Retrieves the number of elements currently being contained by the passed
* array, which may be different from its capacity. The index of the last element
* in the array will be one less than the returned value.
*/
inline static int _zarray_size(const zarray_t *za){
return za->size;
}
/**
* Allocates enough internal storage in the supplied variable array structure to
* guarantee that the supplied number of elements (capacity) can be safely stored.
*/
inline static void _zarray_ensure_capacity(zarray_t *za, int capacity){
if (capacity <= za->alloc)
return;
while (za->alloc < capacity) {
za->alloc *= 2;
if (za->alloc < 8)
za->alloc = 8;
}
za->data = (char*) realloc(za->data, za->alloc * za->el_sz);
}
/**
* Adds a new element to the end of the supplied array, and sets its value
* (by copying) from the data pointed to by the supplied pointer 'p'.
* Automatically ensures that enough storage space is available for the new element.
*/
inline static void _zarray_add(zarray_t *za, const void *p){
_zarray_ensure_capacity(za, za->size + 1);
memcpy(&za->data[za->size*za->el_sz], p, za->el_sz);
za->size++;
}
/**
* Retrieves the element from the supplied array located at the zero-based
* index of 'idx' and copies its value into the variable pointed to by the pointer
* 'p'.
*/
inline static void _zarray_get(const zarray_t *za, int idx, void *p){
CV_DbgAssert(idx >= 0);
CV_DbgAssert(idx < za->size);
memcpy(p, &za->data[idx*za->el_sz], za->el_sz);
}
/**
* Similar to zarray_get(), but returns a "live" pointer to the internal
* storage, avoiding a memcpy. This pointer is not valid across
* operations which might move memory around (i.e. zarray_remove_value(),
* zarray_remove_index(), zarray_insert(), zarray_sort(), zarray_clear()).
* 'p' should be a pointer to the pointer which will be set to the internal address.
*/
inline static void _zarray_get_volatile(const zarray_t *za, int idx, void *p){
CV_DbgAssert(idx >= 0);
CV_DbgAssert(idx < za->size);
*((void**) p) = &za->data[idx*za->el_sz];
}
inline static void _zarray_truncate(zarray_t *za, int sz){
za->size = sz;
}
/**
* Sets the value of the current element at index 'idx' by copying its value from
* the data pointed to by 'p'. The previous value of the changed element will be
* copied into the data pointed to by 'outp' if it is not null.
*/
static inline void _zarray_set(zarray_t *za, int idx, const void *p, void *outp){
CV_DbgAssert(idx >= 0);
CV_DbgAssert(idx < za->size);
if (outp != NULL)
memcpy(outp, &za->data[idx*za->el_sz], za->el_sz);
memcpy(&za->data[idx*za->el_sz], p, za->el_sz);
}
}
}
#endif

208
aruco_pose/vendor/aruco/src/zmaxheap.cpp vendored Normal file
View File

@@ -0,0 +1,208 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2013-2016, The Regents of The University of Michigan.
//
// This software was developed in the APRIL Robotics Lab under the
// direction of Edwin Olson, ebolson@umich.edu. This software may be
// available under alternative licensing terms; contact the address above.
//
// The views and conclusions contained in the software and documentation are those
// of the authors and should not be interpreted as representing official policies,
// either expressed or implied, of the Regents of The University of Michigan.
#include "precomp.hpp"
#include "zmaxheap.hpp"
// 0
// 1 2
// 3 4 5 6
// 7 8 9 10 11 12 13 14
//
// Children of node i: 2*i+1, 2*i+2
// Parent of node i: (i-1) / 2
//
// Heap property: a parent is greater than (or equal to) its children.
#define MIN_CAPACITY 16
namespace cv {
namespace aruco {
struct zmaxheap
{
size_t el_sz;
int size;
int alloc;
float *values;
char *data;
void (*swap)(zmaxheap_t *heap, int a, int b);
};
static inline void _swap_default(zmaxheap_t *heap, int a, int b)
{
float t = heap->values[a];
heap->values[a] = heap->values[b];
heap->values[b] = t;
cv::AutoBuffer<char> tmp(heap->el_sz);
/* NOTE: OpenCV v<3.3 does not have .data() member for AutoBuffer */
memcpy(tmp, &heap->data[a*heap->el_sz], heap->el_sz);
memcpy(&heap->data[a*heap->el_sz], &heap->data[b*heap->el_sz], heap->el_sz);
memcpy(&heap->data[b*heap->el_sz], tmp, heap->el_sz);
}
static inline void _swap_pointer(zmaxheap_t *heap, int a, int b)
{
float t = heap->values[a];
heap->values[a] = heap->values[b];
heap->values[b] = t;
void **pp = (void**) heap->data;
void *tmp = pp[a];
pp[a] = pp[b];
pp[b] = tmp;
}
zmaxheap_t *zmaxheap_create(size_t el_sz)
{
zmaxheap_t *heap = (zmaxheap_t*)calloc(1, sizeof(zmaxheap_t));
heap->el_sz = el_sz;
heap->swap = _swap_default;
if (el_sz == sizeof(void*))
heap->swap = _swap_pointer;
return heap;
}
void zmaxheap_destroy(zmaxheap_t *heap)
{
free(heap->values);
free(heap->data);
memset(heap, 0, sizeof(zmaxheap_t));
free(heap);
}
static void _zmaxheap_ensure_capacity(zmaxheap_t *heap, int capacity)
{
if (heap->alloc >= capacity)
return;
int newcap = heap->alloc;
while (newcap < capacity) {
if (newcap < MIN_CAPACITY) {
newcap = MIN_CAPACITY;
continue;
}
newcap *= 2;
}
heap->values = (float*)realloc(heap->values, newcap * sizeof(float));
heap->data = (char*)realloc(heap->data, newcap * heap->el_sz);
heap->alloc = newcap;
}
void zmaxheap_add(zmaxheap_t *heap, void *p, float v)
{
_zmaxheap_ensure_capacity(heap, heap->size + 1);
int idx = heap->size;
heap->values[idx] = v;
memcpy(&heap->data[idx*heap->el_sz], p, heap->el_sz);
heap->size++;
while (idx > 0) {
int parent = (idx - 1) / 2;
// we're done!
if (heap->values[parent] >= v)
break;
// else, swap and recurse upwards.
heap->swap(heap, idx, parent);
idx = parent;
}
}
// Removes the item in the heap at the given index. Returns 1 if the
// item existed. 0 Indicates an invalid idx (heap is smaller than
// idx). This is mostly intended to be used by zmaxheap_remove_max.
static int zmaxheap_remove_index(zmaxheap_t *heap, int idx, void *p, float *v)
{
if (idx >= heap->size)
return 0;
// copy out the requested element from the heap.
if (v != NULL)
*v = heap->values[idx];
if (p != NULL)
memcpy(p, &heap->data[idx*heap->el_sz], heap->el_sz);
heap->size--;
// If this element is already the last one, then there's nothing
// for us to do.
if (idx == heap->size)
return 1;
// copy last element to first element. (which probably upsets
// the heap property).
heap->values[idx] = heap->values[heap->size];
memcpy(&heap->data[idx*heap->el_sz], &heap->data[heap->el_sz * heap->size], heap->el_sz);
// now fix the heap. Note, as we descend, we're "pushing down"
// the same node the entire time. Thus, while the index of the
// parent might change, the parent_score doesn't.
int parent = idx;
float parent_score = heap->values[idx];
// descend, fixing the heap.
while (parent < heap->size) {
int left = 2*parent + 1;
int right = left + 1;
// assert(parent_score == heap->values[parent]);
float left_score = (left < heap->size) ? heap->values[left] : -INFINITY;
float right_score = (right < heap->size) ? heap->values[right] : -INFINITY;
// put the biggest of (parent, left, right) as the parent.
// already okay?
if (parent_score >= left_score && parent_score >= right_score)
break;
// if we got here, then one of the children is bigger than the parent.
if (left_score >= right_score) {
CV_Assert(left < heap->size);
heap->swap(heap, parent, left);
parent = left;
} else {
// right_score can't be less than left_score if right_score is -INFINITY.
CV_Assert(right < heap->size);
heap->swap(heap, parent, right);
parent = right;
}
}
return 1;
}
int zmaxheap_remove_max(zmaxheap_t *heap, void *p, float *v)
{
return zmaxheap_remove_index(heap, 0, p, v);
}
}}

View File

@@ -0,0 +1,42 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2013-2016, The Regents of The University of Michigan.
//
// This software was developed in the APRIL Robotics Lab under the
// direction of Edwin Olson, ebolson@umich.edu. This software may be
// available under alternative licensing terms; contact the address above.
//
// The views and conclusions contained in the software and documentation are those
// of the authors and should not be interpreted as representing official policies,
// either expressed or implied, of the Regents of The University of Michigan.
#ifndef _OPENCV_ZMAXHEAP_HPP_
#define _OPENCV_ZMAXHEAP_HPP_
#include <stdlib.h>
#include <string.h>
#include <math.h>
namespace cv {
namespace aruco {
typedef struct zmaxheap zmaxheap_t;
typedef struct zmaxheap_iterator zmaxheap_iterator_t;
struct zmaxheap_iterator {
zmaxheap_t *heap;
int in, out;
};
zmaxheap_t *zmaxheap_create(size_t el_sz);
void zmaxheap_destroy(zmaxheap_t *heap);
void zmaxheap_add(zmaxheap_t *heap, void *p, float v);
// returns 0 if the heap is empty, so you can do
// while (zmaxheap_remove_max(...)) { }
int zmaxheap_remove_max(zmaxheap_t *heap, void *p, float *v);
}}
#endif

View File

@@ -1,7 +1,6 @@
[Unit]
Description=Clever ROS package
Requires=roscore.service
After=network.target
[Service]
User=pi

View File

@@ -1,531 +1,531 @@
actionlib:
debian:
stretch: [ros-kinetic-actionlib]
buster: [ros-kinetic-actionlib]
actionlib_msgs:
debian:
stretch: [ros-kinetic-actionlib-msgs]
buster: [ros-kinetic-actionlib-msgs]
angles:
debian:
stretch: [ros-kinetic-angles]
buster: [ros-kinetic-angles]
async_web_server_cpp:
debian:
stretch: [ros-kinetic-async-web-server-cpp]
buster: [ros-kinetic-async-web-server-cpp]
bond:
debian:
stretch: [ros-kinetic-bond]
buster: [ros-kinetic-bond]
bondcpp:
debian:
stretch: [ros-kinetic-bondcpp]
buster: [ros-kinetic-bondcpp]
bondpy:
debian:
stretch: [ros-kinetic-bondpy]
buster: [ros-kinetic-bondpy]
camera_calibration_parsers:
debian:
stretch: [ros-kinetic-camera-calibration-parsers]
buster: [ros-kinetic-camera-calibration-parsers]
camera_info_manager:
debian:
stretch: [ros-kinetic-camera-info-manager]
buster: [ros-kinetic-camera-info-manager]
catkin:
debian:
stretch: [ros-kinetic-catkin]
buster: [ros-kinetic-catkin]
class_loader:
debian:
stretch: [ros-kinetic-class-loader]
buster: [ros-kinetic-class-loader]
cmake_modules:
debian:
stretch: [ros-kinetic-cmake-modules]
buster: [ros-kinetic-cmake-modules]
cpp_common:
debian:
stretch: [ros-kinetic-cpp-common]
buster: [ros-kinetic-cpp-common]
cv_bridge:
debian:
stretch: [ros-kinetic-cv-bridge]
buster: [ros-kinetic-cv-bridge]
cv_camera:
debian:
stretch: [ros-kinetic-cv-camera=0.3.1-0stretch]
buster: [ros-kinetic-cv-camera=0.3.1-0buster]
diagnostic_msgs:
debian:
stretch: [ros-kinetic-diagnostic-msgs]
buster: [ros-kinetic-diagnostic-msgs]
diagnostic_updater:
debian:
stretch: [ros-kinetic-diagnostic-updater]
buster: [ros-kinetic-diagnostic-updater]
eigen_conversions:
debian:
stretch: [ros-kinetic-eigen-conversions]
buster: [ros-kinetic-eigen-conversions]
gencpp:
debian:
stretch: [ros-kinetic-gencpp]
buster: [ros-kinetic-gencpp]
geneus:
debian:
stretch: [ros-kinetic-geneus]
buster: [ros-kinetic-geneus]
genlisp:
debian:
stretch: [ros-kinetic-genlisp]
buster: [ros-kinetic-genlisp]
genmsg:
debian:
stretch: [ros-kinetic-genmsg]
buster: [ros-kinetic-genmsg]
gennodejs:
debian:
stretch: [ros-kinetic-gennodejs]
buster: [ros-kinetic-gennodejs]
genpy:
debian:
stretch: [ros-kinetic-genpy]
buster: [ros-kinetic-genpy]
geographic_msgs:
debian:
stretch: [ros-kinetic-geographic-msgs]
buster: [ros-kinetic-geographic-msgs]
geometry_msgs:
debian:
stretch: [ros-kinetic-geometry-msgs]
buster: [ros-kinetic-geometry-msgs]
image_transport:
debian:
stretch: [ros-kinetic-image-transport]
buster: [ros-kinetic-image-transport]
libmavconn:
debian:
stretch: [ros-kinetic-libmavconn]
buster: [ros-kinetic-libmavconn]
lxml:
debian:
stretch: [python-lxml=3.7.1-1]
buster: [python-lxml=3.7.1-1]
mavlink:
debian:
stretch: [ros-kinetic-mavlink]
buster: [ros-kinetic-mavlink]
mavros:
debian:
stretch: [ros-kinetic-mavros]
buster: [ros-kinetic-mavros]
mavros_msgs:
debian:
stretch: [ros-kinetic-mavros-msgs]
buster: [ros-kinetic-mavros-msgs]
mavros_extras:
debian:
stretch: [ros-kinetic-mavros-extras]
buster: [ros-kinetic-mavros-extras]
message_filters:
debian:
stretch: [ros-kinetic-message-filters]
buster: [ros-kinetic-message-filters]
message_generation:
debian:
stretch: [ros-kinetic-message-generation]
buster: [ros-kinetic-message-generation]
message_runtime:
debian:
stretch: [ros-kinetic-message-runtime]
buster: [ros-kinetic-message-runtime]
mjpg-streamer:
debian:
stretch: [mjpg-streamer=2.0]
buster: [mjpg-streamer=2.0]
mk:
debian:
stretch: [ros-kinetic-mk]
buster: [ros-kinetic-mk]
nav_msgs:
debian:
stretch: [ros-kinetic-nav-msgs]
buster: [ros-kinetic-nav-msgs]
nodelet:
debian:
stretch: [ros-kinetic-nodelet]
buster: [ros-kinetic-nodelet]
opencv3:
debian:
stretch: [ros-kinetic-opencv3]
buster: [ros-kinetic-opencv3]
orocos_kdl:
debian:
stretch: [ros-kinetic-orocos-kdl]
buster: [ros-kinetic-orocos-kdl]
pluginlib:
debian:
stretch: [ros-kinetic-pluginlib]
buster: [ros-kinetic-pluginlib]
python_orocos_kdl:
debian:
stretch: [ros-kinetic-python-orocos-kdl]
buster: [ros-kinetic-python-orocos-kdl]
ros:
debian:
stretch: [ros-kinetic-ros]
buster: [ros-kinetic-ros]
ros_comm:
debian:
stretch: [ros-kinetic-ros-comm]
buster: [ros-kinetic-ros-comm]
ros_environment:
debian:
stretch: [ros-kinetic-ros-environment]
buster: [ros-kinetic-ros-environment]
rosapi:
debian:
stretch: [ros-kinetic-rosapi]
buster: [ros-kinetic-rosapi]
rosauth:
debian:
stretch: [ros-kinetic-rosauth]
buster: [ros-kinetic-rosauth]
rosbag:
debian:
stretch: [ros-kinetic-rosbag]
buster: [ros-kinetic-rosbag]
rosbag_migration_rule:
debian:
stretch: [ros-kinetic-rosbag-migration-rule]
buster: [ros-kinetic-rosbag-migration-rule]
rosbag_storage:
debian:
stretch: [ros-kinetic-rosbag-storage]
buster: [ros-kinetic-rosbag-storage]
rosbash:
debian:
stretch: [ros-kinetic-rosbash]
buster: [ros-kinetic-rosbash]
rosboost_cfg:
debian:
stretch: [ros-kinetic-rosboost-cfg]
buster: [ros-kinetic-rosboost-cfg]
rosbridge_library:
debian:
stretch: [ros-kinetic-rosbridge-library]
buster: [ros-kinetic-rosbridge-library]
rosbridge_server:
debian:
stretch: [ros-kinetic-rosbridge-server]
buster: [ros-kinetic-rosbridge-server]
rosbuild:
debian:
stretch: [ros-kinetic-rosbuild]
buster: [ros-kinetic-rosbuild]
rosclean:
debian:
stretch: [ros-kinetic-rosclean]
buster: [ros-kinetic-rosclean]
rosconsole:
debian:
stretch: [ros-kinetic-rosconsole]
buster: [ros-kinetic-rosconsole]
rosconsole_bridge:
debian:
stretch: [ros-kinetic-rosconsole-bridge]
buster: [ros-kinetic-rosconsole-bridge]
roscpp:
debian:
stretch: [ros-kinetic-roscpp]
buster: [ros-kinetic-roscpp]
roscpp_serialization:
debian:
stretch: [ros-kinetic-roscpp-serialization]
buster: [ros-kinetic-roscpp-serialization]
roscpp_traits:
debian:
stretch: [ros-kinetic-roscpp-traits]
buster: [ros-kinetic-roscpp-traits]
roscreate:
debian:
stretch: [ros-kinetic-roscreate]
buster: [ros-kinetic-roscreate]
rosgraph:
debian:
stretch: [ros-kinetic-rosgraph]
buster: [ros-kinetic-rosgraph]
rosgraph_msgs:
debian:
stretch: [ros-kinetic-rosgraph-msgs]
buster: [ros-kinetic-rosgraph-msgs]
roslang:
debian:
stretch: [ros-kinetic-roslang]
buster: [ros-kinetic-roslang]
roslaunch:
debian:
stretch: [ros-kinetic-roslaunch]
buster: [ros-kinetic-roslaunch]
roslib:
debian:
stretch: [ros-kinetic-roslib]
buster: [ros-kinetic-roslib]
roslint:
debian:
stretch: [ros-kinetic-roslint]
buster: [ros-kinetic-roslint]
roslisp:
debian:
stretch: [ros-kinetic-roslisp]
buster: [ros-kinetic-roslisp]
roslz4:
debian:
stretch: [ros-kinetic-roslz4]
buster: [ros-kinetic-roslz4]
rosmake:
debian:
stretch: [ros-kinetic-rosmake]
buster: [ros-kinetic-rosmake]
rosmaster:
debian:
stretch: [ros-kinetic-rosmaster]
buster: [ros-kinetic-rosmaster]
rosmsg:
debian:
stretch: [ros-kinetic-rosmsg]
buster: [ros-kinetic-rosmsg]
rosnode:
debian:
stretch: [ros-kinetic-rosnode]
buster: [ros-kinetic-rosnode]
rosout:
debian:
stretch: [ros-kinetic-rosout]
buster: [ros-kinetic-rosout]
rospack:
debian:
stretch: [ros-kinetic-rospack]
buster: [ros-kinetic-rospack]
rosparam:
debian:
stretch: [ros-kinetic-rosparam]
buster: [ros-kinetic-rosparam]
rospy:
debian:
stretch: [ros-kinetic-rospy]
buster: [ros-kinetic-rospy]
rospy_tutorials:
debian:
stretch: [ros-kinetic-rospy-tutorials]
buster: [ros-kinetic-rospy-tutorials]
rosserial_client:
debian:
stretch: [ros-kinetic-rosserial-client]
buster: [ros-kinetic-rosserial-client]
rosserial_msgs:
debian:
stretch: [ros-kinetic-rosserial-msgs]
buster: [ros-kinetic-rosserial-msgs]
rosserial_python:
debian:
stretch: [ros-kinetic-rosserial-python]
buster: [ros-kinetic-rosserial-python]
rosservice:
debian:
stretch: [ros-kinetic-rosservice]
buster: [ros-kinetic-rosservice]
rostest:
debian:
stretch: [ros-kinetic-rostest]
buster: [ros-kinetic-rostest]
rostime:
debian:
stretch: [ros-kinetic-rostime]
buster: [ros-kinetic-rostime]
rostopic:
debian:
stretch: [ros-kinetic-rostopic]
buster: [ros-kinetic-rostopic]
rosunit:
debian:
stretch: [ros-kinetic-rosunit]
buster: [ros-kinetic-rosunit]
roswtf:
debian:
stretch: [ros-kinetic-roswtf]
buster: [ros-kinetic-roswtf]
sensor_msgs:
debian:
stretch: [ros-kinetic-sensor-msgs]
buster: [ros-kinetic-sensor-msgs]
smclib:
debian:
stretch: [ros-kinetic-smclib]
buster: [ros-kinetic-smclib]
std_msgs:
debian:
stretch: [ros-kinetic-std-msgs]
buster: [ros-kinetic-std-msgs]
std_srvs:
debian:
stretch: [ros-kinetic-std-srvs]
buster: [ros-kinetic-std-srvs]
stereo_msgs:
debian:
stretch: [ros-kinetic-stereo-msgs]
buster: [ros-kinetic-stereo-msgs]
tf2:
debian:
stretch: [ros-kinetic-tf2]
buster: [ros-kinetic-tf2]
tf2_bullet:
debian:
stretch: [ros-kinetic-tf2-bullet]
buster: [ros-kinetic-tf2-bullet]
tf2_eigen:
debian:
stretch: [ros-kinetic-tf2-eigen]
buster: [ros-kinetic-tf2-eigen]
tf2_geometry_msgs:
debian:
stretch: [ros-kinetic-tf2-geometry-msgs]
buster: [ros-kinetic-tf2-geometry-msgs]
tf2_kdl:
debian:
stretch: [ros-kinetic-tf2-kdl]
buster: [ros-kinetic-tf2-kdl]
tf2_msgs:
debian:
stretch: [ros-kinetic-tf2-msgs]
buster: [ros-kinetic-tf2-msgs]
tf2_py:
debian:
stretch: [ros-kinetic-tf2-py]
buster: [ros-kinetic-tf2-py]
tf2_ros:
debian:
stretch: [ros-kinetic-tf2-ros]
buster: [ros-kinetic-tf2-ros]
tf2_sensor_msgs:
debian:
stretch: [ros-kinetic-tf2-sensor-msgs]
buster: [ros-kinetic-tf2-sensor-msgs]
tf2_tools:
debian:
stretch: [ros-kinetic-tf2-tools]
buster: [ros-kinetic-tf2-tools]
tf:
debian:
stretch: [ros-kinetic-tf]
buster: [ros-kinetic-tf]
topic_tools:
debian:
stretch: [ros-kinetic-topic-tools]
buster: [ros-kinetic-topic-tools]
trajectory_msgs:
debian:
stretch: [ros-kinetic-trajectory-msgs]
buster: [ros-kinetic-trajectory-msgs]
urdf:
debian:
stretch: [ros-kinetic-urdf]
buster: [ros-kinetic-urdf]
urdf_parser_plugin:
debian:
stretch: [ros-kinetic-urdf-parser-plugin]
buster: [ros-kinetic-urdf-parser-plugin]
uuid_msgs:
debian:
stretch: [ros-kinetic-uuid-msgs]
buster: [ros-kinetic-uuid-msgs]
visualization_msgs:
debian:
stretch: [ros-kinetic-visualization-msgs]
buster: [ros-kinetic-visualization-msgs]
xmlrpcpp:
debian:
stretch: [ros-kinetic-xmlrpcpp]
buster: [ros-kinetic-xmlrpcpp]
boost:
debian:
stretch: [libboost-all-dev]
buster: [libboost-all-dev]
bullet:
debian:
stretch: [libbullet-dev]
buster: [libbullet-dev]
bzip2:
debian:
stretch: [libbz2-dev]
buster: [libbz2-dev]
cmake:
debian:
stretch: [cmake]
buster: [cmake]
cppunit:
debian:
stretch: [libcppunit-dev]
buster: [libcppunit-dev]
eigen:
debian:
stretch: [libeigen3-dev]
buster: [libeigen3-dev]
geographiclib-tools:
debian:
stretch: [geographiclib-tools]
buster: [geographiclib-tools]
geographiclib:
debian:
stretch: [libgeographic-dev]
buster: [libgeographic-dev]
google-mock:
debian:
stretch: [google-mock]
buster: [google-mock]
graphviz:
debian:
stretch: [graphviz]
buster: [graphviz]
gtest:
debian:
stretch: [libgtest-dev]
buster: [libgtest-dev]
libconsole-bridge-dev:
debian:
stretch: [libconsole-bridge-dev]
buster: [libconsole-bridge-dev]
libjpeg:
debian:
stretch: [libjpeg-dev]
buster: [libjpeg-dev]
libpng-dev:
debian:
stretch: [libpng-dev]
buster: [libpng-dev]
libpoco-dev:
debian:
stretch: [libpoco-dev]
buster: [libpoco-dev]
libssl-dev:
debian:
stretch: [libssl-dev]
buster: [libssl-dev]
libtiff-dev:
debian:
stretch: [libtiff5-dev]
buster: [libtiff5-dev]
liburdfdom-dev:
debian:
stretch: [liburdfdom-dev]
buster: [liburdfdom-dev]
liburdfdom-headers-dev:
debian:
stretch: [liburdfdom-headers-dev]
buster: [liburdfdom-headers-dev]
libv4l-dev:
debian:
stretch: [libv4l-dev]
buster: [libv4l-dev]
libvtk-qt:
debian:
stretch: [libvtk6-qt-dev]
buster: [libvtk6-qt-dev]
libwebp-dev:
debian:
stretch: [libwebp-dev]
buster: [libwebp-dev]
log4cxx:
debian:
stretch: [liblog4cxx-dev]
buster: [liblog4cxx-dev]
lz4:
debian:
stretch: [liblz4-dev]
buster: [liblz4-dev]
pkg-config:
debian:
stretch: [pkg-config]
buster: [pkg-config]
protobuf:
debian:
stretch: [libprotobuf10]
buster: [libprotobuf10]
python-bson:
debian:
stretch: [python-bson]
buster: [python-bson]
python-catkin-pkg:
debian:
stretch: [python-catkin-pkg]
buster: [python-catkin-pkg]
python-coverage:
debian:
stretch: [python-coverage]
buster: [python-coverage]
python-defusedxml:
debian:
stretch: [python-defusedxml]
buster: [python-defusedxml]
python-empy:
debian:
stretch: [python-empy]
buster: [python-empy]
python-future:
debian:
stretch: [python-future]
buster: [python-future]
python-imaging:
debian:
stretch: [python-imaging]
buster: [python-imaging]
python-lxml:
debian:
stretch: [python-lxml]
buster: [python-lxml]
python-mock:
debian:
stretch: [python-mock]
buster: [python-mock]
python-netifaces:
debian:
stretch: [python-netifaces]
buster: [python-netifaces]
python-nose:
debian:
stretch: [python-nose]
buster: [python-nose]
python-numpy:
debian:
stretch: [python-numpy]
buster: [python-numpy]
python-paramiko:
debian:
stretch: [python-paramiko]
buster: [python-paramiko]
python-rosdep:
debian:
stretch: [python-rosdep]
buster: [python-rosdep]
python-rospkg:
debian:
stretch: [python-rospkg]
buster: [python-rospkg]
python-serial:
debian:
stretch: [python-serial]
buster: [python-serial]
python-setuptools:
debian:
stretch: [python-setuptools]
buster: [python-setuptools]
python-sip:
debian:
stretch: [python-sip-dev]
buster: [python-sip-dev]
python-tornado:
debian:
stretch: [python-tornado]
buster: [python-tornado]
python-twisted-core:
debian:
stretch: [python-twisted-core]
buster: [python-twisted-core]
python-websocket:
debian:
stretch: [python-websocket]
buster: [python-websocket]
python-wxtools:
debian:
stretch: [python-wxtools]
buster: [python-wxtools]
python-yaml:
debian:
stretch: [python-yaml]
buster: [python-yaml]
python:
debian:
stretch: [python-dev]
buster: [python-dev]
sbcl:
debian:
stretch: [sbcl]
buster: [sbcl]
tinyxml2:
debian:
stretch: [libtinyxml2-dev]
buster: [libtinyxml2-dev]
tinyxml:
debian:
stretch: [libtinyxml-dev]
buster: [libtinyxml-dev]
uuid:
debian:
stretch: [uuid-dev]
buster: [uuid-dev]
web_video_server:
debian:
stretch: [ros-kinetic-web-video-server]
buster: [ros-kinetic-web-video-server]
v4l-utils:
debian:
stretch: [v4l-utils]
buster: [v4l-utils]
yaml-cpp:
debian:
stretch: [libyaml-cpp-dev]
buster: [libyaml-cpp-dev]
zlib:
debian:
stretch: [zlib1g-dev]
buster: [zlib1g-dev]
compressed_depth_image_transport:
debian:
stretch: [ros-kinetic-compressed-depth-image-transport]
buster: [ros-kinetic-compressed-depth-image-transport]
compressed_image_transport:
debian:
stretch: [ros-kinetic-compressed-image-transport]
buster: [ros-kinetic-compressed-image-transport]
dynamic_reconfigure:
debian:
stretch: [ros-kinetic-dynamic-reconfigure]
buster: [ros-kinetic-dynamic-reconfigure]
theora_image_transport:
debian:
stretch: [ros-kinetic-theora-image-transport]
buster: [ros-kinetic-theora-image-transport]
libogg:
debian:
stretch: [libtheora0=1.1.1+dfsg.1-14]
buster: [libtheora0=1.1.1+dfsg.1-14]
vl53l1x:
debian:
stretch: [ros-kinetic-vl53l1x]
@@ -537,25 +537,25 @@ led_msgs:
stretch: [ros-kinetic-led-msgs]
interactive_markers:
debian:
stretch: [ros-kinetic-interactive-markers]
buster: [ros-kinetic-interactive-markers]
interactive_marker_proxy:
debian:
stretch: [ros-kinetic-interactive-marker-proxy]
buster: [ros-kinetic-interactive-marker-proxy]
tf2_web_republisher:
debian:
stretch: [ros-kinetic-tf2-web-republisher]
buster: [ros-kinetic-tf2-web-republisher]
image_publisher:
debian:
stretch: [ros-kinetic-image-publisher]
buster: [ros-kinetic-image-publisher]
raspberry-kernel-headers:
debian:
stretch: [raspberry-kernel-headers]
buster: [raspberry-kernel-headers]
ddynamic_reconfigure:
debian:
stretch: [ros-kinetic-ddynamic-reconfigure]
buster: [ros-kinetic-ddynamic-reconfigure]
realsense2_camera:
debian:
stretch: [ros-kinetic-realsense2-camera]
buster: [ros-kinetic-realsense2-camera]
ros_pytest:
debian:
stretch: [ros-kinetic-ros-pytest]
buster: [ros-kinetic-ros-pytest]

View File

@@ -0,0 +1,735 @@
catkin:
debian:
buster: [ros-melodic-catkin]
genmsg:
debian:
buster: [ros-melodic-genmsg]
gencpp:
debian:
buster: [ros-melodic-gencpp]
geneus:
debian:
buster: [ros-melodic-geneus]
genlisp:
debian:
buster: [ros-melodic-genlisp]
gennodejs:
debian:
buster: [ros-melodic-gennodejs]
genpy:
debian:
buster: [ros-melodic-genpy]
bond_core:
debian:
buster: [ros-melodic-bond-core]
cmake_modules:
debian:
buster: [ros-melodic-cmake-modules]
class_loader:
debian:
buster: [ros-melodic-class-loader]
common_msgs:
debian:
buster: [ros-melodic-common-msgs]
common_tutorials:
debian:
buster: [ros-melodic-common-tutorials]
cpp_common:
debian:
buster: [ros-melodic-cpp-common]
desktop:
debian:
buster: [ros-melodic-desktop]
diagnostics:
debian:
buster: [ros-melodic-diagnostics]
executive_smach:
debian:
buster: [ros-melodic-executive-smach]
geometry:
debian:
buster: [ros-melodic-geometry]
geometry_tutorials:
debian:
buster: [ros-melodic-geometry-tutorials]
gl_dependency:
debian:
buster: [ros-melodic-gl-dependency]
image_common:
debian:
buster: [ros-melodic-image-common]
image_pipeline:
debian:
buster: [ros-melodic-image-pipeline]
image_transport_plugins:
debian:
buster: [ros-melodic-image-transport-plugins]
laser_pipeline:
debian:
buster: [ros-melodic-laser-pipeline]
mavlink:
debian:
buster: [ros-melodic-mavlink]
media_export:
debian:
buster: [ros-melodic-media-export]
message_generation:
debian:
buster: [ros-melodic-message-generation]
message_runtime:
debian:
buster: [ros-melodic-message-runtime]
mk:
debian:
buster: [ros-melodic-mk]
nodelet_core:
debian:
buster: [ros-melodic-nodelet-core]
orocos_kdl:
debian:
buster: [ros-melodic-orocos-kdl]
perception:
debian:
buster: [ros-melodic-perception]
perception_pcl:
debian:
buster: [ros-melodic-perception-pcl]
python_orocos_kdl:
debian:
buster: [ros-melodic-python-orocos-kdl]
qt_dotgraph:
debian:
buster: [ros-melodic-qt-dotgraph]
qt_gui:
debian:
buster: [ros-melodic-qt-gui]
qt_gui_py_common:
debian:
buster: [ros-melodic-qt-gui-py-common]
qwt_dependency:
debian:
buster: [ros-melodic-qwt-dependency]
robot:
debian:
buster: [ros-melodic-robot]
ros:
debian:
buster: [ros-melodic-ros]
ros_base:
debian:
buster: [ros-melodic-ros-base]
ros_comm:
debian:
buster: [ros-melodic-ros-comm]
ros_core:
debian:
buster: [ros-melodic-ros-core]
ros_environment:
debian:
buster: [ros-melodic-ros-environment]
ros_tutorials:
debian:
buster: [ros-melodic-ros-tutorials]
rosapi:
debian:
buster: [ros-melodic-rosapi]
rosbag_migration_rule:
debian:
buster: [ros-melodic-rosbag-migration-rule]
rosbash:
debian:
buster: [ros-melodic-rosbash]
rosboost_cfg:
debian:
buster: [ros-melodic-rosboost-cfg]
rosbridge_server:
debian:
buster: [ros-melodic-rosbridge-server]
rosbridge_suite:
debian:
buster: [ros-melodic-rosbridge-suite]
rosbuild:
debian:
buster: [ros-melodic-rosbuild]
rosclean:
debian:
buster: [ros-melodic-rosclean]
roscpp_core:
debian:
buster: [ros-melodic-roscpp-core]
roscpp_traits:
debian:
buster: [ros-melodic-roscpp-traits]
roscreate:
debian:
buster: [ros-melodic-roscreate]
rosgraph:
debian:
buster: [ros-melodic-rosgraph]
roslang:
debian:
buster: [ros-melodic-roslang]
roslint:
debian:
buster: [ros-melodic-roslint]
roslisp:
debian:
buster: [ros-melodic-roslisp]
rosmake:
debian:
buster: [ros-melodic-rosmake]
rosmaster:
debian:
buster: [ros-melodic-rosmaster]
rospack:
debian:
buster: [ros-melodic-rospack]
roslib:
debian:
buster: [ros-melodic-roslib]
rosparam:
debian:
buster: [ros-melodic-rosparam]
rospy:
debian:
buster: [ros-melodic-rospy]
rosserial:
debian:
buster: [ros-melodic-rosserial]
rosserial_msgs:
debian:
buster: [ros-melodic-rosserial-msgs]
rosserial_python:
debian:
buster: [ros-melodic-rosserial-python]
rosservice:
debian:
buster: [ros-melodic-rosservice]
rostime:
debian:
buster: [ros-melodic-rostime]
roscpp_serialization:
debian:
buster: [ros-melodic-roscpp-serialization]
python_qt_binding:
debian:
buster: [ros-melodic-python-qt-binding]
roslaunch:
debian:
buster: [ros-melodic-roslaunch]
rosunit:
debian:
buster: [ros-melodic-rosunit]
angles:
debian:
buster: [ros-melodic-angles]
libmavconn:
debian:
buster: [ros-melodic-libmavconn]
rosconsole:
debian:
buster: [ros-melodic-rosconsole]
pluginlib:
debian:
buster: [ros-melodic-pluginlib]
qt_gui_cpp:
debian:
buster: [ros-melodic-qt-gui-cpp]
resource_retriever:
debian:
buster: [ros-melodic-resource-retriever]
rosconsole_bridge:
debian:
buster: [ros-melodic-rosconsole-bridge]
roslz4:
debian:
buster: [ros-melodic-roslz4]
rosserial_client:
debian:
buster: [ros-melodic-rosserial-client]
rostest:
debian:
buster: [ros-melodic-rostest]
rqt_action:
debian:
buster: [ros-melodic-rqt-action]
rqt_bag:
debian:
buster: [ros-melodic-rqt-bag]
rqt_bag_plugins:
debian:
buster: [ros-melodic-rqt-bag-plugins]
rqt_common_plugins:
debian:
buster: [ros-melodic-rqt-common-plugins]
rqt_console:
debian:
buster: [ros-melodic-rqt-console]
rqt_dep:
debian:
buster: [ros-melodic-rqt-dep]
rqt_graph:
debian:
buster: [ros-melodic-rqt-graph]
rqt_gui:
debian:
buster: [ros-melodic-rqt-gui]
rqt_logger_level:
debian:
buster: [ros-melodic-rqt-logger-level]
rqt_moveit:
debian:
buster: [ros-melodic-rqt-moveit]
rqt_msg:
debian:
buster: [ros-melodic-rqt-msg]
rqt_nav_view:
debian:
buster: [ros-melodic-rqt-nav-view]
rqt_plot:
debian:
buster: [ros-melodic-rqt-plot]
rqt_pose_view:
debian:
buster: [ros-melodic-rqt-pose-view]
rqt_publisher:
debian:
buster: [ros-melodic-rqt-publisher]
rqt_py_console:
debian:
buster: [ros-melodic-rqt-py-console]
rqt_reconfigure:
debian:
buster: [ros-melodic-rqt-reconfigure]
rqt_robot_dashboard:
debian:
buster: [ros-melodic-rqt-robot-dashboard]
rqt_robot_monitor:
debian:
buster: [ros-melodic-rqt-robot-monitor]
rqt_robot_plugins:
debian:
buster: [ros-melodic-rqt-robot-plugins]
rqt_robot_steering:
debian:
buster: [ros-melodic-rqt-robot-steering]
rqt_runtime_monitor:
debian:
buster: [ros-melodic-rqt-runtime-monitor]
rqt_service_caller:
debian:
buster: [ros-melodic-rqt-service-caller]
rqt_shell:
debian:
buster: [ros-melodic-rqt-shell]
rqt_srv:
debian:
buster: [ros-melodic-rqt-srv]
rqt_tf_tree:
debian:
buster: [ros-melodic-rqt-tf-tree]
rqt_top:
debian:
buster: [ros-melodic-rqt-top]
rqt_topic:
debian:
buster: [ros-melodic-rqt-topic]
rqt_web:
debian:
buster: [ros-melodic-rqt-web]
smach:
debian:
buster: [ros-melodic-smach]
smclib:
debian:
buster: [ros-melodic-smclib]
std_msgs:
debian:
buster: [ros-melodic-std-msgs]
actionlib_msgs:
debian:
buster: [ros-melodic-actionlib-msgs]
bond:
debian:
buster: [ros-melodic-bond]
diagnostic_msgs:
debian:
buster: [ros-melodic-diagnostic-msgs]
geometry_msgs:
debian:
buster: [ros-melodic-geometry-msgs]
eigen_conversions:
debian:
buster: [ros-melodic-eigen-conversions]
kdl_conversions:
debian:
buster: [ros-melodic-kdl-conversions]
nav_msgs:
debian:
buster: [ros-melodic-nav-msgs]
rosbridge_msgs:
debian:
buster: [ros-melodic-rosbridge-msgs]
rosgraph_msgs:
debian:
buster: [ros-melodic-rosgraph-msgs]
rosmsg:
debian:
buster: [ros-melodic-rosmsg]
rqt_py_common:
debian:
buster: [ros-melodic-rqt-py-common]
shape_msgs:
debian:
buster: [ros-melodic-shape-msgs]
smach_msgs:
debian:
buster: [ros-melodic-smach-msgs]
std_srvs:
debian:
buster: [ros-melodic-std-srvs]
tf2_msgs:
debian:
buster: [ros-melodic-tf2-msgs]
tf2:
debian:
buster: [ros-melodic-tf2]
tf2_eigen:
debian:
buster: [ros-melodic-tf2-eigen]
trajectory_msgs:
debian:
buster: [ros-melodic-trajectory-msgs]
control_msgs:
debian:
buster: [ros-melodic-control-msgs]
urdf_parser_plugin:
debian:
buster: [ros-melodic-urdf-parser-plugin]
urdfdom_py:
debian:
buster: [ros-melodic-urdfdom-py]
uuid_msgs:
debian:
buster: [ros-melodic-uuid-msgs]
geographic_msgs:
debian:
buster: [ros-melodic-geographic-msgs]
vision_opencv:
debian:
buster: [ros-melodic-vision-opencv]
visualization_msgs:
debian:
buster: [ros-melodic-visualization-msgs]
visualization_tutorials:
debian:
buster: [ros-melodic-visualization-tutorials]
viz:
debian:
buster: [ros-melodic-viz]
webkit_dependency:
debian:
buster: [ros-melodic-webkit-dependency]
xmlrpcpp:
debian:
buster: [ros-melodic-xmlrpcpp]
roscpp:
debian:
buster: [ros-melodic-roscpp]
bondcpp:
debian:
buster: [ros-melodic-bondcpp]
bondpy:
debian:
buster: [ros-melodic-bondpy]
nodelet:
debian:
buster: [ros-melodic-nodelet]
nodelet_tutorial_math:
debian:
buster: [ros-melodic-nodelet-tutorial-math]
pluginlib_tutorials:
debian:
buster: [ros-melodic-pluginlib-tutorials]
roscpp_tutorials:
debian:
buster: [ros-melodic-roscpp-tutorials]
rosout:
debian:
buster: [ros-melodic-rosout]
async_web_server_cpp:
debian:
buster: [ros-melodic-async-web-server-cpp]
camera_calibration:
debian:
buster: [ros-melodic-camera-calibration]
diagnostic_aggregator:
debian:
buster: [ros-melodic-diagnostic-aggregator]
diagnostic_updater:
debian:
buster: [ros-melodic-diagnostic-updater]
diagnostic_common_diagnostics:
debian:
buster: [ros-melodic-diagnostic-common-diagnostics]
dynamic_reconfigure:
debian:
buster: [ros-melodic-dynamic-reconfigure]
filters:
debian:
buster: [ros-melodic-filters]
joint_state_publisher:
debian:
buster: [ros-melodic-joint-state-publisher]
message_filters:
debian:
buster: [ros-melodic-message-filters]
ros_pytest:
debian:
buster: [ros-melodic-ros-pytest]
rosauth:
debian:
buster: [ros-melodic-rosauth]
rosbag_storage:
debian:
buster: [ros-melodic-rosbag-storage]
rosnode:
debian:
buster: [ros-melodic-rosnode]
rospy_tutorials:
debian:
buster: [ros-melodic-rospy-tutorials]
rosshow:
debian:
buster: [ros-melodic-rosshow]
rostopic:
debian:
buster: [ros-melodic-rostopic]
rqt_gui_cpp:
debian:
buster: [ros-melodic-rqt-gui-cpp]
rqt_gui_py:
debian:
buster: [ros-melodic-rqt-gui-py]
self_test:
debian:
buster: [ros-melodic-self-test]
smach_ros:
debian:
buster: [ros-melodic-smach-ros]
tf2_py:
debian:
buster: [ros-melodic-tf2-py]
topic_tools:
debian:
buster: [ros-melodic-topic-tools]
rosbag:
debian:
buster: [ros-melodic-rosbag]
actionlib:
debian:
buster: [ros-melodic-actionlib]
actionlib_tutorials:
debian:
buster: [ros-melodic-actionlib-tutorials]
diagnostic_analysis:
debian:
buster: [ros-melodic-diagnostic-analysis]
nodelet_topic_tools:
debian:
buster: [ros-melodic-nodelet-topic-tools]
roswtf:
debian:
buster: [ros-melodic-roswtf]
rqt_launch:
debian:
buster: [ros-melodic-rqt-launch]
sensor_msgs:
debian:
buster: [ros-melodic-sensor-msgs]
camera_calibration_parsers:
debian:
buster: [ros-melodic-camera-calibration-parsers]
cv_bridge:
debian:
buster: [ros-melodic-cv-bridge]
image_geometry:
debian:
buster: [ros-melodic-image-geometry]
image_transport:
debian:
buster: [ros-melodic-image-transport]
camera_info_manager:
debian:
buster: [ros-melodic-camera-info-manager]
compressed_depth_image_transport:
debian:
buster: [ros-melodic-compressed-depth-image-transport]
compressed_image_transport:
debian:
buster: [ros-melodic-compressed-image-transport]
cv_camera:
debian:
buster: [ros-melodic-cv-camera]
image_proc:
debian:
buster: [ros-melodic-image-proc]
image_publisher:
debian:
buster: [ros-melodic-image-publisher]
map_msgs:
debian:
buster: [ros-melodic-map-msgs]
mavros_msgs:
debian:
buster: [ros-melodic-mavros-msgs]
pcl_msgs:
debian:
buster: [ros-melodic-pcl-msgs]
pcl_conversions:
debian:
buster: [ros-melodic-pcl-conversions]
polled_camera:
debian:
buster: [ros-melodic-polled-camera]
rqt_image_view:
debian:
buster: [ros-melodic-rqt-image-view]
stereo_msgs:
debian:
buster: [ros-melodic-stereo-msgs]
image_view:
debian:
buster: [ros-melodic-image-view]
rosbridge_library:
debian:
buster: [ros-melodic-rosbridge-library]
stereo_image_proc:
debian:
buster: [ros-melodic-stereo-image-proc]
tf2_ros:
debian:
buster: [ros-melodic-tf2-ros]
depth_image_proc:
debian:
buster: [ros-melodic-depth-image-proc]
mavros:
debian:
buster: [ros-melodic-mavros]
tf:
debian:
buster: [ros-melodic-tf]
interactive_markers:
debian:
buster: [ros-melodic-interactive-markers]
interactive_marker_tutorials:
debian:
buster: [ros-melodic-interactive-marker-tutorials]
laser_geometry:
debian:
buster: [ros-melodic-laser-geometry]
laser_assembler:
debian:
buster: [ros-melodic-laser-assembler]
laser_filters:
debian:
buster: [ros-melodic-laser-filters]
pcl_ros:
debian:
buster: [ros-melodic-pcl-ros]
tf2_geometry_msgs:
debian:
buster: [ros-melodic-tf2-geometry-msgs]
image_rotate:
debian:
buster: [ros-melodic-image-rotate]
tf2_kdl:
debian:
buster: [ros-melodic-tf2-kdl]
tf2_web_republisher:
debian:
buster: [ros-melodic-tf2-web-republisher]
tf_conversions:
debian:
buster: [ros-melodic-tf-conversions]
theora_image_transport:
debian:
buster: [ros-melodic-theora-image-transport]
turtlesim:
debian:
buster: [ros-melodic-turtlesim]
turtle_actionlib:
debian:
buster: [ros-melodic-turtle-actionlib]
turtle_tf:
debian:
buster: [ros-melodic-turtle-tf]
turtle_tf2:
debian:
buster: [ros-melodic-turtle-tf2]
urdf:
debian:
buster: [ros-melodic-urdf]
kdl_parser:
debian:
buster: [ros-melodic-kdl-parser]
kdl_parser_py:
debian:
buster: [ros-melodic-kdl-parser-py]
mavros_extras:
debian:
buster: [ros-melodic-mavros-extras]
robot_state_publisher:
debian:
buster: [ros-melodic-robot-state-publisher]
rviz:
debian:
buster: [ros-melodic-rviz]
librviz_tutorial:
debian:
buster: [ros-melodic-librviz-tutorial]
rqt_rviz:
debian:
buster: [ros-melodic-rqt-rviz]
rviz_plugin_tutorials:
debian:
buster: [ros-melodic-rviz-plugin-tutorials]
rviz_python_tutorial:
debian:
buster: [ros-melodic-rviz-python-tutorial]
urdf_tutorial:
debian:
buster: [ros-melodic-urdf-tutorial]
usb_cam:
debian:
buster: [ros-melodic-usb-cam]
visualization_marker_tutorials:
debian:
buster: [ros-melodic-visualization-marker-tutorials]
vl53l1x:
debian:
buster: [ros-melodic-vl53l1x]
web_video_server:
debian:
buster: [ros-melodic-web-video-server]
xacro:
debian:
buster: [ros-melodic-xacro]
led_msgs:
debian:
buster: [ros-melodic-led-msgs]
ws281x:
debian:
buster: [ros-melodic-ws281x]
ddynamic_reconfigure:
debian:
buster: [ros-melodic-ddynamic-reconfigure]
librealsense2:
debian:
buster: [ros-melodic-librealsense2]
realsense2_camera:
debian:
buster: [ros-melodic-realsense2-camera]
realsense2_description:
debian:
buster: [ros-melodic-realsense2-description]

View File

@@ -1,10 +1,9 @@
[Unit]
Description=Launcher for the ROS master, parameter server and rosout logging node
After=network.target
[Service]
User=pi
ExecStart=/bin/sh -c ". /opt/ros/kinetic/setup.sh; ROS_HOSTNAME=`hostname`.local exec roscore"
ExecStart=/bin/sh -c ". /opt/ros/melodic/setup.sh; ROS_HOSTNAME=`hostname`.local exec roscore"
Restart=on-failure
RestartSec=3

107
builder/assets/rsyslog.conf Normal file
View File

@@ -0,0 +1,107 @@
# /etc/rsyslog.conf configuration file for rsyslog
#
# For more information install rsyslog-doc and see
# /usr/share/doc/rsyslog-doc/html/configuration/index.html
#################
#### MODULES ####
#################
module(load="imuxsock") # provides support for local system logging
module(load="imklog") # provides kernel logging support
#module(load="immark") # provides --MARK-- message capability
# provides UDP syslog reception
#module(load="imudp")
#input(type="imudp" port="514")
# provides TCP syslog reception
#module(load="imtcp")
#input(type="imtcp" port="514")
###########################
#### GLOBAL DIRECTIVES ####
###########################
#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
#
# Set the default permissions for all log files.
#
$FileOwner root
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog
#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf
#
# Enable custom output channels to limit file sizes
#
$outchannel limauth,/var/log/auth.log,10485760,/etc/rsyslog.d/rsysrot.sh /var/log/auth.log
$outchannel limsyslog,/var/log/syslog,10485760,/etc/rsyslog.d/rsysrot.sh /var/log/syslog
$outchannel limdaemon,/var/log/daemon.log,10485760,/etc/rsyslog.d/rsysrot.sh /var/log/daemon.log
$outchannel limkern,/var/log/kern.log,10485760,/etc/rsyslog.d/rsysrot.sh /var/log/kern.log
$outchannel limlpr,/var/log/lpr.log,10485760,/etc/rsyslog.d/rsysrot.sh /var/log/lpr.log
$outchannel limmail,/var/log/mail.log,10485760,/etc/rsyslog.d/rsysrot.sh /var/log/mail.log
$outchannel limmailinfo,/var/log/mail.info,10485760,/etc/rsyslog.d/rsysrot.sh /var/log/mail.info
$outchannel limmailwarn,/var/log/mail.warn,10485760,/etc/rsyslog.d/rsysrot.sh /var/log/mail.warn
$outchannel limmailerr,/var/log/mail.err,10485760,/etc/rsyslog.d/rsysrot.sh /var/log/mail.err
$outchannel limuser,/var/log/user.log,10485760,/etc/rsyslog.d/rsysrot.sh /var/log/user.log
$outchannel limdebug,/var/log/debug,10485760,/etc/rsyslog.d/rsysrot.sh /var/log/debug
$outchannel limmsgs,/var/log/messages,10485760,/etc/rsyslog.d/rsysrot.sh /var/log/messages
###############
#### RULES ####
###############
#
# First some standard log files. Log by facility.
#
auth,authpriv.* :omfile:$limauth
*.*;auth,authpriv.none :omfile:$limsyslog
#cron.* /var/log/cron.log
daemon.* :omfile:$limdaemon
kern.* :omfile:$limkern
lpr.* :omfile:$limlpr
mail.* :omfile:$limmail
user.* :omfile:$limuser
#
# Logging for the mail system. Split it up so that
# it is easy to write scripts to parse these files.
#
mail.info :omfile:$limmailinfo
mail.warn :omfile:$limmailwarn
mail.err :omfile:$limmailerr
#
# Some "catch-all" log files.
#
*.=debug;\
auth,authpriv.none;\
news.none;mail.none :omfile:$limdebug
*.=info;*.=notice;*.=warn;\
auth,authpriv.none;\
cron,daemon.none;\
mail,news.none :omfile:$limmsgs
#
# Emergencies are sent to everybody logged in.
#
*.emerg :omusrmsg:*

4
builder/assets/rsysrot.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
LOG_FILE=$1
mv -f ${LOG_FILE} ${LOG_FILE}.1

View File

@@ -15,7 +15,7 @@
set -e # Exit immidiately on non-zero result
SOURCE_IMAGE="https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-04-09/2019-04-08-raspbian-stretch-lite.zip"
SOURCE_IMAGE="https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-09-30/2019-09-26-raspbian-buster-lite.zip"
export DEBIAN_FRONTEND=${DEBIAN_FRONTEND:='noninteractive'}
export LANG=${LANG:='C.UTF-8'}
@@ -95,7 +95,9 @@ done
# Monkey
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/monkey' '/root/'
# rsyslog config
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/rsyslog.conf' '/etc'
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/rsysrot.sh' '/etc/rsyslog.d'
# Butterfly
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/butterfly.service' '/lib/systemd/system/'
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/butterfly.socket' '/lib/systemd/system/'
@@ -110,7 +112,7 @@ ${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-network.
# Clever
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/clever.service' '/lib/systemd/system/'
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/roscore.service' '/lib/systemd/system/'
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/kinetic-rosdep-clever.yaml' '/etc/ros/rosdep/'
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/melodic-rosdep-clever.yaml' '/etc/ros/rosdep/'
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/ros_python_paths' '/etc/sudoers.d/'
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/pigpiod.service' '/lib/systemd/system/'
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/launch.nanorc' '/usr/share/nano/'

View File

@@ -55,4 +55,7 @@ echo_stamp "Set max space for syslogs"
# https://unix.stackexchange.com/questions/139513/how-to-clear-journalctl
sed -i 's/#SystemMaxUse=/SystemMaxUse=200M/' /etc/systemd/journald.conf
echo_stamp "Move /etc/ld.so.preload out of the way"
mv /etc/ld.so.preload /etc/ld.so.preload.disabled-for-build
echo_stamp "End of init image"

View File

@@ -42,7 +42,7 @@ network={
ssid="CLEVER"
psk="cleverwifi"
mode=2
proto=RSN
proto=WPA RSN
key_mgmt=WPA-PSK
pairwise=CCMP
group=CCMP

View File

@@ -68,7 +68,7 @@ my_travis_retry() {
# TODO: 'kinetic-rosdep-clever.yaml' should add only if we use our repo?
echo_stamp "Init rosdep"
my_travis_retry rosdep init
echo "yaml file:///etc/ros/rosdep/kinetic-rosdep-clever.yaml" >> /etc/ros/rosdep/sources.list.d/20-default.list
echo "yaml file:///etc/ros/rosdep/melodic-rosdep-clever.yaml" >> /etc/ros/rosdep/sources.list.d/20-default.list
my_travis_retry rosdep update
echo_stamp "Populate rosdep for ROS user"
@@ -77,69 +77,15 @@ my_travis_retry sudo -u pi rosdep update
resolve_rosdep() {
# TEMPLATE: resolve_rosdep <CATKIN_PATH> <ROS_DISTRO> <OS_DISTRO> <OS_VERSION>
CATKIN_PATH=$1
ROS_DISTRO='kinetic'
ROS_DISTRO='melodic'
OS_DISTRO='debian'
OS_VERSION='stretch'
OS_VERSION='buster'
echo_stamp "Installing dependencies apps with rosdep in ${CATKIN_PATH}"
cd ${CATKIN_PATH}
my_travis_retry rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --os=${OS_DISTRO}:${OS_VERSION}
}
INSTALL_ROS_PACK_SOURCES=${INSTALL_ROS_PACK_SOURCES:='false'}
if [ "${INSTALL_ROS_PACK_SOURCES}" = "true" ]; then
DISCOVER_ROS_PACK=${DISCOVER_ROS_PACK:='true'}
if [ "${DISCOVER_ROS_PACK}" = "false" ]; then
echo_stamp "Preparing ros_comm packages to kinetic-ros_comm-wet.rosinstall" \
&& mkdir -p /home/pi/ros_catkin_ws && cd /home/pi/ros_catkin_ws \
&& rosinstall_generator ros_comm --rosdistro kinetic --deps --wet-only --tar > kinetic-ros_comm-wet.rosinstall \
&& wstool init -j${NUMBER_THREADS} src kinetic-ros_comm-wet.rosinstall \
&& echo_stamp "All roscomm sources was installed!" "SUCCESS" \
|| (echo_stamp "Some roscomm sources installation was failed!" "ERROR"; exit 1)
echo_stamp "Preparing other ROS-packages to kinetic-custom_ros.rosinstall" \
&& cd /home/pi/ros_catkin_ws \
&& rosinstall_generator \
actionlib actionlib_msgs angles async_web_server_cpp bond bond_core bondcpp bondpy camera_calibration_parsers camera_info_manager catkin class_loader cmake_modules cpp_common cv_bridge cv_camera diagnostic_msgs diagnostic_updater dynamic_reconfigure eigen_conversions gencpp geneus genlisp genmsg gennodejs genpy geographic_msgs geometry_msgs geometry2 image_transport compressed_image_transport libmavconn mavlink mavros_msgs message_filters message_generation message_runtime mk nav_msgs nodelet orocos_kdl pluginlib python_orocos_kdl ros ros_comm rosapi rosauth rosbag rosbag_migration_rule rosbag_storage rosbash rosboost_cfg rosbridge_library rosbridge_server rosbridge_suite rosbuild rosclean rosconsole rosconsole_bridge roscpp roscpp_serialization roscpp_traits roscreate rosgraph rosgraph_msgs roslang roslaunch roslib roslint roslisp roslz4 rosmake rosmaster rosmsg rosnode rosout rospack rosparam rospy rospy_tutorials rosserial rosserial_client rosserial_msgs rosserial_python rosservice rostest rostime rostopic rosunit roswtf sensor_msgs smclib std_msgs std_srvs stereo_msgs tf tf2 tf2_bullet tf2_eigen tf2_geometry_msgs tf2_kdl tf2_msgs tf2_py tf2_ros tf2_sensor_msgs tf2_tools topic_tools trajectory_msgs urdf urdf_parser_plugin usb_cam uuid_msgs visualization_msgs web_video_server xmlrpcpp mavros opencv3 mavros_extras interactive_markers tf2_web_republisher interactive_marker_proxy vl53l1x \
--rosdistro kinetic --deps --wet-only --tar > kinetic-custom_ros.rosinstall \
&& wstool merge -j${NUMBER_THREADS} -t src kinetic-custom_ros.rosinstall \
&& wstool update -j${NUMBER_THREADS} -t src \
&& echo_stamp "All custom sources was installed!" "SUCCESS" \
|| (echo_stamp "Some custom sources installation was failed!" "ERROR"; exit 1)
else
echo_stamp "Creating ros_catkin_ws & getting all sources using wstool" \
&& mkdir -p /home/pi/ros_catkin_ws && cd /home/pi/ros_catkin_ws \
&& wstool init -j${NUMBER_THREADS} src kinetic-ros-clever.rosinstall \
> /dev/null \
&& echo_stamp "All CLEVER sources was installed!" "SUCCESS" \
|| (echo_stamp "Some CLEVER sources installation was failed!" "ERROR"; exit 1)
fi
resolve_rosdep '/home/pi/ros_catkin_ws'
# TODO: Add refactor to origin repo
#echo_stamp "Refactoring usb_cam in SRC"
#sed -i '/#define __STDC_CONSTANT_MACROS/a\#define PIX_FMT_RGB24 AV_PIX_FMT_RGB24\n#define PIX_FMT_YUV422P AV_PIX_FMT_YUV422P' /home/pi/ros_catkin_ws/src/usb_cam/src/usb_cam.cpp
echo_stamp "Building ros_catkin_ws packages"
cd /home/pi/ros_catkin_ws && ./src/catkin/bin/catkin_make_isolated --install -j${NUMBER_THREADS} -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic
#echo_stamp "#11 Building light packages on 2 threads"
#cd /home/pi/ros_catkin_ws && ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release -j2 --install-space /opt/ros/kinetic --pkg actionlib actionlib_msgs angles async_web_server_cpp bond bond_core bondcpp bondpy camera_calibration_parsers camera_info_manager catkin class_loader cmake_modules cpp_common diagnostic_msgs diagnostic_updater dynamic_reconfigure eigen_conversions gencpp geneus genlisp genmsg gennodejs genpy geographic_msgs geometry_msgs geometry2 image_transport libmavconn mavlink mavros_msgs message_filters message_generation message_runtime mk nav_msgs nodelet orocos_kdl pluginlib python_orocos_kdl ros ros_comm rosapi rosauth rosbag rosbag_migration_rule rosbag_storage rosbash rosboost_cfg rosbridge_library rosbridge_server rosbridge_suite rosbuild rosclean rosconsole rosconsole_bridge roscpp roscpp_serialization roscpp_traits roscreate rosgraph rosgraph_msgs roslang roslaunch roslib roslint roslisp roslz4 rosmake rosmaster rosmsg rosnode rosout rospack rosparam rospy rospy_tutorials rosserial rosserial_client rosserial_msgs rosserial_python rosservice rostest rostime rostopic rosunit roswtf sensor_msgs smclib std_msgs std_srvs stereo_msgs tf tf2 tf2_bullet tf2_eigen tf2_geometry_msgs tf2_kdl tf2_msgs tf2_py tf2_ros tf2_sensor_msgs tf2_tools topic_tools trajectory_msgs urdf urdf_parser_plugin usb_cam uuid_msgs visualization_msgs xmlrpcpp
#echo_stamp "#12 Building heavy packages"
# This command uses less threads to avoid Raspberry Pi freeze
#cd /home/pi/ros_catkin_ws && ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release -j1 --install-space /opt/ros/kinetic --pkg mavros opencv3 cv_bridge cv_camera mavros_extras web_video_server
# Install builded packages
# WARNING: A major bug was found when using --pkg option (catkin_make_isolated doesn't install environment files)
# TODO: Can we increase threads number with HDD swap?
echo_stamp "Remove build_isolated & devel_isolated from ros_catkin_ws"
rm -rf /home/pi/ros_catkin_ws/build_isolated /home/pi/ros_catkin_ws/devel_isolated
chown -Rf pi:pi /home/pi/ros_catkin_ws
fi
export ROS_IP='127.0.0.1' # needed for running tests
echo_stamp "Reconfiguring Clever repository for simplier unshallowing"
@@ -153,7 +99,7 @@ echo_stamp "Installing CLEVER" \
&& resolve_rosdep $(pwd) \
&& my_travis_retry pip install wheel \
&& my_travis_retry pip install -r /home/pi/catkin_ws/src/clever/clever/requirements.txt \
&& source /opt/ros/kinetic/setup.bash \
&& source /opt/ros/melodic/setup.bash \
&& catkin_make -j2 -DCMAKE_BUILD_TYPE=Release \
&& systemctl enable roscore \
&& systemctl enable clever \
@@ -165,26 +111,31 @@ cd /home/pi/catkin_ws/src/clever
NPM_CONFIG_UNSAFE_PERM=true npm install gitbook-cli -g
NPM_CONFIG_UNSAFE_PERM=true gitbook install
gitbook build
touch node_modules/CATKIN_IGNORE docs/CATKIN_IGNORE _book/CATKIN_IGNORE clever/www/CATKIN_IGNORE apps/CATKIN_IGNORE # ignore documentation files by catkin
echo_stamp "Installing additional ROS packages"
apt-get install -y --no-install-recommends \
ros-kinetic-dynamic-reconfigure \
ros-kinetic-compressed-image-transport \
ros-kinetic-rosbridge-suite \
ros-kinetic-rosserial \
ros-kinetic-usb-cam \
ros-kinetic-vl53l1x \
ros-kinetic-ws281x \
ros-kinetic-opencv3=3.3.19-0stretch \
ros-kinetic-rosshow
ros-melodic-dynamic-reconfigure \
ros-melodic-compressed-image-transport \
ros-melodic-rosbridge-suite \
ros-melodic-rosserial \
ros-melodic-usb-cam \
ros-melodic-vl53l1x \
ros-melodic-ws281x \
ros-melodic-rosshow
# TODO move GeographicLib datasets to Mavros debian package
echo_stamp "Install GeographicLib datasets (needed for mavros)" \
&& wget -qO- https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh | bash
# FIXME: Buster comes with tornado==5.1.1 but we need tornado==4.2.1 for rosbridge_suite
# (note that Python 3 will still have a more recent version)
pip install tornado==4.2.1
echo_stamp "Running tests"
cd /home/pi/catkin_ws
catkin_make run_tests && catkin_test_results
# FIXME: Investigate failing tests
catkin_make run_tests #&& catkin_test_results
echo_stamp "Change permissions for catkin_ws"
chown -Rf pi:pi /home/pi/catkin_ws
@@ -193,9 +144,9 @@ echo_stamp "Setup ROS environment"
cat << EOF >> /home/pi/.bashrc
LANG='C.UTF-8'
LC_ALL='C.UTF-8'
ROS_DISTRO='kinetic'
ROS_DISTRO='melodic'
export ROS_HOSTNAME=\`hostname\`.local
source /opt/ros/kinetic/setup.bash
source /opt/ros/melodic/setup.bash
source /home/pi/catkin_ws/devel/setup.bash
EOF

View File

@@ -62,65 +62,58 @@ echo_stamp "Install apt keys & repos"
# TODO: This STDOUT consist 'OK'
curl http://deb.coex.tech/aptly_repo_signing.key 2> /dev/null | apt-key add -
apt-get update \
&& apt-get install --no-install-recommends -y -qq dirmngr=2.1.18-8~deb9u4 > /dev/null \
&& apt-get install --no-install-recommends -y dirmngr > /dev/null \
&& apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
echo "deb http://packages.ros.org/ros/ubuntu stretch main" > /etc/apt/sources.list.d/ros-latest.list
echo "deb http://deb.coex.tech/rpi-ros-kinetic stretch main" > /etc/apt/sources.list.d/rpi-ros-kinetic.list
echo "deb http://deb.coex.tech/clever stretch main" > /etc/apt/sources.list.d/clever.list
echo "deb http://packages.ros.org/ros/ubuntu buster main" > /etc/apt/sources.list.d/ros-latest.list
echo "deb http://deb.coex.tech/opencv3 buster main" > /etc/apt/sources.list.d/opencv3.list
echo "deb http://deb.coex.tech/rpi-ros-melodic buster main" > /etc/apt/sources.list.d/rpi-ros-melodic.list
echo "deb http://deb.coex.tech/clever buster main" > /etc/apt/sources.list.d/clever.list
echo_stamp "Update apt cache"
# TODO: FIX ERROR: /usr/bin/apt-key: 596: /usr/bin/apt-key: cannot create /dev/null: Permission denied
apt-get update -qq
apt-get update
# && apt upgrade -y
echo_stamp "Software installing"
apt-get install --no-install-recommends -y \
unzip=6.0-21 \
zip=3.0-11 \
ipython=5.1.0-3 \
ipython3=5.1.0-3 \
screen=4.5.0-6 \
byobu=5.112-1 \
nmap=7.40-1 \
lsof=4.89+dfsg-0.1 \
unzip \
zip \
ipython \
ipython3 \
screen \
byobu \
nmap \
lsof \
git \
dnsmasq=2.76-5+rpt1+deb9u1 \
tmux=2.3-4 \
dnsmasq \
tmux \
vim \
cmake=3.7.2-1 \
libjpeg8=8d1-2 \
cmake \
libjpeg8 \
tcpdump \
ltrace \
libpoco-dev=1.7.6+dfsg1-5+deb9u1 \
libpoco-dev \
python-rosdep \
python-rosinstall-generator \
python-wstool=0.1.17-1 \
python-rosinstall=0.7.8-1 \
build-essential=12.3 \
python-wstool \
python-rosinstall \
build-essential \
libffi-dev \
monkey=1.6.9-1 \
monkey \
pigpio python-pigpio python3-pigpio \
i2c-tools \
espeak espeak-data python-espeak \
ntpdate \
python-dev \
python3-dev \
mjpg-streamer=2.0 \
python-systemd \
mjpg-streamer \
python3-opencv \
&& echo_stamp "Everything was installed!" "SUCCESS" \
|| (echo_stamp "Some packages wasn't installed!" "ERROR"; exit 1)
echo_stamp "Updating kernel to fix camera bug"
apt-get install --no-install-recommends -y \
raspberrypi-kernel=1.20190819~stretch-1 \
raspberrypi-bootloader=1.20190819~stretch-1 \
libraspberrypi-bin=1.20190819~stretch-1 \
libraspberrypi-dev=1.20190819~stretch-1 \
libraspberrypi0=1.20190819~stretch-1 \
wireless-regdb=2018.05.09-0~rpt1 \
wpasupplicant=2:2.6-21~bpo9~rpt1
# Deny byobu to check available updates
sed -i "s/updates_available//" /usr/share/byobu/status/status
# sed -i "s/updates_available//" /home/pi/.byobu/status

View File

@@ -16,11 +16,15 @@ set -ex
echo "Run image tests"
export ROS_DISTRO='kinetic'
export ROS_DISTRO='melodic'
export ROS_IP='127.0.0.1'
source /opt/ros/kinetic/setup.bash
source /opt/ros/melodic/setup.bash
source /home/pi/catkin_ws/devel/setup.bash
cd /home/pi/catkin_ws/src/clever/builder/test/
./tests.sh
./tests.py
./tests_py3.py
echo "Move /etc/ld.so.preload back to its original position"
mv /etc/ld.so.preload.disabled-for-build /etc/ld.so.preload

43
builder/standalone-install.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/bash
# Perform a "standalone install" in a Docker container
# Step 1: Install pip
apt update
apt install -y curl
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python ./get-pip.py
# Step 1.5: Add deb.coex.tech to apt
curl http://deb.coex.tech/aptly_repo_signing.key 2> /dev/null | apt-key add -
echo "deb http://deb.coex.tech/ros xenial main" > /etc/apt/sources.list.d/coex.tech.list
echo "yaml file:///etc/ros/rosdep/coex.yaml" > /etc/ros/rosdep/sources.list.d/99-coex.list
cat <<EOF > /etc/ros/rosdep/coex.yaml
led_msgs:
ubuntu:
xenial: ros-kinetic-led-msgs
bionic: ros-melodic-led-msgs
debian:
stretch: ros-kinetic-led-msgs
buster: ros-melodic-led-msgs
EOF
apt update
rosdep update
# Step 2: Run rosdep to install all dependencies
cd /root/catkin_ws
rosdep install --from-paths src --ignore-src -y
# Step 2.5: mavros can't install its geographiclib dependencies
curl https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh -o install_geographiclib_datasets.sh
chmod a+x ./install_geographiclib_datasets.sh
./install_geographiclib_datasets.sh
# Step 3: Build the packages
cd /root/catkin_ws
catkin_make
# Step 4: Run tests
pip install --upgrade pytest
cd /root/catkin_ws
source devel/setup.bash
catkin_make run_tests && catkin_test_results

View File

@@ -37,7 +37,6 @@ roscore -h
rosversion clever
rosversion aruco_pose
rosversion vl53l1x
rosversion opencv3
rosversion mavros
rosversion mavros_extras
rosversion dynamic_reconfigure

7
builder/test/tests_py3.py Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env python3
# Make sure our Python 3 software is installed
import cv2
print(cv2.getBuildInformation())

View File

@@ -17,7 +17,7 @@ EXCLUDE = 'rviz.png', 'ssid.png', 'sitl_docker_demo.png', 'qgc-params.png', 'but
'cl3_mountBEC.JPG', 'cl3_mountRpiCamera.JPG', 'clever4-front-black-large.png', \
'qgc-battery.png', 'qgc-radio.png', 'qgc-cal-acc.png', 'qgc-esc.png', 'qgc-cal-compass.png', \
'qgc.png', 'qgc-parameters.png', 'clever4-front-white-large.png', 'qgc-modes.png', \
'qgc-requires-setup.png', 'clever4-front-white.png', 'clever4-kit-white.png', '26_1.png'
'qgc-requires-setup.png', 'clever4-front-white.png', 'clever4-kit-white.png', '26_1.png', 'battery_holder.stl'
code = 0

View File

@@ -8,7 +8,7 @@
<arg name="optical_flow" default="false"/>
<arg name="aruco" default="false"/>
<arg name="rangefinder_vl53l1x" default="false"/>
<arg name="led" default="false"/>
<arg name="led" default="true"/>
<arg name="rc" default="true"/>
<!-- log formatting -->
@@ -63,11 +63,16 @@
<!-- vl53l1x ToF rangefinder -->
<node name="rangefinder" pkg="vl53l1x" type="vl53l1x_node" output="screen" if="$(arg rangefinder_vl53l1x)">
<param name="frame_id" value="rangefinder"/>
<param name="min_signal" value="0.4"/>
<param name="pass_statuses" type="yaml" value="[0, 6, 7, 11]"/>
</node>
<!-- led strip -->
<include file="$(find clever)/launch/led.launch" if="$(arg led)"/>
<!-- rc backend -->
<node name="rc" pkg="clever" type="rc" output="screen" if="$(arg rc)"/>
<node name="rc" pkg="clever" type="rc" output="screen" if="$(arg rc)" clear_params="true">
<!-- Send fake GCS heartbeats. Set to "true" for upstream PX4 -->
<param name="use_fake_gcs" value="false"/>
</node>
</launch>

View File

@@ -9,7 +9,7 @@
<node pkg="ws281x" name="led" type="ws281x_node" clear_params="true" output="screen" if="$(arg ws281x)">
<param name="led_count" value="58"/>
<param name="gpio_pin" value="21"/>
<param name="brightness" value="100"/>
<param name="brightness" value="64"/>
<param name="strip_type" value="WS2811_STRIP_GRB"/>
<param name="target_frequency" value="800000"/>
<param name="dma" value="10"/>

View File

@@ -18,6 +18,7 @@
<!-- camera node -->
<node pkg="nodelet" type="nodelet" name="main_camera" args="load cv_camera/CvCameraNodelet nodelet_manager" clear_params="true">
<param name="device_path" value="/dev/video0"/> <!-- v4l2 device -->
<param name="frame_id" value="main_camera_optical"/>
<param name="camera_info_url" value="file://$(find clever)/camera_info/fisheye_cam_320.yaml"/>

View File

@@ -1,5 +1,5 @@
<launch>
<arg name="fcu_conn" default="usb"/>
<arg name="fcu_conn" default="usb"/> <!-- options: usb, uart, tcp, udp, sitl -->
<arg name="fcu_ip" default="127.0.0.1"/>
<arg name="gcs_bridge" default="tcp"/>
<arg name="viz" default="true"/>
@@ -13,9 +13,12 @@
<!-- USB connection -->
<param name="fcu_url" value="/dev/px4fmu" if="$(eval fcu_conn == 'usb')"/>
<!-- sitl -->
<!-- sitl before PX4 1.9.0 -->
<param name="fcu_url" value="udp://@$(arg fcu_ip):14557" if="$(eval fcu_conn == 'udp')"/>
<!-- sitl since PX4 1.9.0 -->
<param name="fcu_url" value="udp://@$(arg fcu_ip):14580" if="$(eval fcu_conn == 'sitl')"/>
<!-- gcs bridge -->
<param name="gcs_url" value="tcp-l://0.0.0.0:5760" if="$(eval gcs_bridge == 'tcp')"/>
<param name="gcs_url" value="udp://0.0.0.0:14550@14550" if="$(eval gcs_bridge == 'udp')"/>

View File

@@ -13,6 +13,7 @@
<arg name="rosbridge" value="$(arg rosbridge)"/>
<arg name="aruco" default="false"/>
<arg name="rangefinder_vl53l1x" default="false"/>
<arg name="led" default="false"/>
<arg name="rc" default="false"/>
</include>
</launch>

View File

@@ -33,7 +33,6 @@
<depend>mavros_extras</depend>
<depend>cv_camera</depend>
<depend>cv_bridge</depend>
<depend>opencv3</depend>
<depend>rosbridge_server</depend>
<depend>web_video_server</depend>
<depend>tf2_web_republisher</depend>

View File

@@ -278,7 +278,8 @@ void handleLog(const rosgraph_msgs::Log& log)
void handleBattery(const sensor_msgs::BatteryState& msg)
{
for (auto const& voltage : msg.cell_voltage) {
if (voltage < low_battery_threshold) {
if (voltage < low_battery_threshold &&
voltage > 2.0) { // voltage < 2.0 likely indicates incorrect voltage measurement
// notify low battery every time
notify("low_battery");
}

View File

@@ -34,12 +34,15 @@ public:
nh(),
nh_priv("~")
{
bool use_fake_gcs = nh_priv.param("use_fake_gcs", true);
// Create socket thread
std::thread t(&RC::socketThread, this);
t.detach();
std::thread gcst(&RC::fakeGCSThread, this);
gcst.detach();
if (use_fake_gcs) {
std::thread gcst(&RC::fakeGCSThread, this);
gcst.detach();
}
initLatchedState();
}

View File

@@ -9,6 +9,7 @@
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
import os
import math
import subprocess
import re
@@ -94,7 +95,7 @@ def get_param(name):
return None
if not res.success:
failure('Unable to retrieve PX4 parameter %s', name)
failure('unable to retrieve PX4 parameter %s', name)
else:
if res.value.integer != 0:
return res.value.integer
@@ -224,6 +225,12 @@ def check_fcu():
else:
info('LPE_FUSION: barometer fusion is disabled')
mag_yaw_w = get_param('ATT_W_MAG')
if mag_yaw_w == 0:
info('magnetometer weight (ATT_W_MAG) is zero, better for indoor flights')
else:
info('magnetometer weight (ATT_W_MAG) is non-zero (%.2f), better for outdoor flights', mag_yaw_w)
elif est == 2:
info('selected estimator: EKF2')
else:
@@ -238,15 +245,18 @@ def check_fcu():
cbrk_usb_chk = get_param('CBRK_USB_CHK')
if cbrk_usb_chk != 197848:
failure('Set parameter CBRK_USB_CHK to 197848 for flying with USB connected')
failure('set parameter CBRK_USB_CHK to 197848 for flying with USB connected')
try:
battery = rospy.wait_for_message('mavros/battery', BatteryState, timeout=3)
cell = battery.cell_voltage[0]
if cell > 4.3 or cell < 3.0:
failure('Incorrect cell voltage: %.2f V, https://clever.coex.tech/power', cell)
elif cell < 3.7:
failure('Critically low cell voltage: %.2f V, recharge battery', cell)
if not battery.cell_voltage:
failure('cell voltage is not available, https://clever.coex.tech/power')
else:
cell = battery.cell_voltage[0]
if cell > 4.3 or cell < 3.0:
failure('incorrect cell voltage: %.2f V, https://clever.coex.tech/power', cell)
elif cell < 3.7:
failure('critically low cell voltage: %.2f V, recharge battery', cell)
except rospy.ROSException:
failure('no battery state')
@@ -597,7 +607,7 @@ def check_rangefinder():
@check('Boot duration')
def check_boot_duration():
output = subprocess.check_output('systemd-analyze')
r = re.compile(r'([\d\.]+)s$')
r = re.compile(r'([\d\.]+)s\s*$', flags=re.MULTILINE)
duration = float(r.search(output).groups()[0])
if duration > 15:
failure('long Raspbian boot duration: %ss (systemd-analyze for analyzing)', duration)
@@ -686,9 +696,67 @@ def check_preflight_status():
failure(' '.join([match.groups()[1], 'check:', check_status]))
@check('Network')
def check_network():
ros_hostname = os.environ.get('ROS_HOSTNAME').strip()
if not ros_hostname:
failure('no ROS_HOSTNAME is set')
elif ros_hostname.endswith('.local'):
# using mdns hostname
hosts = open('/etc/hosts', 'r')
for line in hosts:
parts = line.split()
if len(parts) < 2:
continue
ip = parts.pop(0).split('.')
if ip[0] == '127': # loopback ip
if ros_hostname in parts:
break
else:
failure('not found %s in /etc/hosts, ROS will malfunction if network interfaces are down, https://clever.coex.tech/hostname', ros_hostname)
@check('RPi health')
def check_rpi_health():
# `vcgencmd get_throttled` output codes taken from
# https://github.com/raspberrypi/documentation/blob/JamesH65-patch-vcgencmd-vcdbg-docs/raspbian/applications/vcgencmd.md#get_throttled
# TODO: support more base platforms?
FLAG_UNDERVOLTAGE_NOW = 0x1
FLAG_FREQ_CAP_NOW = 0x2
FLAG_THROTTLING_NOW = 0x4
FLAG_THERMAL_LIMIT_NOW = 0x8
FLAG_UNDERVOLTAGE_OCCURRED = 0x10000
FLAG_FREQ_CAP_OCCURRED = 0x20000
FLAG_THROTTLING_OCCURRED = 0x40000
FLAG_THERMAL_LIMIT_OUCCURRED = 0x80000
try:
# vcgencmd outputs a single string in a form of
# <parameter>=<value>
# In case of `get_throttled`, <value> is a hexadecimal number
# with some of the FLAGs OR'ed together
output = subprocess.check_output(['vcgencmd', 'get_throttled'])
except OSError:
failure('could not call vcgencmd binary; not a Raspberry Pi?')
return
throttle_mask = int(output.split('=')[1], base=16)
if throttle_mask & (FLAG_THROTTLING_NOW | FLAG_THROTTLING_OCCURRED):
failure('system throttled to prevent damage')
if throttle_mask & (FLAG_UNDERVOLTAGE_NOW | FLAG_UNDERVOLTAGE_OCCURRED):
failure('not enough power for onboard computer, flight inadvisable')
if throttle_mask & (FLAG_FREQ_CAP_NOW | FLAG_FREQ_CAP_OCCURRED):
failure('CPU frequency reduced to avoid overheating')
if throttle_mask & (FLAG_THERMAL_LIMIT_NOW | FLAG_THERMAL_LIMIT_OUCCURRED):
failure('CPU over soft temperature limit, expect performance loss')
def selfcheck():
check_image()
check_clever_service()
check_network()
check_fcu()
check_imu()
check_local_position()
@@ -701,6 +769,7 @@ def selfcheck():
check_optical_flow()
check_vpe()
check_rangefinder()
check_rpi_health()
check_cpu_usage()
check_boot_duration()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 KiB

After

Width:  |  Height:  |  Size: 322 KiB

BIN
docs/assets/4/31_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 KiB

BIN
docs/assets/4/43_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 KiB

BIN
docs/assets/coexpix-top.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 KiB

15980
docs/assets/dxf/arm.dxf Normal file

File diff suppressed because it is too large Load Diff

15376
docs/assets/dxf/big_leg.dxf Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

19794
docs/assets/dxf/deck.dxf Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

15334
docs/assets/dxf/leg.dxf Normal file

File diff suppressed because it is too large Load Diff

15256
docs/assets/dxf/prop_guard.dxf Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

BIN
docs/assets/programming.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

BIN
docs/assets/raspberry.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

View File

@@ -1,6 +1,6 @@
Using an external 3G modem
===
To use an external 3G modem on Raspberry, you can use the [`sakis3g`] package (https://github.com/Trixarian/sakis3g-source).
To use an external 3G modem on Raspberry, you can use the [`sakis3g`](https://github.com/Trixarian/sakis3g-source) package.
TODO

View File

@@ -20,34 +20,38 @@
* [Connection to the Pixracer](connection.md)
* [Using QGroundControl over Wi-Fi](gcs_bridge.md)
* [Remote shell](ssh.md)
* [Editing files](editing.md)
* [Command line interface](cli.md)
* [Automated self-checks](selfcheck.md)
* [Viewing images from cameras](web_video_server.md)
* Programming
* [ROS](ros.md)
* [MAVROS](mavros.md)
* [Overview](programming.md)
* [Camera orientation](camera_frame.md)
* [Coordinate systems (frames)](frames.md)
* [Simple OFFBOARD](simple_offboard.md)
* [Code snippets](snippets.md)
* Fiducial markers (ArUco)
* [Overview](aruco.md)
* [Marker detection](aruco_marker.md)
* [Map-based navigation](aruco_map.md)
* [Optical Flow](optical_flow.md)
* [Computer vision basics](camera.md)
* [Simple OFFBOARD](simple_offboard.md)
* [Coordinate systems (frames)](frames.md)
* [Code snippets](snippets.md)
* [Interfacing with a laser rangefinder](laser.md)
* [LED strip](leds.md)
* [Working with GPIO](gpio.md)
* [Interfacing with a sonar](sonar.md)
* [Computer vision basics](camera.md)
* [Using rviz and rqt](rviz.md)
* [Interfacing with a laser rangefinder](laser.md)
* [Software autorun](autolaunch.md)
* [Software autorun](autolaunch.md)
* [ROS](ros.md)
* [MAVROS](mavros.md)
* Supplementary materials
* [COEX Pix](coex_pix.md)
* [Guide on autonomous flight](auto_setup.md)
* [Hostname](hostname.md)
* [PX4 Simulation](sitl.md)
* [PID Setup](calibratePID.md)
* [ROS Kinetic installation](ros-install.md)
* [Model files for parts](models.md)
* [ROS Melodic installation](ros-install.md)
* [Clever and Jetson Nano](jetson_nano.md)
* [Remote control app](rc.md)
* [Wi-Fi Configuration](network.md)
* [UART settings](uart.md)
@@ -75,7 +79,6 @@
* [Android RC app](android.md)
* [3D-scanning drone](3dscan.md)
* [Human pose estimation drone control](human_pose_estimation_drone_control.md)
* [Copter Hack 2019](copterhack2019.md)
* [Copter Hack 2018](copterhack2018.md)
* [Copter Hack 2017](copterhack2017.md)
* Textbook
* [Theory and Videos](lessons.md)

View File

@@ -10,7 +10,7 @@
## Configuration
Set the `aruco` argument in `~/catkin_ws/src/clever/clever/launch/aruco.launch` to `true`:
Set the `aruco` argument in `~/catkin_ws/src/clever/clever/launch/clever.launch` to `true`:
```xml
<arg name="aruco" default="true"/>
@@ -61,6 +61,8 @@ Usage example:
rosrun aruco_pose genmap.py 0.33 2 4 1 1 0 > ~/catkin_ws/src/clever/aruco_pose/map/test_map.txt
```
<!-- You can also use the [online map editor](arucogenmap.md) to create ArUco maps. -->
### Checking the map
The currently active map is posted in the `/aruco_map/image` ROS topic. It can be viewed using [web_video_server](web_video_server.md) by opening the following link: http://192.168.11.1:8080/snapshot?topic=/aruco_map/image
@@ -102,6 +104,12 @@ If you're using **LPE** (`SYS_MC_EST_GROUP` parameter is set to `local_position_
* Vision position standard deviations: `LPE_VIS_XY` = 0.1 m, `LPE_VIS_Z` = 0.1 m.
* `LPE_VIS_DELAY` = 0 sec.
<!-- * Compass should not be fused: `ATT_W_MAG` = 0 -->
> **Hint** We recommend using **LPE** for marker-based navigation.
You may use [the `selfcheck.py` utility](selfcheck.md) to check your settings.
> **Hint** In order to use LPE with the Pixhawk v1 hardware you should download the [`px4fmu-v2_lpe.px4` firmware](firmware.md)
## Flight
@@ -112,18 +120,21 @@ You will also be able to use `navigate`, `set_position` and `set_velocity` ROS s
```python
# Takeoff should be performed in the "body" frame; "aruco_map" frame will appear as soon as the drone detects the marker field
navigate(0, 0, 2, frame_id='body', speed=0.5, auto_arm=True) # Takeoff and hover 2 metres above the ground
navigate(x=0, y=0, z=2, frame_id='body', speed=0.5, auto_arm=True) # Takeoff and hover 2 metres above the ground
time.sleep(5)
# Fly to the (2, 2) point on the marker field while being 2 metres above it
navigate(2, 2, 2, speed=1, frame_id='aruco_map')
navigate(x=2, y=2, z=2, speed=1, frame_id='aruco_map')
```
Starting from the [image](image.md) version 0.18, the drone also can fly relative to a marker in the map, even if it doesn't see it:
### Using a specific marker frame
Starting with the [image](image.md) version 0.18, the drone also can fly relative to a marker in the map, even if it is not currently visible. Like with [single-marker navigation](aruco_marker.md#working-with-detected-markers), this works by setting the frame_id parameter to aruco_ID, where ID is the desired marker number.
The folloding code will move the drone to the point 1 meter above the center of marker 5:
```python
# Fly to 1 meter above the marker 5
navigate(frame_id='aruco_5', x=0, y=0, z=1)
```

View File

@@ -10,7 +10,7 @@ Using this module along with [map-based navigation](aruco_map.md) is also possib
## Setup
Set the `aruco` argument in `~/catkin_ws/src/clever/clever/launch/aruco.launch` to `true`:
Set the `aruco` argument in `~/catkin_ws/src/clever/clever/launch/clever.launch` to `true`:
```xml
<arg name="aruco" default="true"/>

View File

@@ -97,6 +97,8 @@ Perform these actions for each motor.
Motors with **<font color=red>red</font>** nuts should rotate **counterclockwise**, the ones with **black** nuts should rotate **clockwise**. Correct rotation direction should also be printed on the motors. You can use a servo tester or your RC transmitter and receiver to check rotation direction.
<img src="../assets/4/props/props_rotation.png" width=300 class="zoom center">
The following describes how to use your RC gear to check the motor direction.
### Setting up PWM mode on RC
@@ -181,31 +183,35 @@ The flight controller expects PPM signal from your RC gear. Switch your transmit
## Mounting the flight controller
1. Align the flight controller so that the arrows on the controller and on the top carbon deck point in the same direction.
2. Attach the flight controller to the flight controller plate using 3M double-sided adhesive pads.
3. Connect the power cable to the **"POWER"** input of the flight controller.
1. Insert the microSD card into your flight controller.
<img src="../assets/4/pix/pixracer_sdcard.png" width=300 class="zoom center border">
2. Align the flight controller so that the arrows on the controller and on the top carbon deck point in the same direction.
3. Attach the flight controller to the flight controller plate using 3M double-sided adhesive pads.
4. Connect the power cable to the **"POWER"** input of the flight controller.
<div class="image-group">
<img src="../assets/4/18.png" width=300 class="zoom border">
<img src="../assets/4/18_1.png" width=300 class="zoom border">
</div>
4. Attach four 40 mm aluminum spacers to the top carbon deck using M3x10 screws.
5. Attach four 40 mm aluminum spacers to the top carbon deck using M3x10 screws.
<div class="image-group">
<img src="../assets/4/19.png" width=300 class="zoom border">
<img src="../assets/4/19_1.png" width=300 class="zoom border">
</div>
5. Connect signal wires to the flight controller as shown in these pictures:
6. Connect signal wires to the flight controller as shown in these pictures:
<div class="image-group">
<img src="../assets/4/20.png" width=300 class="zoom border">
<img src="../assets/4/20_1.png" width=300 class="zoom border">
</div>
6. Attach two 15 mm spacers to the top carbon deck using M3x8 screws.
7. Attach two 15 mm spacers to the top carbon deck and the front arms using M3x10 screws (this was already described in the "Frame Assembly" section, p. 2).
7. Attach two 15 mm spacers to the top carbon deck using M3x8 screws.
8. Attach two 15 mm spacers to the top carbon deck and the front arms using M3x10 screws (this was already described in the "Frame Assembly" section, p. 2).
<div class="image-group">
<img src="../assets/4/21.png" width=300 class="zoom border">
@@ -224,15 +230,19 @@ The flight controller expects PPM signal from your RC gear. Switch your transmit
## Installing the Raspberry Pi
1. Attach the Raspberry Pi using four standoffs.
2. Route the BEC wires through the channel in the top carbon deck.
1. Insert your microSD card [with our image](image.md) into the Raspberry Pi
<img src="../assets/4/rpi/rpi_sdcard.png" width=300 class="zoom center border">
2. Attach the Raspberry Pi using four standoffs.
3. Route the BEC wires through the channel in the top carbon deck.
<div class="image-group">
<img src="../assets/4/24.png" width=300 class="zoom border">
<img src="../assets/4/26.png" width=300 class="zoom border">
</div>
3. Connect the BEC outputs according to the following image:
4. Connect the BEC outputs according to the following image:
<img src="../assets/4/26_1.png" width=300 class="zoom center border">
@@ -252,7 +262,10 @@ The flight controller expects PPM signal from your RC gear. Switch your transmit
1. Power the LED strip from a separate BEC. Connect the **«+»** and **«-»** leads to **5v** and **Ground** respectively.
2. Connect the **D** lead to GPIO21 (consult the [relevant article](leds.md) for more information).
<img src="../assets/4/31_1.png" width=300 class="zoom center border">
<div class="image-group">
<img src="../assets/4/31_1.png" width=300 class="zoom border">
<img src="../assets/4/31_2.png" width=300 class="zoom border">
</div>
## Installing the camera cable
@@ -266,6 +279,9 @@ The flight controller expects PPM signal from your RC gear. Switch your transmit
1. Prepare the laser rangefinder by soldering leads to it.
2. Use four 2x5 self-tapping screws to secure the camera.
> **Warning** Make sure the screws don't touch any components on the camera PCB! Otherwise the camera may not function properly.
3. Mount the laser rangefinder on the lower deck using two M3x8 screws and steel nuts.
<div class="image-group">
@@ -339,6 +355,9 @@ The flight controller expects PPM signal from your RC gear. Switch your transmit
</div>
4. Connect the flight controller to the Raspberry Pi using retractable USB cable.
<img src="../assets/4/43_1.png" width=300 class="zoom center border">
5. Attach the USB cable reel where convenient using 3M double-sided adhesive pads while making sure the cable does not interfere with the propellers.
<div class="image-group">

View File

@@ -25,7 +25,7 @@ This manual contains links to other articles in which each of the topics address
- You can change the name and password of the network if you want to. See the article "[Network Settings] (network.md # change-password-or-ssid-network-name)". The remaining operations with the network are unnecessary.
- Use the nano editor to edit files. [Instructions for working with nano] (editing.md).
- Use the nano editor to edit files. [Instructions for working with nano](cli.md#editing).
> **Hint** In nano, you can only move the cursor with the arrow keys on the keyboard.

View File

@@ -29,7 +29,7 @@ sudo systemctl stop clever
Then use `raspistill` to capture an image from the camera:
```bash
raspistill -o test-image.jpeg
raspistill -o test.jpg
```
If it doesn't work, check the camera cable connections and the cable itself. Replace the cable if it is damaged. Also, make sure the camera screws don't touch any components on the camera board.
@@ -43,12 +43,12 @@ Additionally you can specify an arbitrary capture parameter using its [OpenCV co
```xml
<param name="property_0_code" value="21"/> <!-- property code 21 is CAP_PROP_AUTO_EXPOSURE -->
<param name="property_0_value" value="0.25"/> <!-- property values are normalized as per OpenCV specs, even for "menu" controls; 0.25 means "use manual exposure" -->
<param name="cv_cap_prop_exposure" value="0.3"> <!-- set exposure to 30% of maximum value -->
<param name="cv_cap_prop_exposure" value="0.3"/> <!-- set exposure to 30% of maximum value -->
```
## Computer vision
The [SD card image](image.md) comes with a preinstalled [OpenCV](https://opencv.org) library, which is commonly used for various comupter vision-related tasks. Additional libraries for converting from ROS messages to OpenCV images and back are preinstalled as well.
The [SD card image](image.md) comes with a preinstalled [OpenCV](https://opencv.org) library, which is commonly used for various computer vision-related tasks. Additional libraries for converting from ROS messages to OpenCV images and back are preinstalled as well.
### Python

View File

@@ -2,7 +2,7 @@
> **Note** Documentation for the versions [of image](image.md), starting with **0.15**. For earlier versions, see [documentation for version **0.14**](https://github.com/CopterExpress/clever/blob/v0.14/docs/ru/camera_frame.md).
Position and orientation of the main camera is determined in file `~/catkin_ws/src/clever/clever/launch/main_camera.launch`:
Position and orientation of the main camera is [set in file](cli.md#editing) `~/catkin_ws/src/clever/clever/launch/main_camera.launch`:
```xml
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0 0 -0.07 -1.5707963 0 3.1415926 base_link main_camera_optical"/>

80
docs/en/cli.md Normal file
View File

@@ -0,0 +1,80 @@
# Command line interface
The Raspberry Pi OS, Raspbian, uses CLI as its primary user interface (which is common for Linux-based operating systems). You can use [a secure shell connection](ssh.md) to access the command line.
## Basic commands
> **Hint** Double-tapping the `Tab ↹` key autocompletes the command or its argument. This is known as "tab completion".
Show the contents of the current directory:
```bash
ls
```
Change current (working) directory:
```bash
cd catkin_ws/src/clever/clever/launch
```
Go one directory level up:
```bash
cd ..
```
Print path to the current directory:
```bash
pwd
```
Print contents of the `file.py` file:
```bash
cat file.py
```
Run `file.py` as a Python script:
```bash
python file.py
```
Reboot Raspberry Pi:
```bash
sudo reboot
```
You can terminate currently running (foreground) program by pressing `Ctrl`+`C`.
Read more about the Linux command line in the Raspberry Pi documentation: https://www.raspberrypi.org/documentation/linux/usage/commands.md.
## Editing files {#editing}
You can use **nano** to edit files on the Raspberry Pi. It is one of the more user-friendly console-based text editor.
1. Use the following command to edit or create a file:
```bash
nano path/to/file
```
For example:
```bash
nano ~/catkin_ws/src/clever/clever/launch/clever.launch
```
<img src="../assets/nano.png" alt="Editing files in nano" data-action="zoom">
2. Edit the file.
3. Press `Ctrl`+`X`, `Y`, `Enter` to save your file and exit.
4. Restart the `clever` package if you've changed .launch files:
```bash
sudo systemctl restart clever
```
You may also use other editors like **vim** if you prefer.

60
docs/en/coex_pix.md Normal file
View File

@@ -0,0 +1,60 @@
# COEX Pix
The **COEX Pix** flight controller is a modified [Pixracer](https://docs.px4.io/v1.9.0/en/flight_controller/pixracer.html) FCU. It is a part of the **Clever 4** quadrotor kit.
## Revision 1.1
### Physical specs
* Board size: 35x35 mm.
* Mounting hole pattern: standard 30.5 mm.
* Mounting hole diameter: 3.2 mm.
* Board mass: 9 g.
* Operating temperature range: -5..+65 ºC.
* Input voltage: 4.8..5.5 V.
### Key features
* Main System-on-Chip: *STM32F427VIT6*.
* FRAM chip: *FM25V02A*
* Built-in sensors:
* *MPU9250* 9DOF accelerometer/gyroscope/magnetometer.
* *MS5607* barometer.
### Ports
* *TELEM 1* (JST-GH 4 pin) telemetry port 1, UART.
* *TELEM 2* (JST-GH 4 pin) telemetry port 2, UART.
* *GPS* (JST-GH 6 pin) GNSS (UART) and external compass (I2C) port.
* *I2C* (JST-GH 4 pin) I2C port for supported devices (shares lanes with *GPS* port).
* *PWR* (JST-GH 6 pin) port for PDB connection (COEX PDB or compatible), with two power lanes, two ground lanes, and voltage and current sensor inputs.
* *RC IN* (JST-GH 4 pin) RC input port with RSSI pin. Supports PPM and S.BUS protocols.
* Micro USB port for PC connection (USB 2.0/1.1).
* MicroSD slot (supports up to 32gb microSD cards).
* 6 servo outputs for ESCs and other peripherals.
### Port pinouts
<img src="../assets/coexpix-top.jpg" width="400" class="zoom">
<img src="../assets/coexpix-bottom.jpg" width="400" class="zoom">
> **Note** On rev. 1.0 boards *RC IN* port and microSD slot are switched. Pinout for the *RC IN* port is the same on these boards.
### Mounting suggestions
**Important**: The board is meant to be installed with a non-standard orientation (roll 180º, yaw 90º) on the Clever airframe. Therefore, the `SENS_BOARD_ROT` PX4 parameter should be set to `ROLL 180, YAW 90`.
### Usage notes
In order to reduce magnetic interference from the PDB and power cables you should mount the FCU as far away from these parts as possible. You should have at least 15 mm clearance from high-power parts.
You may want to disable internal compass if you're using an external GNSS+compass module.
If your drone does not have a protective cover for the FCU, you should place a piece of foam over the barometer.
The FCU has power passthrough from the *PWR* input to the servo rail. Supplying additional power to the servo rail is not recommended if the *PWR* input is used. Powering the FCU from USB and *PWR*/*AUX* inputs is acceptable.
### Board specifics
The board utilizes low-noise DC-DC converters, voltage inputs have LC and ferrite filters.

View File

@@ -1,60 +1,52 @@
Connecting Pixhawk/Pixracer to Raspberry Pi
===
# Connecting Raspberry Pi to the flight controller
To program [autonomous flights](simple_offboard.md) [work with Pixhawk (Pixracer) over Wi-Fi](gcs_bridge.md), use [of a phone transmitter] (rc.md), and other functions, it is necessary to connect Raspberry Pi to Pixhawk (Pixracer).
In order to program [autonomous flights](simple_offboard.md), [work with Pixhawk or Pixracer over Wi-Fi](gcs_bridge.md), use [controller app](rc.md) and access other functions you need to connect your Raspberry Pi to the flight controller.
Check operability of the connection [by running on Raspberry Pi](ssh.md):
## USB connection
```bash
rostopic echo /mavros/state
```
USB connection is the preferred way to connect to the flight controller.
The `connected` field should contain value `True`.
1. Connect your FCU to the Raspberry Pi using a microUSB to USB cable.
2. [Connect to the Raspberry Pi over SSH](ssh.md).
3. Make sure the connection is working by [running the following command on the Raspberry Pi](ssh.md):
Connection via USB
---
```bash
rostopic echo /mavros/state
```
Connect Pixhawk/Pixracer to micro USB in Raspberry Pi with a USB cable.
The `connected` field should have the `True` value.s
Make sure that in Clever launch file (`~/catkin_ws/src/clever/clever/launch/clever.launch`), connection type is set to USB:
> **Hint** You need to set the `CBRK_USB_CHK` [parameter](px4_parameters.md) to 197848 for the USB connection to work.
```xml
<arg name="fcu_conn" default="usb"/>
```
## UART connection
After the launch file is edited, restart package `clever`:
<!-- TODO: Connection scheme -->
```bash
sudo systemctl restart clever
```
UART connection is another way for the Raspberry Pi and FCU to communicate.
> **Hint** For correct operation of the Raspberry Pi connection to Pixhawk via USB, set value of [parameter](px4_parameters.md) `CBRK_USB_CHK` to 197848.
1. Connect Raspberry Pi to your FCU using a UART cable.
2. [Connect to the Raspberry Pi over SSH](ssh.md).
3. Change the connection type in `~/catkin_ws/src/clever/clever/launch/clever.launch` to UART:
Connection via UART
---
```xml
<arg name="fcu_conn" default="uart"/>
```
TODO connection diagram
Be sure to restart the `clever` service after editing the .launch file:
Make sure that in Clever launch file (`~/catkin_ws/src/clever/clever/clever.launch`), connection type is set to UART:
```bash
sudo systemctl restart clever
```
```xml
<arg name="fcu_conn" default="uart"/>
```
> **Hint** Set the `SYS_COMPANION` PX4 parameter to 921600 to enable UART on the FCU.
After the launch-file is edited, restart package `clever`:
## SITL connection
```bash
sudo systemctl restart clever
```
> **Hint** For correct operation of the Raspberry Pi connection to Pixhawk via UART, set value of parameter`SYS_COMPANION` to 921600.
Connection to SITL
---
To connect locally/remotely to a running [SITL](sitl.md), set argument `fcu_conn` to `udp`, and `fcu_ip` to the IP address of the machine where SITL is running (`127.0.0.1` for local):
In order to connect to a local or a remote [SITL](sitl.md) instance set the `fcu_conn` parameter to `udp` and `fcu_ip` to the IP address of the SITL instance (`127.0.0.1` if you are running the instance locally):
```xml
<arg name="fcu_conn" default="udp"/>
<arg name="fcu_ip" default="127.0.0.1"/>
```
**Next**: [Using QGroundControl over Wi-Fi](gcs_bridge.md)

94
docs/en/copterhack2019.md Normal file
View File

@@ -0,0 +1,94 @@
# Copter Hack 2019
The [Copter Hack 2019](https://copterexpress.timepad.ru/event/1017592/) hackathon took place on the 11th to 13th of October in the "Moscow" Technopolis.
Event page: https://coex.tech/copterhack.
Hackathon chat: https://t.me/CopterHack.
Timepad event page: https://copterexpress.timepad.ru/event/1017592/.
## Information for participants
### COEX Pix specifics
Be sure to set the *Autopilot orientation* parameter to `ROTATION_ROLL_180_YAW_90` if you're using the *COEX Pix* flight controller. This parameter should be applied during calibration of each sensor.
<img src="../assets/autopilot_orientation.png" class="center" width="600">
This parameter is used for *IMU* orientation correction.
### Suggested image versions
Raspberry Pi versions 3B+ and lower: [v0.18](https://github.com/CopterExpress/clever/releases/tag/v0.18)
Raspberry Pi version 4: [v0.19-alpha.1](https://github.com/CopterExpress/clever/releases/tag/v0.19-alpha.1)
### Camera orientation
Some drones have the camera mounted with the cable going forward. You should set this orientation in the `main_camera.launch` file in the `clever` package.
Further reading: [Camera orientation](camera_frame.md)
### Using Optical Flow
In order to enable optical flow set `optical_flow` and `rangefinder_vl53l1x` parameters to `true` in `clever.launch`.
Enable `pub agl as lpos down` in `LPE_FUSION` parameter using QGroundControl.
Make sure the rangefinder is mounted correctly and is working (see [Interfacing with a laser rangefinder](laser.md)).
Further reading: [Optical Flow](optical_flow.md).
### Using ArUco map
Use the `cmit.txt` map. See [instructions](aruco_map.md).
### Drone batteries
**The battery indicator should be connected to the battery at all times. The organizers will not replace your damaged batteries!**
### Flight videos
Be sure to record **ALL** your flights on video! If your drone fails before your presentation, you'll be able to at least show your videos.
### Yaw problem
The v1.8.2-clever.7 FCU firmware has a potential bug that manifests during VPE (marker-based) flights. If your drone does not correct its yaw when using ArUco markers, try using an older firmware version (v1.8.2-clever.6, available from https://github.com/CopterExpress/Firmware/releases/tag/v1.8.2-clever.6). Download `px4fmu-v4_default.px4` for COEX Pix.
### `navigate` service problem
The 0.18 Raspberry Pi image has a potential bug that makes the drone fly through waypoints too fast. Try setting the `nav_from_sp` parameter to `false` in `~/catkin_ws/src/clever/clever/launch/clever.launch` if you are affected by it:
```xml
<!-- simplified offboard control -->
<node name="simple_offboard" pkg="clever" type="simple_offboard" output="screen" clear_params="true">
<param name="reference_frames/body" value="map"/>
<param name="reference_frames/base_link" value="map"/>
<param name="reference_frames/navigate_target" value="map"/>
<param name="reference_frames/navigate_target" value="map"/>
<param name="nav_from_sp" value="false"/>
</node>
```
## Lectures (in Russian)
Lecture 1: Introduction  https://www.youtube.com/watch?v=cjtmZNuq7z0.
Lecture 2: FCU setup  https://www.youtube.com/watch?v=PJNDYFPZQms.
Lecture 3: PX4 architecture  https://www.youtube.com/watch?v=_jl7FImq3jk.
Lecture 4: Autonomous flights  https://www.youtube.com/watch?v=ThXiNG1IzvI.
Be sure to check out other videos on the COEX YouTube channel: https://www.youtube.com/channel/UCeCu93sLBkcgbIkIC7Jaauw/featured.
## Results
Winners:
1. Bulbolet potato delivery using a smart hoist.
2. Copter don't hurt me controlling drone using a neural interface.
3. import torch active track using neural networks.
4. Autobot freeze light through a VK bot.
5. Stardust Crusaders AR drone simulation.

View File

@@ -1,5 +0,0 @@
# Editing files
Use **nano** text editor to edit files on a Raspberry Pi.
<!-- TODO -->

View File

@@ -1,16 +1,33 @@
Coordinate systems (frames)
===
> **Note** Documentation for the [image](image.md), versions, starting with **0.15**. For older versions refer to [documentation for version **0.14**](https://github.com/CopterExpress/clever/blob/v0.14/docs/ru/frames.md).
> **Note** The following applies to [image](image.md) version 0.15 and up. See [previous version of the article](https://github.com/CopterExpress/clever/blob/v0.14/docs/ru/frames.md) (Russian only) for older images.
![Clever coordinates systems (TF2)](../assets/frames.png)
![TF2 Clever frames](../assets/frames.png)
Main frames in package `clever`:
Main frames in the `clever` package:
* `map` coordinates relative to the point of flight controller initialization: the white grid in the illustration;
* `base_link` — coordinates relative to the quadcopter: schematic image of the quadcopter in the illustration;
* `body` — coordinates relative to the quadcopter regardless of pitch and roll: red, blue and green lines in the illustration.
* `map` has its origin at the flight controller initialization point and may be considered stationary. It is shown as a white grid on the image above;
* `base_link` is rigidly bound to the drone. It is shown by the simplified drone model on the image above;
* `body` is bound to the drone, but its Z axis points up regardless of the drone's pitch and roll. It is shown by the red, blue and green lines in the illustration;
* `navigate_target` is bound to the current navigation target (as set by the [navigate](simple_offboard.md#navigate) service).
> **Hint** In accordance with [the agreement](http://www.ros.org/reps/rep-0103.html), for frames associated with the copter, the X-axis directed forward, Y to the left, and Z up.
Additional frames become available when [ArUco positioning system](aruco.md) is active:
More clearly, 3D visualization of the coordinate systems can be viewed using [rviz](rviz.md).
* `aruco_map` is bound to the currently active [ArUco map](aruco_map.md);
* `aruco_N` is bound to the [marker](aruco_marker.md) with ID=N.
> **Hint** Frames that are bound to the drone are oriented according to [the ROS convention](http://www.ros.org/reps/rep-0103.html): the X axis points forward, Y to the left, and Z up.
3D visualization of the coordinate systems can be viewed using [rviz](rviz.md).
tf2
--
Read more at http://wiki.ros.org/tf2
tf2 ROS package is used extensively in the Clever platform. tf2 is a set of libraries for C++, Python and other programming languages that are used to work with the frames. Internally, ROS nodes publish `TransformStamped` messages to `/tf` topic with transforms between frames at certain points in time.
The [`simple_offboard`](simple_offboard.md) node can be used to request the drone position in an arbitrary frame by setting the `frame_id` argument appropriately in a call to `get_telemetry` service.
tf2 can be used from Python to transform coordinates (for objects like PoseStamped and PointStamped) from one frame to another

View File

@@ -67,3 +67,5 @@ Change parameter `gcs_bridge` in the launch file:
```
After opening the QGroundControl application, the connection should be established automatically.
**Next**: [Remote access using SSH](ssh.md)

146
docs/en/jetson_nano.md Normal file
View File

@@ -0,0 +1,146 @@
# Clever and Jetson Nano
## Jetson Nano overview
[Jetson Nano](https://developer.nvidia.com/embedded/jetson-nano-developer-kit) is a system-on-a-module by Nvidia. It is built on a Tegra X1 platform. With four ARM Cortex-A57 cores clocked at 1.4 GHz, 4 GB of RAM and a relatively powerful GPU, it is more capable than a Raspberry Pi 3 series of single-board computers.
<img src="../assets/jetson_nano/00-jetson-nano-board.jpg" class="zoom">
Jetson Nano developer kits come with a carrier board that has USB 3.0, CSI and Ethernet ports, as well as a row of GPIO pins. The carrier board is only slightly larger than a Raspberry Pi computer, making it a viable option for an onboard computer.
> **Note** The default carrier board does not have a Wi-Fi chip installed. You can use a USB Wi-Fi adapter or install a Wi-Fi card in the M.2 slot on the carrier board. Be sure to check your adapter for compatibility with the Jetson Nano!
## Setting up
Nvidia provides an SD card image with an operating system based on Ubuntu Linux 18.04 for Jetson Nano. This image is a good starting point for ROS and Clever installation.
### Initial system setup
> **Hint** Be sure to check the [official Getting Started instructions](https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit) for the Jetson Nano developer kit!
For the initial setup you'll need an HDMI or DisplayPort monitor, a keyboard and a mouse. Download the [Jetson Nano developer kit image](https://developer.nvidia.com/jetson-nano-sd-card-image-r3231) and flash it on a microSD card (a 32+ GB card is strongly recommended). Plug the card into the Jetson Nano module, connect your monitor, keyboard, and mouse to the carrier board, and power up the Jetson Nano.
> **Hint** Jetson Nano can be powered by a microUSB cable, but we strongly suggest using a good power supply and a barrel jack connector. You'll need to put a jumper on the J48 pins (they are right next to the CSI connector on the carrier board).
Accept the Nvidia EULA and follow the installer prompts. The system will reboot after installation. Login with your username and password.
> **Info** We strongly recommend to choose the English system language/locale for Jetson Nano to avoid ROS compatibility issues!
If you've installed a Wi-Fi adapter, you may want to configure your Jetson Nano to connect to your Wi-Fi network automatically. Once the system is installed and booted up, click on the "wireless network" icon in the top bar, choose "Edit Connections..." in the drop-down menu, select your network name from the list and click on the gear icon at the bottom of the window.
<img src="../assets/jetson_nano/01-network-config.png" class="zoom">
Go to the "General" tab in the newly-opened window and check the "All users may connect to this network" checkbox. Press the "Save" button to close the window.
> **Hint** You may want to make sure you're able to access your Jetson Nano over the network. The image already has SSH enabled, and it's more convenient to perform next steps using the remote shell.
### Installing ROS
> **Hint** Ubuntu 18.04 is officially supported as a base system for ROS Melodic. Be sure to [check the official installation instructions](http://wiki.ros.org/melodic/Installation/Ubuntu)!
Add OSRF keys and repositories to your system:
```bash
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt update
```
Install base ROS packages:
```bash
sudo apt install ros-melodic-ros-base
```
Enable your ROS environment and update your `rosdep` cache:
```bash
source /opt/ros/melodic/setup.bash
sudo rosdep init
rosdep update
```
> **Hint** You may wish to put the `source /opt/ros/melodic/setup.bash` line at the end of your user's `.profile` file.
Install pip for Python 2 (while this is not technically a part of ROS, some dependencies are only installable using pip):
```bash
sudo apt install curl
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python ./get-pip.py
```
### Building Clever nodes
Create a "workspace" directory in your home folder and populate it with Clever packages:
```bash
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/CopterExpress/clever
git clone https://github.com/CopterExpress/ros_led
git clone https://github.com/okalachev/vl53l1x_ros
```
Install dependencies using `rosdep`:
```bash
cd ~/catkin_ws
rosdep install --from-paths src --ignore-src -y
```
Install geographiclib datasets (they are required for mavros, but are not packaged with it):
```bash
curl https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh -o install_geographiclib_datasets.sh
chmod a+x ./install_geographiclib_datasets.sh
sudo ./install_geographiclib_datasets.sh
```
Install development libraries for OpenCV 3.2 (recent Jetson Nano images have OpenCV 4.1.1 preinstalled; using this version will result in build failures):
```bash
sudo apt install libopencv-dev=3.2.0+dfsg-4ubuntu0.1
```
Finally, build the Clever nodes:
```bash
cd ~/catkin_ws
catkin_make
```
> **Hint** You may also want to add udev rules for PX4 flight controllers. Copy [the rules file](https://github.com/CopterExpress/clever/blob/master/clever/config/99-px4fmu.rules) to `/etc/udev/rules.d` and run `sudo udevadm control --reload-rules && sudo udevadm trigger`.
### Running Clever nodes
Set up the workspace environment:
```bash
cd ~/catkin_ws
source devel/setup.bash
```
Configure the launch files to your taste and use `roslaunch` to launch the nodes:
```bash
roslaunch clever clever.launch
```
> **Hint** You may want to start the Clever nodes automatically. This can be done with `systemd`: look at service files for [`roscore`](https://github.com/CopterExpress/clever/blob/master/builder/assets/roscore.service) and [`clever`](https://github.com/CopterExpress/clever/blob/master/builder/assets/clever.service) that are used in our image and adjust them as necessary.
## Caveats
### CSI cameras
Jetson Nano currently does not support older Raspberry Pi v1 cameras (that are based on the Omnivision OV5647 sensor). Raspberry Pi v2 cameras (the ones that use Sony IMX219) are supported, but are not available as Video4Linux devices.
Fortunately, these cameras are available using GStreamer. You can try using the [`gscam`](http://wiki.ros.org/gscam) ROS package or our [`jetson_camera`](https://github.com/sfalexrog/jetson_camera) node. The latter requires you to build OpenCV 3.4 from source with GStreamer support.
The GStreamer pipelines are available at [JetsonHacksNano CSI camera reposotory](https://github.com/JetsonHacksNano/CSI-Camera).
You may also notice that the camera image has a red tint that is more pronounced near the edges. This can be fixed by image signal processor tuning. Generally this should be done by your camera manufacturer; [here is a sample ISP configuration](https://www.arducam.com/docs/camera-for-jetson-nano/fix-red-tint-with-isp-tuning/) from Adrucam
### LED strip
Jetson Nano currently does not support LED strips over GPIO.

15
docs/en/models.md Normal file
View File

@@ -0,0 +1,15 @@
# Model files for parts
This page contains models and drawings of some of the drone parts. They can be used for 3D printing and/or laser cutting replacement parts.
## Clever 4
### Battery holder
File: [`battery_holder.stl`](https://github.com/CopterExpress/clever/raw/master/docs/assets/battery_holder.stl).
Filament: PLA/ABS/SBS.
Infill: 50% or more.
Description: the holder should be installed on the top deck. It allows the user to secure the battery with the battery strap and to mount your battery level indicator using a 3M pad.

View File

@@ -35,7 +35,7 @@ In manual mode the pilot controls the drone directly. GPS, computer vision data,
* **ALTCTL** (ALTITUDE) — control of the altitude rate, pitch, roll and yaw angular velocity. Requires a barometer or another altitude source.
* **POSCTL** (POSITION) — control of the altitude rate, forward/backward and right/left speed, and yaw angular velocity. It is the easiest flying mode. The barometer, GPS, computer vision, and other sensors are used.
### Auto flight modes
### Auto flight modes {#auto}
In autonomous flight modes the quadcopter ignores the control signals from the transmitter and uses a program to fly.

View File

@@ -20,6 +20,8 @@ Optical Flow publishes data in `mavros/px4flow/raw/send` topic. In the topic `op
## Setup of the flight controler
> **Hint** Suggested parameters are applied automatically in [our custom PX4 firmware](firmware.md#modified-firmware-for-clever).
When using **EKF2** (parameter `SYS_MC_EST_GROUP` = `ekf2`):
* `EKF2_AID_MASK` flag 'use optical flow' is on.

96
docs/en/programming.md Normal file
View File

@@ -0,0 +1,96 @@
# Programming
<img src="../assets/programming.png" width="250" align="right">
The Clever platform allows a [Raspberry Pi](raspberry.md) computer to be used for programming autonomous flights. The flight program is typically written using the Python programming language. The program may [receive telemetry data](simple_offboard.md#get_telemetry) (which includes battery data, attitude, position, and other parameters) and send commands like: [fly to a point in space](simple_offboard.md#navigate), [set attitude](simple_offboard.md#set_attitude), [set angular rates](simple_offboard.md#set_rates), and others.
The platform utilizes the [ROS framework](ros.md), which allows the user program to communicate with the Clever services that are running as a `clever` systemd daemon. The [MAVROS](mavros.md) package is used to interact with the flight controller.
PX4 uses [OFFBOARD mode](modes.md#auto) for autonomous flights. The Clever API can be used to transition the drone to this flight mode automatically. If you need to interrupt the autonomous flight, use your flight mode stick on your RC controller to transition to any other flight mode.
## Positioning system {#positioning}
A drone has to use a positioning system to be able to hover still or to fly from point to point. The system should compute the drone position and feed this data into the flight controller. Clever allows using multiple positioning systems, such as [optical flow](optical_flow.md) (requires a [camera](camera.md) and a [rangefinder](laser.md)), [fiducial markers](aruco.md) (requires a camera and markers), GPS and others.
### Optical flow
Optical flow is used to compute shifts between consecutive frames and to use this data to compute the drone shifting in space.
Read more in the [Optical Flow article](optical_flow.md).
### ArUco markers
Fiducial markers allow the drone to compute its position relative to these markers. This data may then be transferred to the flight controller.
Read more about [ArUco markers](aruco.md) in our articles about them.
### GPS (outdoor flight)
GPS allows you to specify global Earth coordinates (latitude and longitude). The [`navigate_global`](simple_offboard.md#navigate_global) function takes these as parameters instead of the usual cartesian coordinates.
Read more in the [GPS connection](gps.md) article.
## Autonomous flight {#flight}
After you've configured your positioning system, you can start writing programs for autonomous flights. Use the [SSH connection to the Raspberry Pi](ssh.md) to run your scripts. In order to run a Python script use the `python` command:
```bash
python flight.py
```
Below is a complete flight program that performs a takeoff, flies forward and lands:
```python
#coding: utf8
import rospy
from clever import srv
from std_srvs.srv import Trigger
rospy.init_node('flight')
get_telemetry = rospy.ServiceProxy('get_telemetry', srv.GetTelemetry)
navigate = rospy.ServiceProxy('navigate', srv.Navigate)
land = rospy.ServiceProxy('land', Trigger)
# Takeoff and hover 1 m above the ground
navigate(x=0, y=0, z=1, frame_id='body', auto_arm=True)
# Wait for 3 seconds
rospy.sleep(3)
# Fly forward 1 m
navigate(x=1, y=0, z=0, frame_id='body')
# Wait for 3 seconds
rospy.sleep(3)
# Perform landing
land()
```
> **Note** The `navigate` function call is not blocking; that is, the program will continue executing the next commands before the drone arrives at the set point. Look at the [`navigate_wait`](snippets.md#block-nav) snippet for a blocking function.
Note that only the first `navigate` call has its `auto_arm` parameter set to `True`. This parameter arms the drone and transitions it to the OFFBOARD flight mode.
The `frame_id` parameter specifies which frame of reference will be used for the target point:
* `body` is rigidly bound to the drone body;
* `navigate_target` has its origin at the last target point for `navigate`;
* `map` is the drone's local frame;
* `aruco_map` is bound to the ArUco marker map;
* `aruco_N` is bound to the marker with ID=N.
Read more in the [coordinate systems](frames.md) article.
You can also use the ["Autonomous flight"](simple_offboard.md) article as an API reference.
## Additional periphery
The Clever platform also exposes APIs for interacting with other peripherals. Read more in the following articles:
* [LED strip](leds.md);
* [laser rangefinder](laser.md);
* [GPIO](gpio.md);
* [ultrasonic rangefinder](sonar.md);
* [camera](camera.md).

View File

@@ -3,7 +3,9 @@ Raspberry Pi
**Raspberry Pi** is a single-board computer that fits in the palm, created on the basis of ARM mobile microprocessor. It features low energy consumption, and it can even run on solar panels. Raspberry Pi 3 is included in the kits for programmable quadcopters "Clever".
<img src="../assets/raspberry3.jpg" width="500">
<img src="../assets/raspberry.png" class="center zoom" alt="Raspberry Pi 3" width="400">
Technical specifications:
* Weight is 45 grams.
* Clock rate is 1.2 GHz.
@@ -12,19 +14,6 @@ Raspberry Pi
* Four USB 2.0 ports.
* An HDMI port.
The scope of Raspberry Pi computer application is quite wide, since after all it is quite a full-fledged computer. If you need a machine to solve simple problems that do not require too many resources in terms of calculations, you can safely connect your Raspberry Pi device to the standard PC elements: a monitor, a mouse, or a keyboard.
Raspberry Pi is connected to the flight controller in the Clever kit and is used as a companion computer. It can be used to [connect to the drone over Wi-Fi](wifi.md), perform autonomous flights, access peripherals and much more.
The Raspberry Pi is a very popular platform where you can implement a variety of projects, such as:
* a home automation server (or a "smart house" system);
* a data storage server (NAS);
* a home media server;
* a "think-tank" for automated machines or robots.
In fact, we will use it as the last in the list, due to its ability to connect to the Pixhawk autopilot.
See more:
* [RPi image](image.md)
* [SSH access](ssh.md)
* [Network setup](network.md)
**Next**: [Raspberry Pi image](image.md)

View File

@@ -1,14 +1,10 @@
# ROS Kinetic package installation and setup
# ROS Melodic package installation and setup
In order to use tools such as rqt, rviz and others as well as running the simulator (SITL), you will need to install and setup ROS package
> **Hint** For more details on installation refer to [the main article](http://wiki.ros.org/kinetic/Installation/Ubuntu).
> **Hint** For more details on installation refer to [the main article](http://wiki.ros.org/melodic/Installation/Ubuntu).
<!-- -->
> **Hint** If you are using Ubuntu 18.04, you will need to install ROS Melodic instead of ROS Kinetic. A complete guide of the installation is available [here](http://wiki.ros.org/melodic/Installation/Ubuntu).
## ROS Kinetic installation on Ubuntu
## ROS Melodic installation on Ubuntu
To find the correct package version, you will need to change the settings of your repositories. Go to "Software and updates" and enable `restricted`, `universe` and `multiverse`.
@@ -35,13 +31,13 @@ Now you can install the ROS package itself.
+ If you plan to use ROS together with the simulator (also includes tools such as rqt, rviz and others):
```bash
sudo apt-get install ros-kinetic-desktop-full
sudo apt-get install ros-melodic-desktop-full
```
+ If you plan to use ROS exclusively for tools rqt, rviz etc.:
```bash
sudo apt-get install ros-kinetic-desktop
sudo apt-get install ros-melodic-desktop
```
After the package has installed, initialize `rosdep`.
@@ -55,12 +51,12 @@ rosdep update
If you are not confortable with entering environment variables manually each time, you may configure it in a way that it add itself in your bash session on every new shell startup:
```bash
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
```
If you whish to install any additionnal packages for yout ROS Kinetic simply use:
If you whish to install any additionnal packages for yout ROS Melodic simply use:
```bash
sudo apt-get install ros-kinetic-PACKAGE
sudo apt-get install ros-melodic-PACKAGE
```

View File

@@ -8,13 +8,13 @@ ROS is a widely used framework for developing complex and distributed robotic sy
Installation
---
Main article: http://wiki.ros.org/kinetic/Installation/Ubuntu
Main article: http://wiki.ros.org/melodic/Installation/Ubuntu
ROS is already installed on [the RPi image](image.md).
To use ROS on a PC, we recommend using Ubuntu Linux (or a virtual machine such as Parallels Desktop Lite](https://itunes.apple.com/ru/app/parallels-desktop-lite/id1085114709?mt=12) or [VirtualBox](https://www.virtualbox.org)).
> **Note** For ROS Kinetic distribution, we recommend using Ubuntu 16.04.
> **Note** For ROS Melodic distribution, we recommend using Ubuntu 18.04.
Concepts
---

View File

@@ -9,7 +9,7 @@ The [rviz] tool(http://wiki.ros.org/rviz) allows real-time visualization of all
To use rviz and rqt, a PC running Ubuntu Linux (or a virtual machine such as [Parallels Desktop Lite] (https://itunes.apple.com/ru/app/parallels-desktop-lite/id1085114709?mt=12) or [VirtualBox] (https://www.virtualbox.org)) is required.
Install package `ros-kinetic-desktop-full` or `ros-kinetic-desktop` using the [installation documentation](http://wiki.ros.org/kinetic/Installation/Ubuntu).
Install package `ros-melodic-desktop-full` or `ros-melodic-desktop` using the [installation documentation](http://wiki.ros.org/melodic/Installation/Ubuntu).
Start rviz
---
@@ -48,7 +48,7 @@ Axis or Grid configured to frame `aruco_map` will visualize the location [on the
It is also recommended to install additional useful plugins for rviz [jsk_rviz_plugins](https://jsk-docs.readthedocs.io/en/latest/jsk_visualization/doc/jsk_rviz_plugins/index.html). This kit allows visualizing topics like `TwistStamped` (velocity) `CameraInfo`, `PolygonArray`, and many more. To install, use command:
```(bash)
sudo apt-get install ros-kinetic-jsk-visualization
sudo apt-get install ros-melodic-jsk-visualization
```
Starting the rqt toolkit
@@ -71,5 +71,5 @@ ROS_MASTER_URI=http://192.168.11.1:11311 rqt_image_view
Brief description of useful rqt plugins:
* `rqt_image_view` viewing images from topics like `sensor_msgs/Image`;
* `rqt_multiplot` Building charts from the data from of arbitrary topics (installation: `sudo apt-get install ros-kinetic-rqt-multiplot`);
* `rqt_multiplot` Building charts from the data from of arbitrary topics (installation: `sudo apt-get install ros-melodic-rqt-multiplot`);
* Bag working with [Bag-files](http://wiki.ros.org/rosbag).

View File

@@ -21,7 +21,9 @@ Description of some checks:
* Global position (GPS) — checks for presence of global position data (GPS module is required for this check);
* Camera — checks for proper operation of the Raspberry camera.
* ArUco — checks whether [ArUco](aruco.md) detection is working
* VPE — checks whether VPE data is published
* Rangefinder — checks whether [rangefinder](laser.md) data is published
* VPE — checks whether VPE data is published.
* Rangefinder — checks whether [rangefinder](laser.md) data is published.
* RPi health checks the [onboard computer](raspberry.md) status.
* CPU usage checks the CPU load of the onboard computer.
> **Caution** Pay attention on the checks marked with *WARN* sign. If necessary, contact [Copter Express technical support](tg://resolve?domain=COEXHelpdesk).

View File

@@ -1,11 +1,11 @@
Simple OFFBOARD
===
> **Note** Documentation for the [image](image.md), versions, starting with **0.15**. For older versions refer to [documentation for version **0.14**](https://github.com/CopterExpress/clever/blob/v0.14/docs/ru/simple_offboard.md).
> **Note** The following applies to [image](image.md) versions **0.15** and up. Older documentation is still avaliable [for version **0.14**](https://github.com/CopterExpress/clever/blob/v0.14/docs/ru/simple_offboard.md) (Russian only).
<!-- -->
> **Hint** For autonomous flights it is recommanded to use [special PX4 firmware for Clever](firmware.md#modified-firmware-for-clever).
> **Hint** We recommend using our [special PX4 firmware for Clever](firmware.md#modified-firmware-for-clever) for autonomous flights.
The `simple_offboard` module of the `clever` package is intended for simplified programming of the autonomous drone flight (`OFFBOARD` [flight mode](modes.md)). It allows setting the desired flight tasks, and automatically transforms [coordinates between frames](frames.md).
@@ -140,6 +140,12 @@ Flying 3 m to the right from the drone:
navigate(x=0, y=-3, z=0, speed=1, frame_id='body')
```
Flying 2 m to the left from the last navigation target:
```python
navigate(x=0, y=2, z=0, speed=1, frame_id='navigate_target')
```
Turn 90 degrees counterclockwise:
```python
@@ -170,6 +176,8 @@ Ascending to the altitude of 2 m (command line):
rosservice call /navigate "{x: 0.0, y: 0.0, z: 2, yaw: 0.0, yaw_rate: 0.0, speed: 0.5, frame_id: 'body', auto_arm: true}"
```
> **Note** Consider using the `navigate_target` frame instead of `body` for missions that primarily use relative movements forward/back/left/right. This negates inaccuracies in relative point calculations.
### navigate_global
Flying in a straight line to a point in the global coordinate system (latitude/longitude).

View File

@@ -120,6 +120,7 @@ Transforming the position (`PoseStamped`) from one system of coordinates ([of fr
```python
import tf2_ros
import tf2_geometry_msgs
from geometry_msgs.msg import PoseStamped
tf_buffer = tf2_ros.Buffer()
tf_listener = tf2_ros.TransformListener(tf_buffer)

View File

@@ -124,7 +124,7 @@ Ultrasonic distance gage RCW-0001 is compatible with distance gage HC-SR04. Use
An example of a flight program with the use of [simple_offboard](simple_offboard.md), which makes the copter fly forward until the connected ultrasonic distance gage detects an obstacle:
```python
set_velocity(x=0.5, frame_id='body', auto_arm=True) # flying forward at the velocity of 0.5 mps
set_velocity(vx=0.5, frame_id='body', auto_arm=True) # flying forward at the velocity of 0.5 mps
while True:
if read_distance_filtered() < 1:

Some files were not shown because too many files have changed in this diff Show More