Compare commits

...

108 Commits

Author SHA1 Message Date
Alexey Rogachevskiy
5ae0da18b9 Merge branch 'master' into buster 2019-11-18 17:17:56 +03:00
Alexey Rogachevskiy
586442560e builder: Add opencv repository 2019-11-13 17:43:54 +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
Alexey Rogachevskiy
9ff7e4a64d Merge remote-tracking branch 'origin/master' into buster 2019-10-12 04:10:39 +03:00
Alexey Rogachevskiy
b5ff8388b2 selfcheck: Update systemd-analyze regex 2019-10-12 04:09:32 +03:00
Alexey Rogachevskiy
46816ee959 docs/CopterHack2019: Add note about camera orientation 2019-10-12 03:53:49 +03:00
Oleg Kalachev
7d475d9d4d docs: fix 2019-10-12 01:02:25 +03:00
Oleg Kalachev
a1745018f9 docs: fixes 2019-10-12 00:52:10 +03:00
Oleg Kalachev
be2afe5d3e docs: update copter hack 2019 info 2019-10-12 00:47:51 +03:00
Alamoris
bfedba50f3 docs: copterhack2019: add paragraph about setting up coex pix (#182)
* copterhack2019: add paragraph about setting up coex pix

* FIx
2019-10-12 00:43:32 +03:00
Alexey Rogachevskiy
e3fc40f2b7 Merge remote-tracking branch 'origin' into buster 2019-10-10 23:32:37 +03:00
Oleg Kalachev
98bfb6eb81 docs: create Copter Hack 2019 page 2019-10-10 18:23:39 +03:00
Alexey Rogachevskiy
3640f09d82 aruco_pose: Remove unused vendored code 2019-10-09 19:15:53 +03:00
Oleg Kalachev
88d05af777 Merge pull request #181 from sfalexrog/camera_updates
Camera documentation updates
2019-10-08 13:11:48 +03:00
Alexey Rogachevskiy
7db345ddd5 docs: Add manual exposure parameters (en/ru) 2019-10-07 16:46:48 +03:00
Alexey Rogachevskiy
975b348b90 docs: Update camera EN article 2019-10-07 15:29:42 +03:00
Alexey Rogachevskiy
31c6944b52 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.
2019-10-07 14:40:06 +03:00
Alexey Rogachevskiy
70684d952f Merge remote-tracking branch 'origin' into buster 2019-10-07 14:26:06 +03:00
Alexey Rogachevskiy
6457dffb73 builder: Move ld.so.preload back after tests 2019-10-07 14:23:49 +03:00
sfalexrog
f42392888c clever/led: Remove return type from notify 2019-10-07 14:18:41 +03:00
sfalexrog
7b0b3c751b builder: Use default kernel 2019-10-06 21:05:51 +03:00
sfalexrog
d833151963 builder: Use more recent base image 2019-10-06 19:23:00 +03:00
Oleg Kalachev
6f3ced98cb docs: fix sonar sample 2019-10-01 15:55:25 +02:00
Oleg Kalachev
a6bdedbfc1 selfcheck.py: fix velocity check 2019-09-27 00:39:24 +03:00
Oleg Kalachev
68fc2fee1a vpe_publisher: quick fix 2019-09-26 00:44:03 +03:00
Oleg Kalachev
a4fa53ba1b vpe_publisher: implement ~reset service 2019-09-25 23:59:48 +03:00
sfalexrog
25fe4397ee builder: Install tornado==4.2.1 for rosbridge_suite 2019-09-24 16:42:40 +03:00
Oleg Kalachev
3ba4ebf3a2 gitbook: make main page language select 2019-09-17 03:15:10 +03:00
Oleg Kalachev
5c2441e2e8 image: add importing SetLedEffect in tests 2019-09-16 20:24:13 +03:00
Oleg Kalachev
45356b19a9 docs: add note about flying relative to a marker in the map 2019-09-15 17:53:15 +03:00
Alexey Rogachevskiy
35ac2396f0 Merge branch 'master' into buster 2019-09-13 00:57:34 +03:00
Alexey Rogachevskiy
99f305cdd2 builder: Re-add mjpgstreamer 2019-09-12 21:39:13 +03:00
Alexey Rogachevskiy
e1a11bd70a aruco_pose: Allow rgb8 map images 2019-09-11 23:10:36 +03:00
Alexey Rogachevskiy
035384cd6f builder: Make tests run again 2019-09-11 21:56:10 +03:00
Alexey Rogachevskiy
a0b67f51c3 aruco_pose: Allow rgb8 map images (again) 2019-09-11 21:33:46 +03:00
Alexey Rogachevskiy
915fbdfcc0 builder: Disable mjpg_streamer test 2019-09-11 21:09:21 +03:00
Alexey Rogachevskiy
239eaf715d aruco_pose: Accept rgb8 map images 2019-09-11 21:07:40 +03:00
Oleg Kalachev
16a2ecef2e gitbook: fix 2019-09-11 20:59:20 +03:00
Alexey Rogachevskiy
22e1bd6b92 builder: Use correct file types for standalone install 2019-09-11 20:55:08 +03:00
Alexey Rogachevskiy
540428aefc builder: Add repo for standalone build 2019-09-11 20:45:57 +03:00
Alexey Rogachevskiy
2ea0eb0783 builder: Use -y for package installation 2019-09-11 18:55:01 +03:00
sfalexrog
24b1cd12ba builder: Set permissions for standalone-install 2019-09-11 18:50:06 +03:00
sfalexrog
06df5cc31a travis: Add native tests 2019-09-11 18:17:19 +03:00
sfalexrog
0a945cc6bf builder: Remove unused builder code 2019-09-11 18:10:07 +03:00
sfalexrog
78603f5f9c builder: Add led packages 2019-09-11 18:09:05 +03:00
sfalexrog
cdc3a1bbc9 aruco_pose: Vendor opencv_contrib/aruco again 2019-09-11 18:03:55 +03:00
sfalexrog
8a6f6ab147 Revert "aruco_pose: Vendor in aruco library from OpenCV 3.4.6"
This reverts commit 9c14a8c002bb3396f9a7d9b2ba39969207f066ba.
2019-09-11 18:03:55 +03:00
sfalexrog
3b19e60111 roscore: Use melodic distribution 2019-09-11 18:03:55 +03:00
sfalexrog
eff5a535e3 tests: Don't try to locate opencv in ros 2019-09-11 18:03:55 +03:00
sfalexrog
fc9ab73640 travis: Disable eclint for vendored aruco library 2019-09-11 18:03:55 +03:00
sfalexrog
512a389670 aruco_pose: Vendor in aruco library from OpenCV 3.4.6 2019-09-11 18:03:55 +03:00
sfalexrog
077ccf0954 builder: Update rosdep 2019-09-11 18:03:55 +03:00
sfalexrog
04d10ed337 aruco_pose, clever: Remove opencv3 ROS dependency 2019-09-11 18:03:55 +03:00
sfalexrog
ae07f2fb01 builder: Update kernel version 2019-09-11 18:03:55 +03:00
sfalexrog
a83ef3a9ad builder: Move to ROS Melodic 2019-09-11 18:03:55 +03:00
sfalexrog
84106ec919 builder: Search for buster ROS packages 2019-09-11 17:58:48 +03:00
sfalexrog
72dfa64678 builder: Use coex repo to install Monkey 2019-09-11 17:58:48 +03:00
sfalexrog
bdcf383408 builder: Move ld.so.preload to have less errors 2019-09-11 17:58:48 +03:00
sfalexrog
b08d2859e1 builder: Use correct repository specifications 2019-09-11 17:58:48 +03:00
sfalexrog
851a978859 builder: Build against Buster 2019-09-11 17:57:14 +03:00
Tenessinum
727fde82a8 docs: change size of iframes in Big Challenges article (#177) 2019-09-10 17:28:11 +03:00
Oleg Kalachev
fc1df980ff docs: fix link to the latest firmware 2019-09-10 16:25:39 +03:00
Alexey Rogachevskiy
2e7bcde38e docs: Revise simple_offboard translation (en) 2019-09-10 14:23:06 +03:00
Alexey Rogachevskiy
5a8ce0cf0c docs/en: Remove non-English words 2019-09-09 22:41:18 +03:00
Oleg Kalachev
e78c57a734 Change Clever documentation domain name 2019-09-09 16:22:48 +03:00
Oleg Kalachev
9581cc6496 Create CNAME 2019-09-09 16:13:19 +03:00
Oleg Kalachev
eddec45259 gitbook: make redirect pages blank 2019-09-08 00:45:30 +03:00
93 changed files with 43424 additions and 456 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

@@ -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
@@ -73,8 +89,8 @@ jobs:
github-token: ${GITHUB_OAUTH_TOKEN}
keep-history: true
target-branch: master
repo: CopterExpress/clever-gitbook
fqdn: clever.copterexpress.com
repo: CopterExpress/clever.coex.tech
fqdn: clever.coex.tech
verbose: true
on:
branch: master
@@ -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"
stages:
- Build
- Annotate

View File

@@ -6,7 +6,7 @@ CLEVER (Russian: *"Клевер"*, meaning *"Clover"*) is an educational program
Copter Express has implemented a large number of different autonomous drone projects using exactly the same platform: [automated pizza delivery](https://www.youtube.com/watch?v=hmkAoZOtF58) in Samara and Kazan, coffee delivery in Skolkovo Innovation Center, [autonomous quadcopter with charging station](https://www.youtube.com/watch?v=RjX6nUqw1mI) for site monitoring and security, winning drones on [Robocross-2016](https://www.youtube.com/watch?v=dGbDaz_VmYU) and [Robocross-2017](https://youtu.be/AQnd2CRczbQ) competitions and many others.
**The main documentation is available [on Gitbook](https://clever.copterexpress.com/).**
**The main documentation is available [on Gitbook](https://clever.coex.tech/).**
Use it to learn how to assemble, configure, pilot and program autonomous CLEVER drone.
@@ -18,19 +18,19 @@ 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
* Periphery drivers (`pigpiod`, `rpi_ws281x`, etc)
* CLEVER software bundle for autonomous drone control
API description (in Russian) for autonomous flights is available [on GitBook](https://clever.copterexpress.com/simple_offboard.html).
API description (in Russian) for autonomous flights is available [on GitBook](https://clever.coex.tech/simple_offboard.html).
## 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,8 @@
<depend>tf2</depend>
<depend>tf2_ros</depend>
<depend>tf2_geometry_msgs</depend>
<depend>opencv3</depend>
<!-- FIXME: OpenCV3 is not in Melodic -->
<!-- <depend>opencv3</depend> -->
<depend>cv_bridge</depend>
<depend>image_transport</depend>
<depend>message_generation</depend>

View File

@@ -140,7 +140,7 @@ def test_map_image(node):
img = rospy.wait_for_message('aruco_map/image', Image, timeout=5)
assert img.width == 2000
assert img.height == 2000
assert img.encoding == 'mono8'
assert img.encoding in ('mono8', 'rgb8')
def test_map_markers(node):
markers = rospy.wait_for_message('aruco_map/markers', MarkerArray, timeout=5)

View File

@@ -17,7 +17,7 @@ class TestArucoPose(unittest.TestCase):
img = rospy.wait_for_message('aruco_map/image', Image, timeout=5)
self.assertEqual(img.width, 2000)
self.assertEqual(img.height, 2000)
self.assertEqual(img.encoding, 'mono8')
self.assertIn(img.encoding, ('mono8', 'rgb8'))
def test_map_visualization(self):
vis = rospy.wait_for_message('aruco_map/visualization', VisMarkerArray, timeout=5)

View File

@@ -58,4 +58,4 @@ def test_map_image(node):
img = rospy.wait_for_message('aruco_map/image', Image, timeout=5)
assert img.width == 2000
assert img.height == 2000
assert img.encoding == 'mono8'
assert img.encoding in ('mono8', 'rgb8')

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

@@ -2,7 +2,7 @@
"title": "Clever",
"description": "Конструктор квадрокоптера «Клевер»",
"author": "Copter Express",
"language": "ru",
"language": "en",
"root": "docs/",
"gitbook": "^3.2.2",
"plugins": [
@@ -24,10 +24,11 @@
},
"bulk-redirect": {
"basepath": "",
"redirectsFile": "redirects.json"
"redirectsFile": "redirects.json",
"blank": true
},
"sitemap": {
"hostname": "https://clever.copterexpress.com"
"hostname": "https://clever.coex.tech"
},
"toolbar": {
"buttons":

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,723 @@
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:
stretch: ros-melodic-ws281x

View File

@@ -4,7 +4,7 @@ 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

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'}
@@ -110,7 +110,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

@@ -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,25 +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 # 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"
catkin_make run_tests && catkin_test_results
cd /home/pi/catkin_ws
# 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
@@ -192,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,59 @@ 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://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
# FIXME: We still don't have these packages built for Buster
# FIXME: Check these packages after their installation
echo "deb http://deb.coex.tech/clever stretch 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 \
&& 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,14 @@ 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
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

@@ -15,7 +15,7 @@ from mavros_msgs.srv import CommandBool, CommandLong, SetMode
from std_srvs.srv import Trigger
from clever.srv import GetTelemetry, Navigate, NavigateGlobal, SetPosition, SetVelocity, \
SetAttitude, SetRates
SetAttitude, SetRates, SetLEDEffect
import tf2_ros
import tf2_geometry_msgs

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

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

@@ -3,7 +3,7 @@
<arg name="aruco_map" default="false"/>
<arg name="aruco_vpe" default="false"/>
<!-- For additional help go to https://clever.copterexpress.com/aruco.html -->
<!-- For additional help go to https://clever.coex.tech/aruco -->
<!-- aruco_detect: detect aruco markers, estimate poses -->
<node name="aruco_detect" pkg="nodelet" if="$(arg aruco_detect)" type="nodelet" args="load aruco_pose/aruco_detect nodelet_manager" output="screen" clear_params="true">

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 -->

View File

@@ -3,13 +3,13 @@
<arg name="led_effect" default="true"/>
<arg name="led_notify" default="true"/>
<!-- For additional help go to https://clever.copterexpress.com/led.html -->
<!-- For additional help go to https://clever.coex.tech/led -->
<!-- ws281x led strip driver -->
<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

@@ -2,7 +2,7 @@
<!-- Camera position and orientation are represented by base_link -> main_camera_optical transform -->
<!-- static_transform_publisher arguments: x y z yaw pitch roll frame_id child_frame_id -->
<!-- article about camera setup: https://clever.copterexpress.com/camera_frame.html -->
<!-- article about camera setup: https://clever.coex.tech/camera_frame -->
<!-- camera is oriented downward, camera cable goes backward [option 1] -->
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0.05 0 -0.07 -1.5707963 0 3.1415926 base_link main_camera_optical"/>

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

@@ -7,7 +7,7 @@
<maintainer email="okalachev@gmail.com">Oleg Kalachev</maintainer>
<license>MIT</license>
<url type="website">https://clever.copterexpress.com/</url>
<url type="website">https://clever.coex.tech/</url>
<author email="okalachev@gmail.com">Oleg Kalachev</author>
<author email="urpylka@gmail.com">Artem Smirnov</author>
@@ -33,7 +33,8 @@
<depend>mavros_extras</depend>
<depend>cv_camera</depend>
<depend>cv_bridge</depend>
<depend>opencv3</depend>
<!-- FIXME: OpenCV3 is not in Melodic -->
<!-- <depend>opencv3</depend> -->
<depend>rosbridge_server</depend>
<depend>web_video_server</depend>
<depend>tf2_web_republisher</depend>

View File

@@ -230,7 +230,7 @@ void handleState(const led_msgs::LEDStateArray& msg)
led_count = state.leds.size();
}
bool notify(const std::string& event)
void notify(const std::string& event)
{
if (ros::param::has("~notify/" + event + "/effect") ||
ros::param::has("~notify/" + event + "/r") ||

View File

@@ -209,7 +209,7 @@ def check_fcu():
is_clever_firmware = True
if not is_clever_firmware:
failure('not running Clever PX4 firmware, check http://clever.copterexpress.com/firmware.html')
failure('not running Clever PX4 firmware, https://clever.coex.tech/firmware')
est = get_param('SYS_MC_EST_GROUP')
if est == 1:
@@ -224,6 +224,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:
@@ -244,7 +250,7 @@ def check_fcu():
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, see https://clever.copterexpress.com/power.html', cell)
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:
@@ -477,7 +483,7 @@ def check_local_position():
@check('Velocity estimation')
def check_velocity():
try:
velocity = rospy.wait_for_message('mavros/local_position/velocity', TwistStamped, timeout=1)
velocity = rospy.wait_for_message('mavros/local_position/velocity_local', TwistStamped, timeout=1)
horiz = math.hypot(velocity.twist.linear.x, velocity.twist.linear.y)
vert = velocity.twist.linear.z
if abs(horiz) > 0.1:
@@ -485,6 +491,7 @@ def check_velocity():
if abs(vert) > 0.1:
failure('vertical velocity estimation is %.2f m/s; is copter staying still?' % vert)
velocity = rospy.wait_for_message('mavros/local_position/velocity_body', TwistStamped, timeout=1)
angular = velocity.twist.angular
ANGULAR_VELOCITY_LIMIT = 0.1
if abs(angular.x) > ANGULAR_VELOCITY_LIMIT:
@@ -596,7 +603,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)

View File

@@ -479,7 +479,7 @@ inline void checkState()
throw std::runtime_error("State timeout, check mavros settings");
if (!state.connected)
throw std::runtime_error("No connection to FCU, https://clever.copterexpress.com/connection.html");
throw std::runtime_error("No connection to FCU, https://clever.coex.tech/connection");
}
#define ENSURE_FINITE(var) { if (!std::isfinite(var)) throw std::runtime_error(#var " argument cannot be NaN or Inf"); }

View File

@@ -19,11 +19,13 @@
#include <geometry_msgs/TransformStamped.h>
#include <geometry_msgs/PoseStamped.h>
#include <geometry_msgs/PoseWithCovarianceStamped.h>
#include <std_srvs/Trigger.h>
// #include <aruco_pose/MarkerArray.h>
using std::string;
using namespace geometry_msgs;
bool reset_flag = false;
string local_frame_id, frame_id, child_frame_id, offset_frame_id;
tf2_ros::Buffer tf_buffer;
ros::Publisher vpe_pub;
@@ -84,13 +86,14 @@ void callback(const T& msg)
// offset
if (!offset_frame_id.empty()) {
if (msg->header.stamp - vpe.header.stamp > offset_timeout) {
if (reset_flag || msg->header.stamp - vpe.header.stamp > offset_timeout) {
// calculate the offset
offset = tf_buffer.lookupTransform(local_frame_id, frame_id,
msg->header.stamp, ros::Duration(0.02));
// offset.header.frame_id = vpe.header.frame_id;
offset.child_frame_id = offset_frame_id;
br.sendTransform(offset);
reset_flag = false;
ROS_INFO("offset reset");
}
// apply the offset
@@ -106,6 +109,13 @@ void callback(const T& msg)
}
}
bool reset(std_srvs::Trigger::Request& req, std_srvs::Trigger::Response& res)
{
reset_flag = true;
res.success = true;
return true;
}
int main(int argc, char **argv) {
ros::init(argc, argv, "vpe_publisher");
ros::NodeHandle nh, nh_priv("~");
@@ -139,6 +149,8 @@ int main(int argc, char **argv) {
local_position_sub = nh.subscribe("mavros/local_position/pose", 1, &localPositionCallback);
}
auto reset_serv = nh_priv.advertiseService("reset", &reset);
ROS_INFO("ready");
ros::spin();
}

View File

@@ -1,7 +1,7 @@
<h1>CLEVER Drone Kit Tools</h1>
<ul>
<li><a href="docs">View documentation</a> (snapshot of <a href="http://clever.copterexpress.com">clever.copterexpress.com</a>)</li>
<li><a href="docs">View documentation</a> (snapshot of <a href="https://clever.coex.tech">clever.coex.tech</a>)</li>
<li><a href="" id="wvs">View image topics</a> (<code>web_video_server</code>)</li>
<li><a href="" id="butterfly">Open web terminal</a> (<code>Butterfly</code>)</li>
<li><a href="viz.html">View 3D visualization</a> (<code>ros3djs</code>)</li>

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.

After

Width:  |  Height:  |  Size: 80 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

View File

@@ -37,7 +37,7 @@ gitbook.events.bind('page.change', function() {
// show link to latest raspberry image
gitbook.events.bind('page.change', function() {
var el = document.querySelector('a.latest-image');
if (el.length) return;
if (!el) return;
// get latest release from GitHub
fetch('https://api.github.com/repos/CopterExpress/clever/releases').then(function(res) {

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

@@ -77,5 +77,3 @@
* [Human pose estimation drone control](human_pose_estimation_drone_control.md)
* [Copter Hack 2018](copterhack2018.md)
* [Copter Hack 2017](copterhack2017.md)
* Textbook
* [Theory and Videos](lessons.md)

View File

@@ -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,12 +120,22 @@ 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')
```
### 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
navigate(frame_id='aruco_5', x=0, y=0, z=1)
```
## Additional settings

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
@@ -339,6 +352,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

@@ -269,7 +269,7 @@ and replace map.txt with your map name.
Ctrl+x; y; Enter
```
- Перезагрузите модуль Клевер:
- Restart the `clever` service:
```bash
sudo systemctl restart clever

View File

@@ -1,12 +1,12 @@
# Working with the camera
To work with the main camera, make sure it is enabled in file `~/catkin_ws/src/clever/clever/launch/clever.launch`:
Make sure the camera is enabled in the `~/catkin_ws/src/clever/clever/launch/clever.launch` file:
```xml
<arg name="main_camera" default="true"/>
```
Also make sure that [correct position and orientation are indicated] for the camera (camera_frame.md).
Also make sure that [position and orientation of the camera](camera_frame.md) is correct.
The `clever` package must be restarted after the launch-file has been edited:
@@ -14,11 +14,41 @@ The `clever` package must be restarted after the launch-file has been edited:
sudo systemctl restart clever
```
For monitoring images from the camera, you may use rqt or [web_video_server](web_video_server.md).
You may use rqt or [web_video_server](web_video_server.md) to view the camera stream.
## Troubleshooting
If the camera stream is missing, try using the [`raspistill`](https://www.raspberrypi.org/documentation/usage/camera/raspicam/raspistill.md) utility to check whether the camera works.
First, stop the Clever service:
```bash
sudo systemctl stop clever
```
Then use `raspistill` to capture an image from the camera:
```bash
raspistill -o test-image.jpeg
```
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.
## Camera parameters
Some camera parameters, such as image size, FPS cap, and exposure, may be configured in the `main_camera.launch` file. The list of supported parameters can be found [in the cv_camera repository](https://github.com/OTL/cv_camera#parameters).
Additionally you can specify an arbitrary capture parameter using its [OpenCV code](https://docs.opencv.org/3.3.1/d4/d15/group__videoio__flags__base.html). For example, add the following parameters to the camera node to set exposition manually:
```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 -->
```
## Computer vision
For implementation of the computer vision algorithms, it is recommended to use the [OpenCV] library that is pre-installed in [the SD card image] (image.md) (https://opencv.org).
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.
### Python
@@ -66,11 +96,11 @@ The obtained images can be viewed using [web_video_server](web_video_server.md).
To program actions of the copter upon detection of [QR codes](https://en.wikipedia.org/wiki/QR_code) you can use the [ZBar] library (http://zbar.sourceforge.net). It should be installed using pip:
```(bash)
```bash
sudo pip install zbar
```
Recognizing QR codes in Python:
QR codes recognition in Python:
```python
import cv2
@@ -100,7 +130,7 @@ def image_callback(data):
image_sub = rospy.Subscriber('main_camera/image_raw', Image, image_callback, queue_size=1)
```
The script will take up to 100% CPU capacity. To slow down the script artificially, you can run [throttling](http://wiki.ros.org/topic_tools/throttle) of frames from the camera, for example, at 5 Hz (`main_camera.launch`):
The script will take up to 100% CPU capacity. To slow down the script artificially, you can use [throttling](http://wiki.ros.org/topic_tools/throttle) of frames from the camera, for example, at 5 Hz (`main_camera.launch`):
```xml
<node pkg="topic_tools" name="cam_throttle" type="throttle"

View File

@@ -1,16 +1,28 @@
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.
> **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.
More clearly, 3D visualization of the coordinate systems can be viewed using [rviz](rviz.md).
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

@@ -31,7 +31,7 @@ Before you test it you need to install on your laptop:
- Install Nodejs from [here](https://nodejs.org/en/download/). For [Ubuntu installation](https://tecadmin.net/install-latest-nodejs-npm-on-ubuntu/)
- Install Yarn package manager from [here](https://yarnpkg.com/lang/en/docs/install/). [Usual problem](https://github.com/yarnpkg/yarn/issues/3189) while installing and using yarn with Ubuntu.
- Have an experience in manual control on the drone in case of any weird behavior happen.
- Worked before with COEX drones, if this is your first time to work with COEX drones check [this](https://clever.copterexpress.com/en/).
- Worked before with COEX drones, if this is your first time to work with COEX drones check [this](https://clever.coex.tech/en/).
and you are ready to build and use the required codes.
@@ -52,7 +52,7 @@ git clone https://github.com/hany606/tfjs-posenet.git
### In the Raspberry Pi of the drone (Main controller)
- Access the Raspberry Pi
- [Switch to Client mode](https://clever.copterexpress.com/en/network.html) and ensure that the network has internet connection.
- [Switch to Client mode](network.md) and ensure that the network has internet connection.
Notice: I have already made a bash script based on that tutorial, it is in COEX-Internship19/helpers/ called .to_client.bash
To run it:
@@ -145,7 +145,7 @@ Animation is created by [this](https://justsketchme.web.app/)
## References
- [Human pose estimation guide](https://blog.nanonets.com/human-pose-estimation-2d-guide/)
- [Clever drones tutorials](https://clever.copterexpress.com/en/)
- [Clever drones tutorials](https://clever.coex.tech/en/)
- [Posenet GitHub repo](https://github.com/tensorflow/tfjs-models/tree/master/posenet)
- [Posenet meduim article](https://medium.com/tensorflow/real-time-human-pose-estimation-in-the-browser-with-tensorflow-js-7dd0bc881cd5)
- [Tensorflow.js demos](https://www.tensorflow.org/js/demos)

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.

View File

@@ -27,7 +27,7 @@ Main article: https://docs.qgroundcontrol.com/en/SetupView/Firmware.html
> **Note** Do not connect your flight controller prior to flashing.
We recommend using the modified version of PX4 by CopterExpress for the Clever drone, especially for autonomous flights. Download the latest stable version **<a class="latest-firmware v4" href="https://github.com/CopterExpress/clever/releases">from our GitHub</a>**.
We recommend using the modified version of PX4 by CopterExpress for the Clever drone, especially for autonomous flights. Download the latest stable version **<a class="latest-firmware v4" href="https://github.com/CopterExpress/Firmware/releases">from our GitHub</a>**.
Flash the flight controller with this firmware:

View File

@@ -1,31 +1,29 @@
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 firmware PX4 for Clever](firmware.md#прошивка-для-клевера).
> **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 ([mode](modes.md) `OFFBOARD`). It allows setting the desired flight tasks, and automatically transforms [the system of coordinates](frames.md).
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).
`simple_offboard` is a high level way of interacting with the flight controller. For a more low level work, see [mavros](mavros.md).
`simple_offboard` is a high level system for interacting with the flight controller. For a more low level system, see [mavros](mavros.md).
Main services are `get_telemetry` (receiving all telemetry), `navigate` (flying to a given point along a straight line), `navigate_global` (flying to a global point along a straight line), `land` (switching to the landing mode).
Main services are [`get_telemetry`](#gettelemetry) (receive telemetry data), [`navigate`](#navigate) (fly to a given point along a straight line), [`navigate_global`](#navigateglobal) (fly to a point specified as latitude and longitude along a straight line), [`land`](#land) (switch to landing mode).
The use of Python language
Python samples
---
To use the services, create proxies to them. Use the following template for you programs:
You need to create proxies for services before calling them. Use the following template for your programs:
```python
import rospy
from clever import srv
from std_srvs.srv import Trigger
rospy.init_node('flight') # flight name of your ROS node
# Creating proxies to all services:
rospy.init_node('flight') # 'flight' is name of your ROS node
get_telemetry = rospy.ServiceProxy('get_telemetry', srv.GetTelemetry)
navigate = rospy.ServiceProxy('navigate', srv.Navigate)
@@ -42,11 +40,11 @@ Unused proxy functions may be removed from the code.
API description
---
> **Note** Blank numeric parameters are set to 0.
> **Note** Omitted numeric parameters are set to 0.
### get_telemetry
Obtaining complete telemetry of the drone.
Obtains complete telemetry of the drone.
Parameters:
@@ -56,11 +54,11 @@ Response format:
* `frame_id` — frame;
* `connected` whether there is a connection to <abbr title="Flight Control Unit flight controller">FCU</abbr>;
* `armed` - state of propellers (the propellers are armed, if true);
* `armed` - drone arming state (armed if true);
* `mode` current [flight mode](modes.md);
* `x, y, z` — local position of the drone *(m)*;
* `lat, lon` latitude, longitude *(degrees)*, [GPS](gps.md) is to be available;
* `alt` altitude in the global system of coordinates (standard [WGS-84](https://ru.wikipedia.org/wiki/WGS_84), not <abbr title="Above Mean Sea Level">AMSL</abbr>!), [GPS](gps.md) is to be available ;
* `lat, lon` drone latitude and longitude *(degrees)*, requires [GPS](gps.md) module;
* `alt` altitude in the global coordinate system (according to [WGS-84](https://ru.wikipedia.org/wiki/WGS_84) standard, not <abbr title="Above Mean Sea Level">AMSL</abbr>!), requires [GPS](gps.md) module;
* `vx, vy, vz` drone velocity *(m/s)*;
* `pitch` pitch angle *(radians)*;
* `roll` roll angle *(radians)*;
@@ -71,7 +69,7 @@ Response format:
* `voltage` total battery voltage *(V)*;
* `cell_voltage` battery cell voltage *(V)*.
> **Note** Fields that are unavailabe for any reason will contain the `NaN` value.
> **Note** Fields that are unavailable for any reason will contain the `NaN` value.
Displaying drone coordinates `x`, `y` and `z` in the local system of coordinates:
@@ -80,7 +78,7 @@ telemetry = get_telemetry()
print telemetry.x, telemetry.y, telemetry.z
```
Displaying drone altitude relative to [the card of ArUco tags](aruco.md):
Displaying drone altitude relative to [the ArUco map](aruco.md):
```python
telemetry = get_telemetry(frame_id='aruco_map')
@@ -92,14 +90,14 @@ Checking global position availability:
```python
import math
if not math.isnan(get_telemetry().lat):
print 'Global position presents'
print 'Global position is available'
else:
print 'No global position'
```
Output of current telemetry (command line):
```(bash)
```bash
rosservice call /get_telemetry "{frame_id: ''}"
```
@@ -111,12 +109,12 @@ Parameters:
* `x`, `y` — coordinates *(m)*;
* `yaw` — yaw angle *(radians)*;
* `yaw_rate` angular yaw velocity (used for setting the yaw to `NaN`) *(rad/s)*;
* `yaw_rate` angular yaw velocity (will be used if yaw is set to `NaN`) *(rad/s)*;
* `speed` flight speed (setpoint speed) *(m/s)*;
* `auto_arm` switch the drone to `OFFBOARD` and arm automatically (**the drone will take off**);
* `frame_id` [system of coordinates](frames.md) for values `x`, `y`, `z`, `vx`, `vy`, `vz`. Example: `map`, `body`, `aruco_map`. Default value: `map`.
* `auto_arm` switch the drone to `OFFBOARD` mode and arm automatically (**the drone will take off**);
* `frame_id` [coordinate system](frames.md) for values `x`, `y`, `z`, `vx`, `vy`, `vz`. Example: `map`, `body`, `aruco_map`. Default value: `map`.
> **Note** To fly without changing the yaw angle, it is sufficient to set the `yaw` to `NaN` (angular velocity by default is 0).
> **Note** If you don't want to change your current yaw set the `yaw` parameter to `NaN` (angular velocity by default is 0).
Ascending to the altitude of 1.5 m with the climb rate of 0.5 m/s:
@@ -142,13 +140,19 @@ 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
navigate(yaw=math.radians(-90), frame_id='body')
```
Flying to point 3:2 (altitude 2) in the system of coordinates [of the marker field](aruco.md) at the speed of 1 m/s:
Flying to point 3:2 (with the altitude of 2 m) in the [ArUco map](aruco.md) coordinate system with the speed of 1 m/s:
```python
navigate(x=3, y=2, z=2, speed=1, frame_id='aruco_map')
@@ -172,9 +176,11 @@ 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 system of coordinates (latitude/longitude).
Flying in a straight line to a point in the global coordinate system (latitude/longitude).
Parameters:
@@ -184,11 +190,11 @@ Parameters:
* `yaw_rate` angular yaw velocity (used for setting the yaw to `NaN`) *(rad/s)*;
* `speed` flight speed (setpoint speed) *(m/s)*;
* `auto_arm` switch the drone to `OFFBOARD` and arm automatically (**the drone will take off**);
* `frame_id` [system of coordinates](frames.md), given `z` и `yaw` (Default value: `map`).
* `frame_id` [coordinate system](frames.md) for `z` and `yaw` (Default value: `map`).
> **Note** To fly without changing the yaw angle, it is sufficient to set the `yaw` to `NaN` (angular velocity by default is 0).
> **Note** If you don't want to change your current yaw set the `yaw` parameter to `NaN` (angular velocity by default is 0).
Flying to a global point at the speed of 5 m/s, while remaining at current altitude (`yaw` will be set to 0, the drone will face East):
Flying to a global point at the speed of 5 m/s, while maintaining current altitude (`yaw` will be set to 0, the drone will face East):
```python
navigate_global(lat=55.707033, lon=37.725010, z=0, speed=5, frame_id='body')
@@ -202,15 +208,15 @@ navigate_global(lat=55.707033, lon=37.725010, z=0, speed=5, yaw=float('nan'), fr
Flying to a global point (command line):
```(bash)
```bash
rosservice call /navigate_global "{lat: 55.707033, lon: 37.725010, z: 0.0, yaw: 0.0, yaw_rate: 0.0, speed: 5.0, frame_id: 'body', auto_arm: false}"
```
### set_position
Set the target for position and yaw. This service may be used to specify the continuous flow of target points, for example, for flying along complex trajectories (circular, arcuate, etc.).
Set the setpoint for position and yaw. This service may be used to specify the continuous flow of target points, for example, for flying along complex trajectories (circular, arcuate, etc.).
> **Hint** For flying to a point in a straight line or takeoff, use the [`navigate`] higher-level service (#navigate).
> **Hint** Use the [`navigate`](#navigate) higher-level service to fly to a point in a straight line or to perform takeoff.
Parameters:
@@ -218,7 +224,7 @@ Parameters:
* `yaw` — yaw angle *(radians)*;
* `yaw_rate` angular yaw velocity (used for setting the yaw to NaN) *(rad/s)*;
* `auto_arm` switch the drone to `OFFBOARD` and arm automatically (**the drone will take off**);
* `frame_id` [system of coordinates](frames.md), given `x`, `y`, `z` и `yaw` (Default value: `map`).
* `frame_id` [coordinate system](frames.md) for `x`, `y`, `z` and `yaw` parameters (Default value: `map`).
Hovering on the spot:
@@ -246,13 +252,13 @@ set_position(x=0, y=0, z=0, frame_id='body', yaw=float('nan'), yaw_rate=0.5)
### set_velocity
Setting speed and yaw.
Set speed and yaw setpoints.
* `vx`, `vy`, `vz` required flight speed *(m/s)*;
* `vx`, `vy`, `vz` flight speed *(m/s)*;
* `yaw` — yaw angle *(radians)*;
* `yaw_rate` angular yaw velocity (used for setting the yaw to NaN) *(rad/s)*;
* `auto_arm` switch the drone to `OFFBOARD` and arm automatically (**the drone will take off**);
* `frame_id` [system of coordinates](frames.md), given `vx`, `vy`, `vz` и `yaw` (Default value: `map`).
* `frame_id` [coordinate system](frames.md) for `vx`, `vy`, `vz` and `yaw` (Default value: `map`).
> **Note** Parameter `frame_id` specifies only the orientation of the resulting velocity vector, but not its length.
@@ -262,7 +268,7 @@ Flying forward (relative to the drone) at the speed of 1 m/s:
set_velocity(vx=1, vy=0.0, vz=0, frame_id='body')
```
One of variants of flying in a circle:
One possible way of flying in a circle:
```python
set_velocity(vx=0.4, vy=0.0, vz=0, yaw=float('nan'), yaw_rate=0.4, frame_id='body')
@@ -270,30 +276,30 @@ set_velocity(vx=0.4, vy=0.0, vz=0, yaw=float('nan'), yaw_rate=0.4, frame_id='bod
### set_attitude
Setting pitch, roll, yaw and throttle level (approximate analogue to control in [the `STABILIZED` mode](modes.md)). This service may be used for lower level monitoring of the drone behavior or controlling the drone, if no reliable data on its position are available.
Set pitch, roll, yaw and throttle level (similar to [the `STABILIZED` mode](modes.md)). This service may be used for lower level control of the drone behavior, or controlling the drone when no reliable data on its position is available.
Parameters:
* `pitch`, `roll`, `yaw` required pitch, roll, and yaw angle *(radians)*;
* `thrust` — throttle level from 0 (no throttle, propellers are stopped) to 1 (full throttle).
* `auto_arm` switch the drone to `OFFBOARD` and arm automatically (**the drone will take off**);
* `frame_id` [system of coordinates](frames.md), given `yaw` (Default value: `map`).
* `pitch`, `roll`, `yaw` requested pitch, roll, and yaw angle *(radians)*;
* `thrust` — throttle level, ranges from 0 (no throttle, propellers are stopped) to 1 (full throttle).
* `auto_arm` switch the drone to `OFFBOARD` mode and arm automatically (**the drone will take off**);
* `frame_id` [coordinate system](frames.md) for `yaw` (Default value: `map`).
### set_rates
Setting pitch, roll, and yaw angular velocity and the throttle level (approximate analogue to control in [the `ACRO` mode](modes.md)). This is the lowest drone control level (excluding direct control of motor rotation speed). This service may be used to automatically perform acrobatic tricks (e.g., flips).
Set pitch, roll, and yaw rates and the throttle level (similar to [the `ACRO` mode](modes.md)). This is the lowest drone control level (excluding direct control of motor rotation speed). This service may be used to automatically perform aerobatic tricks (e.g., flips).
Parameters:
* `pitch_rate`, `roll_rate`, `yaw_rate` angular pitch, roll, and yaw velocity *(rad/s)*;
* `thrust` — throttle level from 0 (no throttle, propellers are stopped) to 1 (full throttle).
* `pitch_rate`, `roll_rate`, `yaw_rate` pitch, roll, and yaw rates *(rad/s)*;
* `thrust` — throttle level, ranges from 0 (no throttle, propellers are stopped) to 1 (full throttle).
* `auto_arm` switch the drone to `OFFBOARD` and arm automatically (**the drone will take off**);
### land
Transfer the drone to the landing [mode](modes.md) (`AUTO.LAND` or similar).
Switch the drone to landing [mode](modes.md) (`AUTO.LAND` or similar).
> **Note** For automatic propeller disabling after landing, [parameter PX4](px4_parameters.md) `COM_DISARM_LAND` is to be set to a value > 0.
> **Note** Set the `COM_DISARM_LAND` [PX4 parameter](px4_parameters.md) to a value greater than 0 to enable automatic disarm after landing.
Landing the drone:
@@ -306,7 +312,7 @@ if res.success:
Landing the drone (command line):
```(bash)
```bash
rosservice call /land "{}"
```
@@ -319,5 +325,5 @@ Stop publishing setpoints to the drone (release control). Required to continue m
Additional materials
------------------------
* [Flying in the field of ArUco markers](aruco.md).
* [Samples of programs and snippets](snippets.md).
* [ArUco-based position estimation and navigation](aruco.md).
* [Program samples and snippets](snippets.md).

View File

@@ -70,6 +70,7 @@ def fall(gpio, level, tick):
done.set()
def read_distance():
global low
done.clear()
pi.gpio_trigger(TRIG, 50, 1)
done.wait(timeout=5)

View File

@@ -43,10 +43,12 @@
* [Визуализация с помощью rviz](rviz.md)
* [Автозапуск ПО](autolaunch.md)
* Дополнительные материалы
* [COEX Pix](coex_pix.md)
* [Гид по автономному полету](auto_setup.md)
* [Имя хоста](hostname.md)
* [Симулятор](sitl.md)
* [Настройка PID](pid_tuning.md)
* [STL-модели Клевера](models.md)
* [Docker-контейнер с симулятором](sitl_docker.md)
* [Установка ROS Kinetic](ros-install.md)
* [Пилотирование со смартфона](rc.md)
@@ -74,6 +76,7 @@
* [Светодиодная лента (legacy)](leds_old.md)
* [Вклад в Клевер](contributing.md)
* Мероприятия
* [CopterHack-2019](copterhack2019.md)
* [Олимпиада НТИ 2019](nti2019.md)
* [CopterHack-2018](copterhack2018.md)
* [CopterHack-2017](copterhack2017.md)
@@ -81,6 +84,7 @@
* [Генератор ArUco карт](arucogenmap.md)
* [Модель аэротакси в городе](bigchallenges.md)
* [Шаровая защита коптера](shield.md)
* [Дрон для 3D-сканирования человека](3dscan.md)
* [Распознавание лиц](face_recognition.md)
* [Управление дроном силой мысли](control_emotions.md)
* [Подсчет количества объектов c камеры](object_counting.md)

View File

@@ -120,12 +120,22 @@ rosrun aruco_pose genmap.py 0.33 2 4 1 1 0 > ~/catkin_ws/src/clever/aruco_pose/m
```python
# Вначале необходимо взлететь, чтобы коптер увидел карту меток и появился фрейм aruco_map:
navigate(0, 0, 2, frame_id='body', speed=0.5, auto_arm=True) # взлет на 2 метра
navigate(x=0, y=0, z=2, frame_id='body', speed=0.5, auto_arm=True) # взлет на 2 метра
time.sleep(5)
# Полет в координату 2:2 маркерного поля, высота 2 метра
navigate(2, 2, 2, speed=1, frame_id='aruco_map') # полет в координату 2:2, высота 3 метра
navigate(x=2, y=2, z=2, speed=1, frame_id='aruco_map') # полет в координату 2:2, высота 3 метра
```
### Полет в координаты по ID маркера
Начиная с версии [образа](image.md) 0.18, доступны также полёты относительно отдельного маркера в карте, даже если дрон его не видит. По аналогии с [навигацией по отдельным маркерам](aruco_marker.md#навигация-по-маркерам) при настройке карты маркеров дрон сможет лететь в координаты относительно отдельного маркера, используя фрейм aruco_ID с соответствующим ID маркера.
Полет в точку над маркером 5 на высоту 1 метр:
```python
navigate(frame_id='aruco_5', x=0, y=0, z=1)
```
## Дополнительные настройки

View File

@@ -1,6 +1,6 @@
# Генератор ArUco карт
Начиная с образа версии *0.16* изменился подход к созданию карт маркеров: маркеры больше не привязаны к сетке и каждый из них теперь можно повернуть на любой угол вокруг всех трёх осей. Вместе с этим изменился и способ задания карт маркеров. Теперь карта загружается из текстового файла (подробнее в статье [**Навигация по картам ArUco-маркеров**](https://clever.copterexpress.com/ru/aruco_map.html)). Для упрощения процесса создания текстового файла был создан [*конструктор полей*](https://aruco.tenessinum.ru/).
Начиная с образа версии *0.16* изменился подход к созданию карт маркеров: маркеры больше не привязаны к сетке и каждый из них теперь можно повернуть на любой угол вокруг всех трёх осей. Вместе с этим изменился и способ задания карт маркеров. Теперь карта загружается из текстового файла (подробнее в статье [**Навигация по картам ArUco-маркеров**](aruco_map.md)). Для упрощения процесса создания текстового файла был создан [*конструктор полей*](https://aruco.tenessinum.ru/).
<img alt="" src="../assets/arucogenmap.PNG"/>

View File

@@ -97,6 +97,8 @@
Моторы с **<font color=red>красными</font>** гайками должны вращаться **против** часовой стрелки, с **чёрными** - **по** часовой стрелке. Правильные направления вращения также указаны на самих моторах. Для проверки направления вращения можно использовать серво-тестер или радиоприёмник с пультом.
<img src="../assets/4/props/props_rotation.png" width=300 class="zoom center">
Использование радиоприёмника и пульта описано ниже.
### Перевод пульта в режим PWM
@@ -181,31 +183,35 @@
## Установка полётного контроллера
1. Установите полетный контроллер на пластину с помощью двухстороннего скотча.
2. Стрелки на полетном контроллере и центральной деке должны быть направлены в одну сторону.
3. Подключите шлейф питания PDB к разъему *"POWER"* полетного контроллера, закрутив его в "косичку" для взаимной фиксации проводов.
1. Вставьте карту microSD в полётный контроллер
<img src="../assets/4/pix/pixracer_sdcard.png" width=300 class="zoom center border">
2. Установите полетный контроллер на пластину с помощью двухстороннего скотча.
3. Стрелки на полетном контроллере и центральной деке должны быть направлены в одну сторону.
4. Подключите шлейф питания PDB к разъему *"POWER"* полетного контроллера, закрутив его в "косичку" для взаимной фиксации проводов.
<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. Установите 4 алюминиевые стойки 40 мм с помощью винтов М3х10.
5. Установите 4 алюминиевые стойки 40 мм с помощью винтов М3х10.
<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. Подключите сигнальные провода регуляторов к полетному контроллеру следующим образом:
6. Подключите сигнальные провода регуляторов к полетному контроллеру следующим образом:
<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. Установите 2 стойки "мама-мама" 15 мм на центральную деку с помощью винтов М3х8.
7. Другие 2 стойки были установлены ранее в разделе "Сборка рамы", п. 2.
7. Установите 2 стойки "мама-мама" 15 мм на центральную деку с помощью винтов М3х8.
8. Другие 2 стойки были установлены ранее в разделе "Сборка рамы", п. 2.
<div class="image-group">
<img src="../assets/4/21.png" width=300 class="zoom border">
@@ -224,15 +230,19 @@
## Установка Raspberry Pi
1. Установите плату Raspberry Pi на стойки, используя 4 стойки "папа-мама".
2. Протяните провода от BEC через паз в центральной раме.
1. Вставьте карту microSD с [записанным образом](image.md) в Raspberry Pi
<img src="../assets/4/rpi/rpi_sdcard.png" width=300 class="zoom center border">
2. Установите плату Raspberry Pi на стойки, используя 4 стойки "папа-мама".
3. Протяните провода от BEC через паз в центральной раме.
<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. Подключите провод питания от BEC к Raspberry, согласно схеме:
4. Подключите провод питания от BEC к Raspberry, согласно схеме:
<img src="../assets/4/26_1.png" width=300 class="zoom center border">
@@ -252,7 +262,10 @@
1. Питание для ленты берется от второго BEC. Подключите контакты *«-»* и *«+»* к *Ground* и *5v* на ленте соответственно.
2. Подключите контакт *D* к GPIO-пину на Raspberry. Рекомендуется использовать пин GPIO21.
<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>
## Установка шлейфа для камеры
@@ -339,6 +352,9 @@
</div>
4. Подключите USB кабель к разъему на полетном контроллере и USB разъему Raspberry Pi.
<img src="../assets/4/43_1.png" width=300 class="zoom center border">
5. Зафиксируйте "улитку" кабеля в удобном месте с помощью двухстороннего скотча так, чтобы провод не мешал вращению винтов.
<div class="image-group">

View File

@@ -7,8 +7,8 @@
Крупные города страдают из-за пробок и перегруженности транспорта. Пробки на дорогах и перегруженность транспорта влечёт за собой многие неудобства. Одной из таких проблем является отсутствие возможности быстро добраться из точки А в точку Б. При этом воздушное пространство практически не используется. Предлагаемое решение заключается в создании системы, которая в режиме реального времени наблюдает и контролирует движение беспилотных летательных аппаратов. Такое решение приводит к полной автоматизации процесса полёта и исключает возможность воздушно-транспортных происшествий. В результате проделанной работы удалось сделать систему, которая состоит из нескольких дронов и сервера. Сервер прокладывает маршрут дронам из начальной точки в заданную по проложенным дорогам. Также в работу сервера входит логистика, благодаря которой беспилотники не сталкиваются в полёте.
<iframe width="966" height="543" src="https://www.youtube.com/embed/nq1DKjacs6U" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="966" height="543" src="https://www.youtube.com/embed/QdgZ4lzPmwQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="100%" height="433" src="https://www.youtube.com/embed/nq1DKjacs6U" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="100%" height="433" src="https://www.youtube.com/embed/QdgZ4lzPmwQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
## Настройка сервера
@@ -32,12 +32,12 @@ pip install -r requirements.txt
python manage.py runserver 0.0.0.0:8000
```
Чтобы перейти на веб страницу наберите в адресной строке ip адрес сервера в локальной сети и укажите порт 8000 (`http://ip:8000`).
Чтобы перейти на веб страницу наберите в адресной строке ip адрес сервера в локальной сети и укажите порт 8000 (`http://ip:8000`).
[Как узнать ip адрес устройства](https://remontka.pro/ip-adres/)
## Настройка коптеров
В первую очередь подготовьте SD-карту с образом Clever ([Инструкция](https://clever.copterexpress.com/ru/microsd_images.html))
В первую очередь подготовьте SD-карту с образом Clever ([Инструкция](image.md))
Чтобы скачать проект на Raspberry Pi в коптере выполните команду
@@ -45,7 +45,7 @@ python manage.py runserver 0.0.0.0:8000
git clone https://github.com/Tennessium/HUEX
```
Перед началом работы с системой необходимо перевести коптеры в режим клиента и подключить к сети WiFi. Вы можете воспользоваться [этим мануалом](https://clever.copterexpress.com/ru/network.html#переключение-адаптера-в-режим-клиента)
Перед началом работы с системой необходимо перевести коптеры в режим клиента и подключить к сети WiFi. Вы можете воспользоваться [этим мануалом](network.md#переключение-адаптера-в-режим-клиента)
Однако, для упрощения развертывания системы на нескольких коптреах, рекомендуется использование нашего скрипта, лежащего в папке *copter/setup/*

View File

@@ -36,6 +36,18 @@ raspistill -o test-image.jpg
Если команда завершается с ошибкой, проверьте качество подключения шлейфа камеры к Raspberry Pi или замените его.
## Настройки камеры
Ряд параметров камеры - размер изображения, максимальную частоту кадров, экспозицию - можно настроить в файле `main_camera.launch`. Список настраиваемых параметров можно [посмотреть в репозитории cv_camera](https://github.com/OTL/cv_camera#parameters).
Параметры, не указанные в этом списке, можно указывать через [код параметра OpenCV](https://docs.opencv.org/3.3.1/d4/d15/group__videoio__flags__base.html). Например, для установки фиксированной экспозиции добавьте следующие параметры в ноду камеры:
```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 -->
```
## Компьютерное зрение
Для реализации алгоритмов компьютерного зрения рекомендуется использовать предустановленную на [образ SD-карты](image.md) библиотеку [OpenCV](https://opencv.org).

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

@@ -0,0 +1,60 @@
# COEX Pix
Полетный контроллер **COEX Pix** является модифицированным аналогом полетного контроллера [Pixracer](https://docs.px4.io/v1.9.0/en/flight_controller/pixracer.html). Этот полетный контроллер поставляется с наборами **Клевер 4** и далее.
## Ревизия 1.1
### Характеристики
* Размеры платы 35x35 мм.
* Диаметр монтажных отверстий 3.2 мм.
* Расстояние между центрами монтажных отверстий 30.5 мм.
* Масса платы (без проводов) 9 г.
* Диапазон рабочих температур -5...+65 ºC.
* Диапазон входного напряжения 4.8...5.5 В.
### Основные элементы
* Основной SOC *STM32F427VIT6*.
* Память FRAM *FM25V02A*.
* Датчики:
* *MPU9250* (9 DOF) 3-х осевой магнитометр, 3-х осевой гироскоп, 3-х осевой акселерометр.
* *MS5607* датчик атмосферного давления.
### Разъемы
* *TELEM 1* (JST-GH 4 pin) разъем для подключения телеметрии, порт 1, протокол UART.
* *TELEM 2* (JST-GH 4 pin) разъем для подключения телеметрии, порт 2, протокол UART.
* *GPS* (JST-GH 6 pin) разъем для подключения ГПС модуля (UART) с компасом (I2C).
* *I2C* (JST-GH 4 pin) разъем для подключения поддерживаемых I2C устройств.
* *PWR* (JST-GH 6 pin) разъем для подключения питания с платы COEX PDB или аналогичной, датчиков напряжения и тока.
* *RC IN* (JST-GH 4 pin) разъем для подключения радиоприемника аппаратуры радиоуправления, канала для * снятия показаний RSSI. Поддерживаемые RC протоколы PPM и SBUS.
* Разьем Micro USB для подключения к ПК для настройки и коммуникации по протоколу USB 2.0/1.1
* Слот для карты памяти MicroSD, до 32 ГБ.
* Серворазъемы для подключения контроллеров моторов и других устройств.
### Схемы расположения контактов
<img src="../assets/coexpix-top.jpg" width=400 class=zoom>
<img src="../assets/coexpix-bottom.jpg" width=400 class=zoom>
> **Note** На плате ревизии 1.0 RC IN разъем располагался на месте разъема Micro SD. Распиновка самого разъема осталась такой же.
### Установка на Клевере
**Важно**: плата спроектирована для удобной установки на Клевере с поворотом на 180º по крену и 90º по рысканью (стрелка на плате находится снизу и указывает направо). Таким образом, параметр ориентации автопилота PX4 устанавливается в значение `SENS_BOARD_ROT` = `ROLL 180, YAW 90`.
### Рекомендации
Во время установки полетного контроллера, учитывайте возможные влияния магнитных полей от силовых проводов и платы распределения питания на магнитометр. В случае установки данной платы над платой распределения питания, рекомендуется (в случае использования внутреннего магнитометра) поднять плату на высоту не менее 15 мм от платы распределения питания и силовых проводов. Силовой провод от аккумуляторной батареи старайтесь зафиксировать соответственно.
В случае использования внешнего GPS модуля со встроенным магнитометром, внутренний магнитометр рекомендуется отключать.
В случае, если на дроне не предусмотрен защитный кожух, рекомендуется изолировать барометр поролоновой губкой (достаточно подложить губку между полетным контроллером и нижней частью корпуса (платой распределения питания), либо зафиксировать иным способом.
При подключении питания в разъем PWR, на разъеме **+** будет напряжение 5 вольт, его можно использовать для питания сервомашинок. Не рекомендуется подключать дополнительные источники питания в разъем **+**, если питание подается в разъем PWR. Питать полетный контроллер одновременно от USB и PWR\AUX разъемов допускается.
### Особенности платы
Для повышения надежности и стабильности, плата оснащена низкошумящими понижающими преобразователями. Установлен входной LC фильтр, а также ферритовые фильтры в цепях питания.

View File

@@ -91,4 +91,4 @@
<img src="../assets/github-pull-request-create.png" alt="GitHub Create Pull">
10. Дождитесь комментариев на свою статью, сделайте правки, если потребуется.
11. Порадуйтесь своей новой полезной статье, опубликованной на https://clever.copterexpress.com !
11. Порадуйтесь своей новой полезной статье, опубликованной на https://clever.coex.tech !

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

@@ -0,0 +1,94 @@
# Copter Hack 2019
Хакатон [Copter Hack 2019](https://copterexpress.timepad.ru/event/768108/) проходит 1113 октября в Технополисе "Москва".
Официальный сайт: https://ru.coex.tech/copterhack.
Чат хакатона: https://t.me/CopterHack.
Timepad: https://copterexpress.timepad.ru/event/1017592/.
## Информация для участников
### Особенности настройки полетного контроллера COEX PIX
При использовании полетного контроллера *COEX Pix* перед калибровкой датчиков вам стоит обратить внимание, что в графе *Autopilot orientation* вы должны выбрать параметр `ROTATION_ROLL_180_YAW_90`. Данную настройку требуется проводить при калибровке каждого из датчиков.
<img src="../assets/autopilot_orientation.png" class="center" width=600>
Этот параметр устанавливается для того, чтобы на программном уровне настроить ориентацию вашего *IMU* датчика находящегося на полетном контроллере.
### Рекомендуемая версия образа
Для Raspberry Pi версий до 3B+: [v0.18](https://github.com/CopterExpress/clever/releases/tag/v0.18)
Для Raspberry Pi версии 4: [v0.19-alpha.1](https://github.com/CopterExpress/clever/releases/tag/v0.19-alpha.1)
### Ориентация камеры
На многих дронах камера ориентирована шлейфом вперёд. Это следует отразить в файле `main_camera.launch` в пакете `clever`.
Подробнее см. статью [Ориентация камеры](camera_frame.md).
### Полет с использованием Optical Flow
Для включения optical flow установите параметры `optical_flow` и `rangefinder_vl53l1x` в файле `clever.launch` в `true`.
Также необходимо в QGroundControl в параметре `LPE_FUSION` включить галочку `pub agl as lpos down`.
Необходимо также убедиться, что лазерный дальномер корректно установлен и работает (см. [конфигурирование дальномера](laser.md)).
Подробнее: [Использование Optical Flow](optical_flow.md).
### Использование карты маркеров
Для настройки большой карты маркеров используйте карту с названием `cmit.txt`. Далее используйте [инструкцию](aruco_map.md).
### Аккумуляторы
**При полетах обязательно использование датчика напряжения ("пищалки"). В случае выхода из строя аккумулятора новый не предоставляется!**
### Съемка видео
Снимайте **ВСЕ** ваши полеты на видео! В случае поломки дрона на защите сможете показать видео, что будет учтено при оценке.
### Проблема с yaw
При полете по маркерам (VPE) в прошивке v1.8.2-clever.7 возможно есть ошибка, которая проявляется в том, что дрон не держит yaw по маркерам. Если у вас есть такая проблема, попробуйте залить более старую прошивку v1.8.2-clever.6, доступную по ссылке https://github.com/CopterExpress/Firmware/releases/tag/v1.8.2-clever.6. Для COEX Pix необходимо скачивать файл `px4fmu-v4_default.px4`.
### Проблема с navigate
В образе 0.18 обнаружился баг из-за которого дрон может летать по точкам слишком быстро. Если у вас это происходит, поставьте в файле `~/catkin_ws/src/clever/clever/launch/clever.launch` параметр `nav_from_sp` в значение `false` таким образом:
```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>
```
## Лекции
Лекция 1: введение  https://www.youtube.com/watch?v=cjtmZNuq7z0.
Лекция 2: настройка полетного контроллера  https://www.youtube.com/watch?v=PJNDYFPZQms.
Лекция 3: архитектура полетного контроллера PX4  https://www.youtube.com/watch?v=_jl7FImq3jk.
Лекция 4: автономные полеты: https://www.youtube.com/watch?v=ThXiNG1IzvI.
См. также другие видео на канале COEX на YouTube: https://www.youtube.com/channel/UCeCu93sLBkcgbIkIC7Jaauw/featured.
## Результаты
Команды-победители:
1. Бульболет – доставка картошки с помощью умной лебедки.
2. Copter don't hurt me – управление дроном с помощью нейроинтерфейса.
3. import torch  active track на нейронках.
4. Автобот freeze light через бота ВКонтакте.
5. Stardust Crusaders  AR среда симуляции для дронов.

View File

@@ -9,7 +9,8 @@
* `map` — координаты относительно точки инициализации полетного контроллера: белая сетка на иллюстрации;
* `base_link` — координаты относительно квадрокоптера: схематичное изображение квадрокоптера на иллюстрации;
* `body` — координаты относительно квадрокоптера без учета наклонов по тангажу и крену: красная, синяя и зеленая линии на иллюстрации.
* `body` — координаты относительно квадрокоптера без учета наклонов по тангажу и крену: красная, синяя и зеленая линии на иллюстрации;
* `navigate_target` координаты точки, в которую сейчас летит дрон (с использованием [navigate](simple_offboard.md#navigate)).
> **Hint** В соответствии с [соглашением](http://www.ros.org/reps/rep-0103.html), для фреймов, связанных с коптером, ось X направлена вперед, Y налево и Z вверх.

View File

@@ -1,4 +1,4 @@
# Управление дроном для оценки позы человека
# Управление дроном при помощи позы человека
## Демонстрация
@@ -9,7 +9,7 @@
## Ссылки на литературу
- [Руководство по оценке позы человека](https://blog.nanonets.com/human-pose-estimation-2d-guide/)
- [Умные беспилотники учебники](https://clever.copterexpress.com/en/)
- [Умные беспилотники учебники](https://clever.coex.tech/en/)
- [Posnet GitHub РЕПО](https://github.com/tensorflow/tfjs-models/tree/master/posenet)
- [Posnet Medium артикул](https://medium.com/tensorflow/real-time-human-pose-estimation-in-the-browser-with-tensorflow-js-7dd0bc881cd5)
- [Tensorflow.js Демонстрация](https://www.tensorflow.org/js/demos)

View File

@@ -46,7 +46,7 @@
* [Инструкция по сборке.](assemble_3.md)
* [Инструкция по настройке.](setup.md)
* [Проверочные задания.](tests.md)
* Информационные материалы на сайте https://clever.copterexpress.com.
* Информационные материалы на сайте https://clever.coex.tech.
## Промежуточный контроль

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

@@ -0,0 +1,15 @@
# STL-модели
На этой странице представлены STL-модели некоторых деталей квадрокоптеров Клевер.
## Клевер 4
### Холдер для АКБ
Файл: [`battery_holder.stl`](https://github.com/CopterExpress/clever/raw/master/docs/assets/battery_holder.stl).
Материал печати: PLA/ABS/SBS.
Заполнение: не менее 50%.
Функция: устанавливается на деталь "дека монтажная", после чего позволяет надежно фиксировать АКБ с помощью ремешка. Также имеется возможность установки индикатора напряжения (с помощью 3М-скотча).

View File

@@ -1,10 +1,10 @@
# Использование Optical Flow
При использовании технологии Optical Flow возможен полет в режиме POSCTL и автономные полеты по камере, направленной вниз, за счет измерения сдвигов текстуры поверхности пола.
При использовании технологии Optical Flow возможен полет в режиме POSCTL и автономные полеты ([режим OFFBOARD](simple_offboard.md)) по камере, направленной вниз, за счет измерения сдвигов текстуры поверхности пола.
## Включение
> **Hint** Рекомендуется использование [специальной сборки PX4 для Клевера](firmware.md#прошивка-для-клевера).
> **Hint** Необходимо использование [специальной сборки PX4 для Клевера](firmware.md#прошивка-для-клевера).
Необходимо использование дальномера. [Подключите и настройте дальномер VL53L1X](laser.md), используя инструкцию.
@@ -20,17 +20,7 @@ Optical Flow публикует данные в топик `mavros/px4flow/raw/s
## Настройка полетного контроллера
При использовании **EKF2** (параметр `SYS_MC_EST_GROUP` = `ekf2`):
* `EKF2_AID_MASK` включен флажок use optical flow.
* `EKF2_OF_DELAY`  0.
* `EKF2_OF_QMIN` 10.
* `EKF2_OF_N_MIN`  0.05.
* `EKF2_OF_N_MAX` - 0.2.
* `SENS_FLOW_ROT` No rotation (отсутствие поворота).
* `SENS_FLOW_MAXHGT` 4.0 (для дальномера VL53L1X)
* `SENS_FLOW_MINHGT` 0.01 (для дальномера VL53L1X)
* Опционально: `EKF2_HGT_MODE` range sensor (см. [конфигурирование дальномера](laser.md)).
> **Hint** При использовании [сборки PX4 для Клевера](firmware.md#прошивка-для-клевера) необходимые параметры PX4 применятся автоматически.
При использовании **LPE** (параметр `SYS_MC_EST_GROUP` = `local_position_estimator, attitude_estimator_q`):
@@ -44,6 +34,18 @@ Optical Flow публикует данные в топик `mavros/px4flow/raw/s
* `SENS_FLOW_MINHGT` 0.01 (для дальномера VL53L1X)
* Опционально: `LPE_FUSION` – включен флажок pub agl as lpos down (см. [конфигурирование дальномера](laser.md).
При использовании **EKF2** (параметр `SYS_MC_EST_GROUP` = `ekf2`):
* `EKF2_AID_MASK` включен флажок use optical flow.
* `EKF2_OF_DELAY`  0.
* `EKF2_OF_QMIN` 10.
* `EKF2_OF_N_MIN`  0.05.
* `EKF2_OF_N_MAX` - 0.2.
* `SENS_FLOW_ROT` No rotation (отсутствие поворота).
* `SENS_FLOW_MAXHGT` 4.0 (для дальномера VL53L1X)
* `SENS_FLOW_MINHGT` 0.01 (для дальномера VL53L1X)
* Опционально: `EKF2_HGT_MODE` range sensor (см. [конфигурирование дальномера](laser.md)).
Для проверки правильности всех настроек можно [воспользоваться утилитой `selfcheck.py`](selfcheck.md).
## Полет в POSCTL
@@ -63,7 +65,13 @@ navigate(z=1.5, frame_id='body', auto_arm=True)
Полет вперед на 1 м:
```python
navigate(x=1.5, frame_id='body')
navigate(x=1, frame_id='body')
```
Полет назад на 1 м (относительно предыдущей целевой точки):
```python
navigate(x=-1, frame_id='navigate_target')
```
При использовании Optical Flow возможна также [навигация по ArUco-маркерам](aruco_marker.md), в том числе [используя VPE](aruco_map.md).

View File

@@ -27,7 +27,7 @@
> **Note** Перед осуществлением перепрошивки Pixracer не должен быть подключен к компьютеру по USB.
Для Клевера, в особенности для осуществления автономных полетов, рекомендуется использовать версию прошивки PX4 от Copter Express. Скачайте актуальную версию прошивки на GitHub — **<a class="latest-firmware v4" href="https://github.com/CopterExpress/clever/releases">скачать</a>**.
Для Клевера, в особенности для осуществления автономных полетов, рекомендуется использовать версию прошивки PX4 от Copter Express. Скачайте актуальную версию прошивки на GitHub — **<a class="latest-firmware v4" href="https://github.com/CopterExpress/Firmware/releases">скачать</a>**.
Далее загрузите прошивку в полетный контролер.

View File

@@ -90,7 +90,7 @@ print telemetry.z
```python
import math
if not math.isnan(get_telemetry().lat):
print 'Global position presents'
print 'Global position is available'
else:
print 'No global position'
```
@@ -140,6 +140,12 @@ navigate(x=5, y=0, z=3, speed=0.8, yaw=float('nan'))
navigate(x=0, y=-3, z=0, speed=1, frame_id='body')
```
Полет влево на 2 м относительно последней целевой точки полета дрона:
```python
navigate(x=0, y=2, z=0, speed=1, frame_id='navigate_target')
```
Повернуться на 90 градусов против часовой:
```python
@@ -170,6 +176,8 @@ navigate(x=3, y=0, z=0, speed=0.5, yaw=float('nan'), yaw_rate=0.2, frame_id='bod
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** При программировании миссии дрона в терминах "вперед-назад-влево-вправо" рекомендуется использовать систему координат `navigate_target` вместо `body`, чтобы не учитывать неточность прилета дрона в предыдущую целевую точку при вычислении следующей.
### navigate_global
Полет по прямой в точку в глобальной системе координат (широта/долгота).

View File

@@ -79,7 +79,7 @@ roslaunch mavros px4.launch fcu_url:=udp://@127.0.0.1:14557
> **Caution** Среда `ROS Kinetic` в изначально ориентированна для `Ubuntu (Xenial)` версии 16.04, по этому актуальность данной инструкции гарантируется только для соответственной версии операционной системы.
В первую очередь вам потребуется установить полный пакет ROS Kinetic desktop-full, инструкцию по установке вы можете найти в [статье по установке ROS](https://clever.copterexpress.com/ru/ros-install.html).
В первую очередь вам потребуется установить полный пакет ROS Kinetic desktop-full, инструкцию по установке вы можете найти в [статье по установке ROS](ros-install.md).
После того, как вы выполнили указанные выше инструкции, вам нужно проверить, есть ли в вашем пакете `ROS` все нужные пакеты.

View File

@@ -70,6 +70,7 @@ def fall(gpio, level, tick):
done.set()
def read_distance():
global low
done.clear()
pi.gpio_trigger(TRIG, 50, 1)
done.wait(timeout=5)

View File

@@ -1,6 +1,5 @@
{
"redirects": [
{ "from": "index.html", "to": "ru/index.html" },
{ "from": "assemble.html", "to": "ru/assemble_2.html" },
{ "from": "assemble_clever3_4in1.html", "to": "ru/assemble_3.html" },
{ "from": "glossary.html", "to": "ru/gloss.html" },