Compare commits
388 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
594d8b4fc8 | ||
|
|
e238032de7 | ||
|
|
163af20d29 | ||
|
|
d376bc0553 | ||
|
|
802d04e1eb | ||
|
|
99b03ae5be | ||
|
|
9a3c13da77 | ||
|
|
d012c4fe7a | ||
|
|
75d20b1234 | ||
|
|
96fb8a21e6 | ||
|
|
39787af90b | ||
|
|
07a8ed0dc2 | ||
|
|
ee3941f16c | ||
|
|
ffe89f8265 | ||
|
|
2a0562188a | ||
|
|
7978c9e6fa | ||
|
|
4237192802 | ||
|
|
3caa6796b6 | ||
|
|
fcf9b6b909 | ||
|
|
572d8dc55f | ||
|
|
6f473816a1 | ||
|
|
6701c17332 | ||
|
|
89cee43d38 | ||
|
|
c17dde8f8f | ||
|
|
6e1aa44f2d | ||
|
|
660d26bbce | ||
|
|
7e7cb1c085 | ||
|
|
2aef7fbfba | ||
|
|
76347bf4cc | ||
|
|
280a0003ed | ||
|
|
74a1e1cbee | ||
|
|
2099c75fa8 | ||
|
|
cbb19271bf | ||
|
|
6fc2f952ce | ||
|
|
62c22d3539 | ||
|
|
83ea7b8f54 | ||
|
|
52fbe86e0f | ||
|
|
d000f81356 | ||
|
|
e815c14070 | ||
|
|
8b4b7221b5 | ||
|
|
6c025d84ad | ||
|
|
ed08f41065 | ||
|
|
71e8d74160 | ||
|
|
6261ff9da5 | ||
|
|
f507923cb1 | ||
|
|
8017904261 | ||
|
|
9a4d467d9f | ||
|
|
640781f381 | ||
|
|
b255de4627 | ||
|
|
bb9ece650f | ||
|
|
415689d725 | ||
|
|
1b66508df7 | ||
|
|
12c431f87c | ||
|
|
00a506cfdf | ||
|
|
e13ca40a75 | ||
|
|
3a2ea23822 | ||
|
|
fd4afdfc84 | ||
|
|
ec757e3418 | ||
|
|
efd9d82131 | ||
|
|
affd349ee9 | ||
|
|
2ae1c1dfaa | ||
|
|
bc6f066804 | ||
|
|
1f5f814f42 | ||
|
|
fc9b33b698 | ||
|
|
1ed4221d9f | ||
|
|
fe7f29b76f | ||
|
|
a165a4817c | ||
|
|
e35a7fe108 | ||
|
|
f91b7742c3 | ||
|
|
5065ca8c3b | ||
|
|
3a2b8bd1f4 | ||
|
|
837c7af7ee | ||
|
|
6c9103835f | ||
|
|
d16a27c891 | ||
|
|
834e21aaf0 | ||
|
|
7260433a91 | ||
|
|
c4bfff69f4 | ||
|
|
e71515ee3e | ||
|
|
2372824122 | ||
|
|
521baaa652 | ||
|
|
8df037d1ad | ||
|
|
afdbe7ba7a | ||
|
|
852308c78d | ||
|
|
020f3b6259 | ||
|
|
4fdcb32044 | ||
|
|
d55e7ed404 | ||
|
|
4e38266101 | ||
|
|
330e3f92b4 | ||
|
|
72ea0daeec | ||
|
|
b938b28076 | ||
|
|
5bb818332a | ||
|
|
85a7db1b56 | ||
|
|
972abc6277 | ||
|
|
5fdf22afc3 | ||
|
|
80669d7e2f | ||
|
|
74157b4901 | ||
|
|
a42f631bf4 | ||
|
|
47648cd57f | ||
|
|
eec5b9c9b2 | ||
|
|
61544c2099 | ||
|
|
afa3523cb2 | ||
|
|
8c6af93fd1 | ||
|
|
3dd5747b3c | ||
|
|
2901234d9c | ||
|
|
595e67a928 | ||
|
|
fa817d9f80 | ||
|
|
72b20f8c94 | ||
|
|
6dc0bd5cc5 | ||
|
|
da9eb7d0ba | ||
|
|
18f973ce00 | ||
|
|
469542416d | ||
|
|
fb6b96fa5b | ||
|
|
98f0b57eb6 | ||
|
|
4f8956829f | ||
|
|
9c6991e9d7 | ||
|
|
59b2c3895c | ||
|
|
ccef57f311 | ||
|
|
c25a752b20 | ||
|
|
9ecf10ea43 | ||
|
|
1238107b13 | ||
|
|
55fc7493c9 | ||
|
|
5959f7cbcc | ||
|
|
25ab5933a2 | ||
|
|
2e019c136f | ||
|
|
1d91f2800d | ||
|
|
66b879ebb7 | ||
|
|
e47824b1ff | ||
|
|
0e791c7bf7 | ||
|
|
4a02d27e35 | ||
|
|
224d09be9f | ||
|
|
f236db3392 | ||
|
|
ee88d7d6bf | ||
|
|
273310f915 | ||
|
|
405b956b06 | ||
|
|
ef88fcbfd3 | ||
|
|
c98913000c | ||
|
|
85d765e5e7 | ||
|
|
1406229b11 | ||
|
|
9c3a8627b5 | ||
|
|
a548fcafa8 | ||
|
|
b029054946 | ||
|
|
bcab7a9b15 | ||
|
|
5cf7e86d33 | ||
|
|
c0cd53c733 | ||
|
|
45743ca6ac | ||
|
|
54048922fa | ||
|
|
2b1fd00ca0 | ||
|
|
ccc5a12320 | ||
|
|
c828effd23 | ||
|
|
d7e6629567 | ||
|
|
b6a06c62d1 | ||
|
|
cea91bd082 | ||
|
|
a9e5270acd | ||
|
|
3f5b856310 | ||
|
|
7595971f96 | ||
|
|
1ecc2774d7 | ||
|
|
7e47914abe | ||
|
|
ef204e0a54 | ||
|
|
8e1015f64e | ||
|
|
ec9d7ab22f | ||
|
|
8cc9a916c4 | ||
|
|
0d1c1bfec2 | ||
|
|
90debd91ba | ||
|
|
bccecbbc88 | ||
|
|
850afc6688 | ||
|
|
3bffcba4de | ||
|
|
0fc319c2af | ||
|
|
3434f6963e | ||
|
|
482d47a48c | ||
|
|
0ce4714f8e | ||
|
|
1d27febf6a | ||
|
|
290301115b | ||
|
|
81ef67787a | ||
|
|
815bebf6f2 | ||
|
|
1f29d4c0ec | ||
|
|
4eaf8c87c5 | ||
|
|
234b377ceb | ||
|
|
23ba569e48 | ||
|
|
6e364009e3 | ||
|
|
b1f79c1903 | ||
|
|
0cb23e600c | ||
|
|
04b22af49d | ||
|
|
1e0589b3ed | ||
|
|
214224101c | ||
|
|
d574adbc3f | ||
|
|
1c77d030d9 | ||
|
|
0410246918 | ||
|
|
a86e662c1e | ||
|
|
c68fb8883c | ||
|
|
7dd0779f69 | ||
|
|
98ad1cdba8 | ||
|
|
386c88a8f4 | ||
|
|
5accc55e93 | ||
|
|
756e50d3ac | ||
|
|
d8c4b452c5 | ||
|
|
1430968566 | ||
|
|
13fcc3c20a | ||
|
|
8b7c20b40c | ||
|
|
f7b58c9e6d | ||
|
|
2adb329ece | ||
|
|
a5cdb9dc00 | ||
|
|
c971b1b00c | ||
|
|
85bbd15bd0 | ||
|
|
dc597c9299 | ||
|
|
b85b8a978a | ||
|
|
b27ad9d395 | ||
|
|
671de1a799 | ||
|
|
2565997fb6 | ||
|
|
8baba02f98 | ||
|
|
fbbfdd54e8 | ||
|
|
a09bc7156a | ||
|
|
5922619605 | ||
|
|
2bd9e119f8 | ||
|
|
a52faadbef | ||
|
|
5751184c46 | ||
|
|
d7418e80c2 | ||
|
|
d9578d3c32 | ||
|
|
66b09ee99a | ||
|
|
8b213d6103 | ||
|
|
2f584fd2d7 | ||
|
|
9cf8357c4f | ||
|
|
3f53de0832 | ||
|
|
59e6f33e9f | ||
|
|
24edace814 | ||
|
|
5da1125ecd | ||
|
|
8566c2ccbd | ||
|
|
d3acb298e8 | ||
|
|
3827bb4210 | ||
|
|
e71519d358 | ||
|
|
4c2a881407 | ||
|
|
a67179105c | ||
|
|
e092cec215 | ||
|
|
4f8e9019af | ||
|
|
4d68f77368 | ||
|
|
a05ae6cafe | ||
|
|
1283219c51 | ||
|
|
de30d0d09f | ||
|
|
ab5df9f725 | ||
|
|
613fe1639c | ||
|
|
4de6468393 | ||
|
|
c4f4c9a81a | ||
|
|
5a22dce8d4 | ||
|
|
bea4f3044c | ||
|
|
f8018aab68 | ||
|
|
a9d9adc25f | ||
|
|
e04cb7cb6a | ||
|
|
8539ff8430 | ||
|
|
8b60d2c61d | ||
|
|
5590e64e0a | ||
|
|
8379f8ac6a | ||
|
|
fcd6d41586 | ||
|
|
c72b04a413 | ||
|
|
342bf0caed | ||
|
|
850b18ab35 | ||
|
|
f2437b4722 | ||
|
|
595d84fb7c | ||
|
|
26246e3ef7 | ||
|
|
70196d69ad | ||
|
|
5f6ba57b33 | ||
|
|
749d465556 | ||
|
|
f143a94426 | ||
|
|
916ad43f4e | ||
|
|
4850d03825 | ||
|
|
8c72eb65ff | ||
|
|
be2ffe7580 | ||
|
|
a0a54716b8 | ||
|
|
386c85c01b | ||
|
|
908a7bfcc0 | ||
|
|
a2e0e483b5 | ||
|
|
f84e6d4598 | ||
|
|
5e5247aee1 | ||
|
|
2e27485e3b | ||
|
|
67cb2f1c8f | ||
|
|
f2ff6eaa4a | ||
|
|
2367709b2e | ||
|
|
3fc266a061 | ||
|
|
a008f6b57c | ||
|
|
27ef8da039 | ||
|
|
e45665502f | ||
|
|
c6297469d7 | ||
|
|
b419b400ba | ||
|
|
e7a7a87e48 | ||
|
|
61cb198893 | ||
|
|
dc02747f87 | ||
|
|
676c3d6b79 | ||
|
|
e32ed43c29 | ||
|
|
b4fabf70c2 | ||
|
|
e0af232f76 | ||
|
|
bdd9997bb5 | ||
|
|
950503d231 | ||
|
|
20a6275ae8 | ||
|
|
ef187ed37e | ||
|
|
11f6818663 | ||
|
|
41ef3b1d22 | ||
|
|
1ddec5f97b | ||
|
|
9ddd4a63bb | ||
|
|
3f1d9e3be0 | ||
|
|
fa7c5ee40d | ||
|
|
10ee12bfcd | ||
|
|
a43e5861d7 | ||
|
|
1724dcc8ff | ||
|
|
aca11bdb40 | ||
|
|
862ee9a2d0 | ||
|
|
a1f29738ab | ||
|
|
b03919ed86 | ||
|
|
d5c6c67f11 | ||
|
|
07d33798a0 | ||
|
|
27a748c6a6 | ||
|
|
9c839854fa | ||
|
|
fb2ea36c4b | ||
|
|
6ae4d63c30 | ||
|
|
ae3ef67825 | ||
|
|
751412e639 | ||
|
|
c73921af4f | ||
|
|
ab9106f902 | ||
|
|
aad6940ca7 | ||
|
|
470e4264b2 | ||
|
|
72e76638ff | ||
|
|
af1388a067 | ||
|
|
8205a7c33f | ||
|
|
f532372535 | ||
|
|
a2a34a4e2f | ||
|
|
6f96c9e3ff | ||
|
|
9aca12e0a5 | ||
|
|
ead55fe0e3 | ||
|
|
f2820471bc | ||
|
|
fb7885ada2 | ||
|
|
f9f4dc5a92 | ||
|
|
ffe4f562cc | ||
|
|
a906428734 | ||
|
|
abc7e6fec1 | ||
|
|
3b01cf3782 | ||
|
|
53d616fb16 | ||
|
|
8168c1f201 | ||
|
|
a0e1e032d6 | ||
|
|
77eca7578f | ||
|
|
d13badca50 | ||
|
|
acf4f84cae | ||
|
|
c24d135815 | ||
|
|
0d64476b04 | ||
|
|
091e110afd | ||
|
|
de8ba52643 | ||
|
|
8a2bb6eb32 | ||
|
|
ed649fd1b1 | ||
|
|
4cd4b99ae0 | ||
|
|
c903afa09d | ||
|
|
8aeb11f771 | ||
|
|
ed51b826a0 | ||
|
|
bb84eeb35e | ||
|
|
8a9fd2a97c | ||
|
|
3b49f9a67f | ||
|
|
2a4faedf67 | ||
|
|
82f7f82f54 | ||
|
|
276922104c | ||
|
|
3bd4a6673f | ||
|
|
1909feceba | ||
|
|
e585341933 | ||
|
|
e87054f0d3 | ||
|
|
6b0bd77d49 | ||
|
|
77f4cbcdd3 | ||
|
|
928c5938e9 | ||
|
|
03500d70af | ||
|
|
2c30a5361f | ||
|
|
c59d31fc21 | ||
|
|
5115ba6d8a | ||
|
|
4daab3d286 | ||
|
|
34512e5e49 | ||
|
|
0fddd90e1f | ||
|
|
29b6a58769 | ||
|
|
549b2e3815 | ||
|
|
88ef7d7eca | ||
|
|
d70c3f92ad | ||
|
|
4a25fed9d5 | ||
|
|
6fb4d43500 | ||
|
|
76dca88b62 | ||
|
|
bc7fb94d63 | ||
|
|
2bedc6cd31 | ||
|
|
c0f748756b | ||
|
|
181a8aeb1b | ||
|
|
c45f7b8148 | ||
|
|
1d21665c16 | ||
|
|
b87d3c612b | ||
|
|
d6757d67f8 | ||
|
|
376e44ec6c | ||
|
|
94402d96ad | ||
|
|
d3a1bf7eb6 | ||
|
|
beb9370fc5 | ||
|
|
b2bc692cc2 |
@@ -5,7 +5,7 @@ end_of_line = lf
|
|||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
|
|
||||||
[*.{py,cpp,h,swift,launch}]
|
[*.{py,swift,launch}]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
|
|
||||||
|
|||||||
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
/deploy/ros_lib/
|
|
||||||
*.pyc
|
*.pyc
|
||||||
|
*.DS_Store
|
||||||
|
/images
|
||||||
@@ -13,8 +13,8 @@
|
|||||||
"WireShark",
|
"WireShark",
|
||||||
"Wi-Fi",
|
"Wi-Fi",
|
||||||
"Raspberry Pi",
|
"Raspberry Pi",
|
||||||
"PixHawk",
|
"Pixhawk",
|
||||||
"PixRacer",
|
"Pixracer",
|
||||||
"ArUco"
|
"ArUco"
|
||||||
],
|
],
|
||||||
"code_blocks": false
|
"code_blocks": false
|
||||||
|
|||||||
35
.travis.yml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
sudo: required
|
||||||
|
language: generic
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
- DOCKER="smirart/img-tool:v0.1"
|
||||||
|
- TARGET_REPO="https://github.com/${TRAVIS_REPO_SLUG}.git"
|
||||||
|
- if [[ -z ${TRAVIS_TAG} ]]; then IMAGE_VERSION="${TRAVIS_COMMIT}}"; else IMAGE_VERSION="${TRAVIS_TAG}"; fi
|
||||||
|
- IMAGE_NAME="$(basename -s '.git' ${TARGET_REPO})_${IMAGE_VERSION}.img"
|
||||||
|
git:
|
||||||
|
depth: 1
|
||||||
|
before_script:
|
||||||
|
- docker pull ${DOCKER}
|
||||||
|
script:
|
||||||
|
- docker run --privileged --rm -v /dev:/dev -v $(pwd):/builder/repo -e TRAVIS_TAG="${TRAVIS_TAG}" ${DOCKER}
|
||||||
|
before_deploy:
|
||||||
|
# Set up git user name and tag this commit
|
||||||
|
- git config --local user.name "urpylka"
|
||||||
|
- git config --local user.email "urpylka@gmail.com"
|
||||||
|
- sudo chmod -R 777 *
|
||||||
|
- cd images && zip ${IMAGE_NAME}.zip ${IMAGE_NAME}
|
||||||
|
deploy:
|
||||||
|
provider: releases
|
||||||
|
api_key: ${GITHUB_OAUTH_TOKEN}
|
||||||
|
file: ${IMAGE_NAME}.zip
|
||||||
|
skip_cleanup: true
|
||||||
|
on:
|
||||||
|
tags: true
|
||||||
|
|
||||||
|
# More info there
|
||||||
|
# https://github.com/travis-ci/travis-ci/issues/6893
|
||||||
|
# https://docs.travis-ci.com/user/customizing-the-build/
|
||||||
|
# https://docs.travis-ci.com/user/deployment/releases
|
||||||
|
# https://docs.travis-ci.com/user/environment-variables/
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2018 Copter Express
|
Copyright (c) 2018 Copter Express Technologies
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Use it to learn how to assemble, configure, pilot and program autonomous CLEVER
|
|||||||
|
|
||||||
**Preconfigured image for Raspberry Pi 3 with installed and configured software, ready to fly, is available [in the Releases section](https://github.com/CopterExpress/clever/releases).**
|
**Preconfigured image for Raspberry Pi 3 with installed and configured software, ready to fly, is available [in the Releases section](https://github.com/CopterExpress/clever/releases).**
|
||||||
|
|
||||||
[](http://builder.coex.space/job/CopterExpress---clever/)
|
[](https://travis-ci.org/urpylka/clever)
|
||||||
|
|
||||||
Image includes:
|
Image includes:
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
theme: jekyll-theme-cayman
|
|
||||||
tagline: Конструктор программируемого квадрокоптера
|
|
||||||
@@ -1,21 +1,12 @@
|
|||||||
PODS:
|
PODS:
|
||||||
- MarqueeLabel/Swift (3.1.4)
|
|
||||||
- NotificationBannerSwift (1.5.4):
|
|
||||||
- MarqueeLabel/Swift
|
|
||||||
- SnapKit (~> 4.0)
|
|
||||||
- SnapKit (4.0.0)
|
|
||||||
- SwiftSocket (2.0.2)
|
- SwiftSocket (2.0.2)
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
- NotificationBannerSwift
|
|
||||||
- SwiftSocket (~> 2.0)
|
- SwiftSocket (~> 2.0)
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
MarqueeLabel: bf768455fe88d427f71476ebb23f9092b660f40b
|
|
||||||
NotificationBannerSwift: 4f6666c8421dcf11be0812dd1093d932c15921af
|
|
||||||
SnapKit: a42d492c16e80209130a3379f73596c3454b7694
|
|
||||||
SwiftSocket: 6f4c9c63fbc5c1d61188936bb3c599fd546f40ae
|
SwiftSocket: 6f4c9c63fbc5c1d61188936bb3c599fd546f40ae
|
||||||
|
|
||||||
PODFILE CHECKSUM: fd5199f69c3ee8c1fbc0dd582477d890c8b2a24f
|
PODFILE CHECKSUM: 2044f57d00f536792fbc38c63ded4fa78dcc135c
|
||||||
|
|
||||||
COCOAPODS: 1.4.0
|
COCOAPODS: 1.4.0
|
||||||
|
|||||||
@@ -226,16 +226,10 @@
|
|||||||
);
|
);
|
||||||
inputPaths = (
|
inputPaths = (
|
||||||
"${SRCROOT}/Pods/Target Support Files/Pods-cleverrc/Pods-cleverrc-frameworks.sh",
|
"${SRCROOT}/Pods/Target Support Files/Pods-cleverrc/Pods-cleverrc-frameworks.sh",
|
||||||
"${BUILT_PRODUCTS_DIR}/MarqueeLabel/MarqueeLabel.framework",
|
|
||||||
"${BUILT_PRODUCTS_DIR}/NotificationBannerSwift/NotificationBannerSwift.framework",
|
|
||||||
"${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework",
|
|
||||||
"${BUILT_PRODUCTS_DIR}/SwiftSocket/SwiftSocket.framework",
|
"${BUILT_PRODUCTS_DIR}/SwiftSocket/SwiftSocket.framework",
|
||||||
);
|
);
|
||||||
name = "[CP] Embed Pods Frameworks";
|
name = "[CP] Embed Pods Frameworks";
|
||||||
outputPaths = (
|
outputPaths = (
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MarqueeLabel.framework",
|
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/NotificationBannerSwift.framework",
|
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework",
|
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftSocket.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftSocket.framework",
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -397,7 +391,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
DEVELOPMENT_TEAM = 7QY6KJ2672;
|
DEVELOPMENT_TEAM = M8TDN3PAH2;
|
||||||
INFOPLIST_FILE = cleverrc/Info.plist;
|
INFOPLIST_FILE = cleverrc/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = coex.cleverrc;
|
PRODUCT_BUNDLE_IDENTIFIER = coex.cleverrc;
|
||||||
@@ -413,7 +407,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
DEVELOPMENT_TEAM = 7QY6KJ2672;
|
DEVELOPMENT_TEAM = M8TDN3PAH2;
|
||||||
INFOPLIST_FILE = cleverrc/Info.plist;
|
INFOPLIST_FILE = cleverrc/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = coex.cleverrc;
|
PRODUCT_BUNDLE_IDENTIFIER = coex.cleverrc;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// cleverrc
|
// cleverrc
|
||||||
//
|
//
|
||||||
// Created by Oleg Kalachev on 20.01.2018.
|
// Created by Oleg Kalachev on 20.01.2018.
|
||||||
// Copyright © 2018 Copter Express. All rights reserved.
|
// Copyright © 2018 Copter Express Technologies. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|||||||
@@ -3,114 +3,176 @@
|
|||||||
{
|
{
|
||||||
"size" : "20x20",
|
"size" : "20x20",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "cleverrc40.png",
|
"filename" : "Icon-App-20x20@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "20x20",
|
"size" : "20x20",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "clever60.png",
|
"filename" : "Icon-App-20x20@3x.png",
|
||||||
"scale" : "3x"
|
"scale" : "3x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "29x29",
|
"size" : "29x29",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "clever58.png",
|
"filename" : "Icon-App-29x29@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "29x29",
|
"size" : "29x29",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "clever87.png",
|
"filename" : "Icon-App-29x29@3x.png",
|
||||||
"scale" : "3x"
|
"scale" : "3x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "40x40",
|
"size" : "40x40",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "clever80.png",
|
"filename" : "Icon-App-40x40@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "40x40",
|
"size" : "40x40",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "clever120.png",
|
"filename" : "Icon-App-40x40@3x.png",
|
||||||
"scale" : "3x"
|
"scale" : "3x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "60x60",
|
"size" : "60x60",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "clever120-1.png",
|
"filename" : "Icon-App-60x60@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "60x60",
|
"size" : "60x60",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "clever180-1.png",
|
"filename" : "Icon-App-60x60@3x.png",
|
||||||
"scale" : "3x"
|
"scale" : "3x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "20x20",
|
"size" : "20x20",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "clever20.png",
|
"filename" : "Icon-App-20x20@1x.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "20x20",
|
"size" : "20x20",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "clever40.png",
|
"filename" : "Icon-App-20x20@2x-1.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "29x29",
|
"size" : "29x29",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "clever29.png",
|
"filename" : "Icon-App-29x29@1x.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "29x29",
|
"size" : "29x29",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "clever58-1.png",
|
"filename" : "Icon-App-29x29@2x-1.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "40x40",
|
"size" : "40x40",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "clever40-1.png",
|
"filename" : "Icon-App-40x40@1x.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "40x40",
|
"size" : "40x40",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "clever80-1.png",
|
"filename" : "Icon-App-40x40@2x-1.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "76x76",
|
"size" : "76x76",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "clever76.png",
|
"filename" : "Icon-App-76x76@1x.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "76x76",
|
"size" : "76x76",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "clever152.png",
|
"filename" : "Icon-App-76x76@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "83.5x83.5",
|
"size" : "83.5x83.5",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "clever167.png",
|
"filename" : "Icon-App-83.5x83.5@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "1024x1024",
|
"size" : "1024x1024",
|
||||||
"idiom" : "ios-marketing",
|
"idiom" : "ios-marketing",
|
||||||
"filename" : "clever1024.png",
|
"filename" : "ItunesArtwork@2x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "24x24",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "notificationCenter",
|
||||||
|
"subtype" : "38mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "27.5x27.5",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "notificationCenter",
|
||||||
|
"subtype" : "42mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"role" : "companionSettings",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"role" : "companionSettings",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "appLauncher",
|
||||||
|
"subtype" : "38mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "44x44",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "longLook",
|
||||||
|
"subtype" : "42mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "86x86",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "quickLook",
|
||||||
|
"subtype" : "38mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "98x98",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "quickLook",
|
||||||
|
"subtype" : "42mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "watch-marketing",
|
||||||
|
"size" : "1024x1024",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info" : {
|
"info" : {
|
||||||
"version" : 1,
|
"version" : 1,
|
||||||
"author" : "xcode"
|
"author" : "xcode"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"pre-rendered" : true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
After Width: | Height: | Size: 638 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 9.6 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 508 B |
|
Before Width: | Height: | Size: 659 B |
|
Before Width: | Height: | Size: 867 B |
|
Before Width: | Height: | Size: 867 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 867 B |
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"images" : [
|
|
||||||
{
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "1x"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "2x"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "3x"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"info" : {
|
|
||||||
"version" : 1,
|
|
||||||
"author" : "xcode"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,9 +17,9 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0</string>
|
<string>1.1</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>5</string>
|
<string>6</string>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>UILaunchStoryboardName</key>
|
<key>UILaunchStoryboardName</key>
|
||||||
|
|||||||
@@ -3,13 +3,12 @@
|
|||||||
// cleverrc
|
// cleverrc
|
||||||
//
|
//
|
||||||
// Created by Oleg Kalachev on 20.01.2018.
|
// Created by Oleg Kalachev on 20.01.2018.
|
||||||
// Copyright © 2018 Copter Express. All rights reserved.
|
// Copyright © 2018 Copter Express Technologies. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import WebKit
|
import WebKit
|
||||||
import SwiftSocket
|
import SwiftSocket
|
||||||
import NotificationBannerSwift
|
|
||||||
import AudioToolbox.AudioServices
|
import AudioToolbox.AudioServices
|
||||||
|
|
||||||
class ViewController: UIViewController, WKScriptMessageHandler {
|
class ViewController: UIViewController, WKScriptMessageHandler {
|
||||||
|
|||||||
@@ -16,11 +16,15 @@ find_package(catkin REQUIRED COMPONENTS
|
|||||||
image_transport
|
image_transport
|
||||||
cv_bridge
|
cv_bridge
|
||||||
tf
|
tf
|
||||||
#tf2
|
tf2
|
||||||
#tf2_ros
|
tf2_ros
|
||||||
#aruco_msgs
|
tf2_geometry_msgs
|
||||||
|
sensor_msgs
|
||||||
|
message_generation
|
||||||
)
|
)
|
||||||
|
|
||||||
|
find_package(OpenCV REQUIRED)
|
||||||
|
|
||||||
## System dependencies are found with CMake's conventions
|
## System dependencies are found with CMake's conventions
|
||||||
# find_package(Boost REQUIRED COMPONENTS system)
|
# find_package(Boost REQUIRED COMPONENTS system)
|
||||||
|
|
||||||
@@ -55,11 +59,12 @@ find_package(catkin REQUIRED COMPONENTS
|
|||||||
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
|
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
|
||||||
|
|
||||||
## Generate messages in the 'msg' folder
|
## Generate messages in the 'msg' folder
|
||||||
#add_message_files(
|
add_message_files(
|
||||||
# FILES
|
FILES
|
||||||
# Marker.msg
|
Point2D.msg
|
||||||
# MarkerArray.msg
|
Marker.msg
|
||||||
#)
|
MarkerArray.msg
|
||||||
|
)
|
||||||
|
|
||||||
## Generate services in the 'srv' folder
|
## Generate services in the 'srv' folder
|
||||||
# add_service_files(
|
# add_service_files(
|
||||||
@@ -76,10 +81,11 @@ find_package(catkin REQUIRED COMPONENTS
|
|||||||
# )
|
# )
|
||||||
|
|
||||||
## Generate added messages and services with any dependencies listed here
|
## Generate added messages and services with any dependencies listed here
|
||||||
#generate_messages(
|
generate_messages(
|
||||||
# DEPENDENCIES
|
DEPENDENCIES
|
||||||
# std_msgs # Or other packages containing msgs
|
std_msgs
|
||||||
#)
|
geometry_msgs
|
||||||
|
)
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
## Declare ROS dynamic reconfigure parameters ##
|
## Declare ROS dynamic reconfigure parameters ##
|
||||||
@@ -111,9 +117,9 @@ find_package(catkin REQUIRED COMPONENTS
|
|||||||
## CATKIN_DEPENDS: catkin_packages dependent projects also need
|
## CATKIN_DEPENDS: catkin_packages dependent projects also need
|
||||||
## DEPENDS: system dependencies of this project that dependent projects also need
|
## DEPENDS: system dependencies of this project that dependent projects also need
|
||||||
catkin_package(
|
catkin_package(
|
||||||
# INCLUDE_DIRS include
|
INCLUDE_DIRS DEPENDS OpenCV
|
||||||
LIBRARIES aruco_pose
|
LIBRARIES aruco_pose
|
||||||
# CATKIN_DEPENDS other_catkin_pkg
|
CATKIN_DEPENDS message_runtime
|
||||||
# DEPENDS system_lib
|
# DEPENDS system_lib
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -126,11 +132,13 @@ catkin_package(
|
|||||||
include_directories(
|
include_directories(
|
||||||
# include
|
# include
|
||||||
${catkin_INCLUDE_DIRS}
|
${catkin_INCLUDE_DIRS}
|
||||||
|
${OpenCV_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
## Declare a C++ library
|
## Declare a C++ library
|
||||||
add_library(${PROJECT_NAME}
|
add_library(aruco_pose
|
||||||
src/aruco_pose.cpp
|
src/aruco_detect.cpp
|
||||||
|
src/aruco_map.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
## Add cmake target dependencies of the library
|
## Add cmake target dependencies of the library
|
||||||
@@ -154,11 +162,9 @@ add_library(${PROJECT_NAME}
|
|||||||
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||||
|
|
||||||
## Specify libraries to link a library or executable target against
|
## Specify libraries to link a library or executable target against
|
||||||
link_directories(/opt/ros/kinetic/lib)
|
target_link_libraries(aruco_pose
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
|
||||||
${catkin_LIBRARIES}
|
${catkin_LIBRARIES}
|
||||||
"/opt/ros/kinetic/lib/libopencv_aruco3.so" # TODO: fix launch fails with .so loading
|
${OpenCV_LIBS}
|
||||||
)
|
)
|
||||||
|
|
||||||
#############
|
#############
|
||||||
|
|||||||
4
aruco_pose/map/map.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
1 0.33 0 0 0 0 0 0
|
||||||
|
2 0.33 1 0 0 0 0 0
|
||||||
|
3 0.33 0 1 0 0 0 0
|
||||||
|
4 0.33 1 1 0 0 0 0
|
||||||
6
aruco_pose/msg/Marker.msg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
uint32 id
|
||||||
|
geometry_msgs/PoseWithCovariance pose
|
||||||
|
Point2D c1
|
||||||
|
Point2D c2
|
||||||
|
Point2D c3
|
||||||
|
Point2D c4
|
||||||
2
aruco_pose/msg/MarkerArray.msg
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Header header
|
||||||
|
Marker[] markers
|
||||||
2
aruco_pose/msg/Point2D.msg
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
float32 x
|
||||||
|
float32 y
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
<library path="lib/libaruco_pose">
|
<library path="lib/libaruco_pose">
|
||||||
<class name="aruco_pose/aruco_pose" type="ArucoPose" base_class_type="nodelet::Nodelet">
|
<class name="aruco_pose/aruco_detect" type="ArucoDetect" base_class_type="nodelet::Nodelet">
|
||||||
|
<description/>
|
||||||
|
</class>
|
||||||
|
<class name="aruco_pose/aruco_map" type="ArucoMap" base_class_type="nodelet::Nodelet">
|
||||||
<description/>
|
<description/>
|
||||||
</class>
|
</class>
|
||||||
</library>
|
</library>
|
||||||
|
|||||||
@@ -2,61 +2,43 @@
|
|||||||
<package>
|
<package>
|
||||||
<name>aruco_pose</name>
|
<name>aruco_pose</name>
|
||||||
<version>0.0.0</version>
|
<version>0.0.0</version>
|
||||||
<description>ArUco maps precise pose estimation nodelet</description>
|
<description>Positioning by ArUco markers</description>
|
||||||
|
|
||||||
<!-- One maintainer tag required, multiple allowed, one person per tag -->
|
|
||||||
<!-- Example: -->
|
|
||||||
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
|
|
||||||
<maintainer email="okalachev@gmail.com">Oleg Kalachev</maintainer>
|
<maintainer email="okalachev@gmail.com">Oleg Kalachev</maintainer>
|
||||||
|
<license>MIT</license>
|
||||||
|
|
||||||
|
<!--url type="website">http://wiki.ros.org/aruco_pose</url-->
|
||||||
|
<author email="okalachev@gmail.com">Oleg Kalachev</author>
|
||||||
|
<author email="urpylka@gmail.com">Artem Smirnov</author>
|
||||||
|
|
||||||
<!-- One license tag required, multiple allowed, one license per tag -->
|
|
||||||
<!-- Commonly used license strings: -->
|
|
||||||
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
|
|
||||||
<license>TODO</license>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Url tags are optional, but multiple are allowed, one per tag -->
|
|
||||||
<!-- Optional attribute type can be: website, bugtracker, or repository -->
|
|
||||||
<!-- Example: -->
|
|
||||||
<!-- <url type="website">http://wiki.ros.org/aruco_pose</url> -->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Author tags are optional, multiple are allowed, one per tag -->
|
|
||||||
<!-- Authors do not have to be maintainers, but could be -->
|
|
||||||
<!-- Example: -->
|
|
||||||
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- The *_depend tags are used to specify dependencies -->
|
|
||||||
<!-- Dependencies can be catkin packages or system dependencies -->
|
|
||||||
<!-- Examples: -->
|
|
||||||
<!-- Use build_depend for packages you need at compile time: -->
|
|
||||||
<!-- <build_depend>message_generation</build_depend> -->
|
|
||||||
<!-- Use buildtool_depend for build tool packages: -->
|
|
||||||
<!-- <buildtool_depend>catkin</buildtool_depend> -->
|
|
||||||
<!-- Use run_depend for packages you need at runtime: -->
|
|
||||||
<!-- <run_depend>message_runtime</run_depend> -->
|
|
||||||
<!-- Use test_depend for packages you need only for testing: -->
|
|
||||||
<!-- <test_depend>gtest</test_depend> -->
|
|
||||||
<buildtool_depend>catkin</buildtool_depend>
|
<buildtool_depend>catkin</buildtool_depend>
|
||||||
|
|
||||||
|
<build_depend>tf</build_depend>
|
||||||
|
<build_depend>tf2</build_depend>
|
||||||
|
<build_depend>tf2_ros</build_depend>
|
||||||
|
<build_depend>tf2_geometry_msgs</build_depend>
|
||||||
|
<build_depend>cv_bridge</build_depend>
|
||||||
|
<build_depend>dynamic_reconfigure</build_depend>
|
||||||
|
<build_depend>image_transport</build_depend>
|
||||||
|
<build_depend>message_generation</build_depend>
|
||||||
|
<build_depend>message_runtime</build_depend>
|
||||||
<build_depend>nodelet</build_depend>
|
<build_depend>nodelet</build_depend>
|
||||||
<build_depend>roscpp</build_depend>
|
<build_depend>roscpp</build_depend>
|
||||||
<build_depend>image_transport</build_depend>
|
<build_depend>std_msgs</build_depend>
|
||||||
<build_depend>cv_bridge</build_depend>
|
|
||||||
<build_depend>tf</build_depend>
|
|
||||||
|
|
||||||
<run_depend>nodelet</run_depend>
|
<run_depend>nodelet</run_depend>
|
||||||
<run_depend>roscpp</run_depend>
|
<run_depend>roscpp</run_depend>
|
||||||
<run_depend>image_transport</run_depend>
|
<run_depend>image_transport</run_depend>
|
||||||
<run_depend>cv_bridge</run_depend>
|
<run_depend>cv_bridge</run_depend>
|
||||||
<build_depend>tf</build_depend>
|
<run_depend>message_runtime</run_depend>
|
||||||
|
<run_depend>std_msgs</run_depend>
|
||||||
|
<run_depend>tf</run_depend>
|
||||||
|
<run_depend>tf2</run_depend>
|
||||||
|
<run_depend>tf2_ros</run_depend>
|
||||||
|
<run_depend>tf2_geometry_msgs</run_depend>
|
||||||
|
|
||||||
<!-- The export tag contains other, unspecified, tags -->
|
<!-- The export tag contains other, unspecified, tags -->
|
||||||
<export>
|
<export>
|
||||||
<nodelet plugin="${prefix}/nodelet_plugins.xml" />
|
<nodelet plugin="${prefix}/nodelet_plugins.xml" />
|
||||||
<!-- Other tools can request additional information be placed here -->
|
<!-- Other tools can request additional information be placed here -->
|
||||||
|
|
||||||
</export>
|
</export>
|
||||||
</package>
|
</package>
|
||||||
|
|||||||
293
aruco_pose/src/aruco_detect.cpp
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
/*
|
||||||
|
* Detecting and positioning ArUco markers
|
||||||
|
* Copyright (C) 2018 Copter Express Technologies
|
||||||
|
*
|
||||||
|
* Author: Oleg Kalachev <okalachev@gmail.com>
|
||||||
|
*
|
||||||
|
* Distributed under MIT License (available at https://opensource.org/licenses/MIT).
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Code is based on https://github.com/UbiquityRobotics/fiducials, which is distributed
|
||||||
|
* under the BSD license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <ros/ros.h>
|
||||||
|
#include <nodelet/nodelet.h>
|
||||||
|
#include <pluginlib/class_list_macros.h>
|
||||||
|
#include <tf/transform_datatypes.h>
|
||||||
|
#include <tf2_ros/buffer.h>
|
||||||
|
#include <tf2_ros/transform_listener.h>
|
||||||
|
#include <tf2_ros/transform_broadcaster.h>
|
||||||
|
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
|
||||||
|
#include <image_transport/image_transport.h>
|
||||||
|
#include <cv_bridge/cv_bridge.h>
|
||||||
|
#include <geometry_msgs/Vector3.h>
|
||||||
|
#include <geometry_msgs/Pose.h>
|
||||||
|
#include <geometry_msgs/PoseStamped.h>
|
||||||
|
#include <geometry_msgs/PoseWithCovarianceStamped.h>
|
||||||
|
#include <geometry_msgs/TransformStamped.h>
|
||||||
|
#include <visualization_msgs/Marker.h>
|
||||||
|
#include <visualization_msgs/MarkerArray.h>
|
||||||
|
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include <opencv2/highgui.hpp>
|
||||||
|
#include <opencv2/aruco.hpp>
|
||||||
|
#include <opencv2/imgproc/imgproc.hpp>
|
||||||
|
#include <opencv2/calib3d/calib3d.hpp>
|
||||||
|
|
||||||
|
#include <aruco_pose/Marker.h>
|
||||||
|
#include <aruco_pose/MarkerArray.h>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
|
using cv::Mat;
|
||||||
|
|
||||||
|
class ArucoDetect : public nodelet::Nodelet {
|
||||||
|
private:
|
||||||
|
ros::NodeHandle nh_, nh_priv_;
|
||||||
|
tf2_ros::TransformBroadcaster br_;
|
||||||
|
tf2_ros::Buffer tf_buffer_;
|
||||||
|
tf2_ros::TransformListener tf_listener_{tf_buffer_};
|
||||||
|
cv::Ptr<cv::aruco::Dictionary> dictionary_;
|
||||||
|
cv::Ptr<cv::aruco::DetectorParameters> parameters_;
|
||||||
|
image_transport::Publisher debug_pub_;
|
||||||
|
image_transport::CameraSubscriber img_sub_;
|
||||||
|
ros::Publisher markers_pub_, vis_markers_pub_;
|
||||||
|
bool estimate_poses_, send_tf_;
|
||||||
|
double length_;
|
||||||
|
std::string snap_orientation_;
|
||||||
|
Mat camera_matrix_, dist_coeffs_;
|
||||||
|
aruco_pose::MarkerArray array_;
|
||||||
|
visualization_msgs::MarkerArray vis_array_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void onInit()
|
||||||
|
{
|
||||||
|
nh_ = getNodeHandle();
|
||||||
|
nh_priv_ = getPrivateNodeHandle();
|
||||||
|
|
||||||
|
int dictionary;
|
||||||
|
nh_priv_.param("dictionary", dictionary, 2);
|
||||||
|
nh_priv_.param("estimate_poses", estimate_poses_, true);
|
||||||
|
nh_priv_.param("send_tf", send_tf_, true);
|
||||||
|
if (estimate_poses_ && !nh_priv_.getParam("length", length_)) {
|
||||||
|
ROS_FATAL("aruco_detect: can't estimate marker's poses as ~length parameter is not defined");
|
||||||
|
ros::shutdown();
|
||||||
|
}
|
||||||
|
nh_priv_.param<std::string>("snap_orientation", snap_orientation_, "");
|
||||||
|
|
||||||
|
camera_matrix_ = cv::Mat::zeros(3, 3, CV_64F);
|
||||||
|
dist_coeffs_ = cv::Mat::zeros(8, 1, CV_64F);
|
||||||
|
|
||||||
|
dictionary_ = cv::aruco::getPredefinedDictionary(static_cast<cv::aruco::PREDEFINED_DICTIONARY_NAME>(dictionary));
|
||||||
|
parameters_ = cv::aruco::DetectorParameters::create();
|
||||||
|
parameters_->cornerRefinementMethod = cv::aruco::CORNER_REFINE_SUBPIX;
|
||||||
|
|
||||||
|
image_transport::ImageTransport it(nh_);
|
||||||
|
image_transport::ImageTransport it_priv(nh_priv_);
|
||||||
|
|
||||||
|
debug_pub_ = it_priv.advertise("debug", 1);
|
||||||
|
markers_pub_ = nh_priv_.advertise<aruco_pose::MarkerArray>("markers", 1);
|
||||||
|
vis_markers_pub_ = nh_priv_.advertise<visualization_msgs::MarkerArray>("visualization", 1);
|
||||||
|
img_sub_ = it.subscribeCamera("image_raw", 1, &ArucoDetect::imageCallback, this);
|
||||||
|
|
||||||
|
ROS_INFO("aruco_detect: ready");
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void imageCallback(const sensor_msgs::ImageConstPtr& msg, const sensor_msgs::CameraInfoConstPtr &cinfo)
|
||||||
|
{
|
||||||
|
Mat image = cv_bridge::toCvShare(msg, "bgr8")->image;
|
||||||
|
|
||||||
|
vector<int> ids;
|
||||||
|
vector<vector<cv::Point2f>> corners, rejected;
|
||||||
|
vector<cv::Vec3d> rvecs, tvecs;
|
||||||
|
vector<cv::Point3f> obj_points;
|
||||||
|
geometry_msgs::TransformStamped snap_to;
|
||||||
|
|
||||||
|
// Detect markers
|
||||||
|
cv::aruco::detectMarkers(image, dictionary_, corners, ids, parameters_, rejected);
|
||||||
|
|
||||||
|
array_.header.stamp = msg->header.stamp;
|
||||||
|
array_.header.frame_id = msg->header.frame_id;
|
||||||
|
array_.markers.clear();
|
||||||
|
|
||||||
|
if (ids.size() != 0) {
|
||||||
|
parseCameraInfo(cinfo, camera_matrix_, dist_coeffs_);
|
||||||
|
|
||||||
|
// Estimate individual markers' poses
|
||||||
|
if (estimate_poses_) {
|
||||||
|
cv::aruco::estimatePoseSingleMarkers(corners, length_, camera_matrix_, dist_coeffs_,
|
||||||
|
rvecs, tvecs);
|
||||||
|
|
||||||
|
if (!snap_orientation_.empty()) {
|
||||||
|
try {
|
||||||
|
snap_to = tf_buffer_.lookupTransform(msg->header.frame_id, snap_orientation_,
|
||||||
|
msg->header.stamp, ros::Duration(0.02));
|
||||||
|
} catch (const tf2::TransformException& e) {
|
||||||
|
ROS_WARN_THROTTLE(5, "aruco_detect: can't snap: %s", e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
array_.markers.reserve(ids.size());
|
||||||
|
aruco_pose::Marker marker;
|
||||||
|
geometry_msgs::TransformStamped transform;
|
||||||
|
transform.header.stamp = msg->header.stamp;
|
||||||
|
transform.header.frame_id = msg->header.frame_id;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < ids.size(); i++) {
|
||||||
|
marker.id = ids[i];
|
||||||
|
fillCorners(marker, corners[i]);
|
||||||
|
|
||||||
|
if (estimate_poses_) {
|
||||||
|
fillPose(marker.pose.pose, rvecs[i], tvecs[i]);
|
||||||
|
|
||||||
|
// snap orientation (if enabled and snap frame avaiable)
|
||||||
|
if (!snap_orientation_.empty() && !snap_to.header.frame_id.empty()) {
|
||||||
|
snapOrientation(marker.pose.pose, snap_to.transform.rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: check IDs are unique
|
||||||
|
if (send_tf_) {
|
||||||
|
transform.child_frame_id = getChildFrameId(ids[i]);
|
||||||
|
transform.transform.rotation = marker.pose.pose.orientation;
|
||||||
|
fillTranslation(transform.transform.translation, tvecs[i]);
|
||||||
|
br_.sendTransform(transform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array_.markers.push_back(marker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
markers_pub_.publish(array_);
|
||||||
|
|
||||||
|
// Publish visualization markers
|
||||||
|
if (estimate_poses_ && vis_markers_pub_.getNumSubscribers() != 0) {
|
||||||
|
// Delete all markers
|
||||||
|
visualization_msgs::Marker vis_marker;
|
||||||
|
vis_marker.action = visualization_msgs::Marker::DELETEALL;
|
||||||
|
vis_array_.markers.clear();
|
||||||
|
vis_array_.markers.reserve(ids.size() + 1);
|
||||||
|
vis_array_.markers.push_back(vis_marker);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < ids.size(); i++)
|
||||||
|
pushVisMarkers(msg->header.frame_id, msg->header.stamp, array_.markers[i].pose.pose,
|
||||||
|
length_, ids[i], i);
|
||||||
|
|
||||||
|
vis_markers_pub_.publish(vis_array_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Publish debug image
|
||||||
|
if (debug_pub_.getNumSubscribers() != 0) {
|
||||||
|
Mat debug = image.clone();
|
||||||
|
cv::aruco::drawDetectedMarkers(debug, corners, ids); // draw markers
|
||||||
|
if (estimate_poses_)
|
||||||
|
for (unsigned int i = 0; i < ids.size(); i++)
|
||||||
|
cv::aruco::drawAxis(debug, camera_matrix_, dist_coeffs_, rvecs[i], tvecs[i], length_);
|
||||||
|
|
||||||
|
cv_bridge::CvImage out_msg;
|
||||||
|
out_msg.header.frame_id = msg->header.frame_id;
|
||||||
|
out_msg.header.stamp = msg->header.stamp;
|
||||||
|
out_msg.encoding = sensor_msgs::image_encodings::BGR8;
|
||||||
|
out_msg.image = debug;
|
||||||
|
debug_pub_.publish(out_msg.toImageMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void fillCorners(aruco_pose::Marker& marker, const vector<cv::Point2f>& corners) const
|
||||||
|
{
|
||||||
|
marker.c1.x = corners[0].x;
|
||||||
|
marker.c2.x = corners[1].x;
|
||||||
|
marker.c3.x = corners[2].x;
|
||||||
|
marker.c4.x = corners[3].x;
|
||||||
|
marker.c1.y = corners[0].y;
|
||||||
|
marker.c2.y = corners[1].y;
|
||||||
|
marker.c3.y = corners[2].y;
|
||||||
|
marker.c4.y = corners[3].y;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void fillPose(geometry_msgs::Pose& pose, const cv::Vec3d& rvec, const cv::Vec3d& tvec) const
|
||||||
|
{
|
||||||
|
pose.position.x = tvec[0];
|
||||||
|
pose.position.y = tvec[1];
|
||||||
|
pose.position.z = tvec[2];
|
||||||
|
|
||||||
|
double angle = norm(rvec);
|
||||||
|
cv::Vec3d axis = rvec / angle;
|
||||||
|
|
||||||
|
tf2::Quaternion q;
|
||||||
|
q.setRotation(tf2::Vector3(axis[0], axis[1], axis[2]), angle);
|
||||||
|
|
||||||
|
pose.orientation.w = q.w();
|
||||||
|
pose.orientation.x = q.x();
|
||||||
|
pose.orientation.y = q.y();
|
||||||
|
pose.orientation.z = q.z();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void fillTranslation(geometry_msgs::Vector3& translation, const cv::Vec3d& tvec) const
|
||||||
|
{
|
||||||
|
translation.x = tvec[0];
|
||||||
|
translation.y = tvec[1];
|
||||||
|
translation.z = tvec[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
void pushVisMarkers(const std::string& frame_id, const ros::Time& stamp,
|
||||||
|
const geometry_msgs::Pose &pose, double length, int id, int index)
|
||||||
|
{
|
||||||
|
visualization_msgs::Marker marker;
|
||||||
|
marker.header.frame_id = frame_id;
|
||||||
|
marker.header.stamp = stamp;
|
||||||
|
marker.action = visualization_msgs::Marker::ADD;
|
||||||
|
marker.id = index;
|
||||||
|
|
||||||
|
// Marker
|
||||||
|
marker.ns = "aruco_marker";
|
||||||
|
marker.type = visualization_msgs::Marker::CUBE;
|
||||||
|
marker.scale.x = length;
|
||||||
|
marker.scale.y = length;
|
||||||
|
marker.scale.z = 0.001;
|
||||||
|
marker.color.r = 1;
|
||||||
|
marker.color.g = 1;
|
||||||
|
marker.color.b = 1;
|
||||||
|
marker.color.a = 0.9;
|
||||||
|
marker.pose = pose;
|
||||||
|
vis_array_.markers.push_back(marker);
|
||||||
|
|
||||||
|
// Label
|
||||||
|
marker.ns = "aruco_marker_label";
|
||||||
|
marker.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
|
||||||
|
marker.scale.z = length * 0.6;
|
||||||
|
marker.color.r = 0;
|
||||||
|
marker.color.g = 0;
|
||||||
|
marker.color.b = 0;
|
||||||
|
marker.color.a = 1;
|
||||||
|
marker.text = std::to_string(id);
|
||||||
|
marker.pose = pose;
|
||||||
|
vis_array_.markers.push_back(marker);
|
||||||
|
}
|
||||||
|
|
||||||
|
void snapOrientation(geometry_msgs::Pose& pose, const geometry_msgs::Quaternion orientation)
|
||||||
|
{
|
||||||
|
tf::Quaternion q;
|
||||||
|
q.setRPY(0, 0, -tf::getYaw(pose.orientation) + tf::getYaw(orientation) + M_PI / 2);
|
||||||
|
tf::Quaternion pq;
|
||||||
|
tf::quaternionMsgToTF(orientation, pq);
|
||||||
|
pq = pq * q;
|
||||||
|
tf::quaternionTFToMsg(pq, pose.orientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string getChildFrameId(int id) const
|
||||||
|
{
|
||||||
|
return "aruco_" + std::to_string(id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
PLUGINLIB_EXPORT_CLASS(ArucoDetect, nodelet::Nodelet)
|
||||||
307
aruco_pose/src/aruco_map.cpp
Normal file
@@ -0,0 +1,307 @@
|
|||||||
|
/*
|
||||||
|
* Positioning ArUco markers maps
|
||||||
|
* Copyright (C) 2018 Copter Express Technologies
|
||||||
|
*
|
||||||
|
* Author: Oleg Kalachev <okalachev@gmail.com>
|
||||||
|
*
|
||||||
|
* Distributed under MIT License (available at https://opensource.org/licenses/MIT).
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Code is based on https://github.com/UbiquityRobotics/fiducials, which is distributed
|
||||||
|
* under the BSD license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <fstream>
|
||||||
|
#include <ros/ros.h>
|
||||||
|
#include <nodelet/nodelet.h>
|
||||||
|
#include <pluginlib/class_list_macros.h>
|
||||||
|
#include <image_transport/image_transport.h>
|
||||||
|
#include <cv_bridge/cv_bridge.h>
|
||||||
|
#include <tf2_ros/buffer.h>
|
||||||
|
#include <tf2_ros/transform_listener.h>
|
||||||
|
#include <tf2_ros/transform_broadcaster.h>
|
||||||
|
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
|
||||||
|
#include <geometry_msgs/TransformStamped.h>
|
||||||
|
#include <geometry_msgs/PoseWithCovarianceStamped.h>
|
||||||
|
#include <sensor_msgs/Image.h>
|
||||||
|
#include <visualization_msgs/Marker.h>
|
||||||
|
#include <visualization_msgs/MarkerArray.h>
|
||||||
|
|
||||||
|
#include <aruco_pose/MarkerArray.h>
|
||||||
|
#include <aruco_pose/Marker.h>
|
||||||
|
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include <opencv2/aruco.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "gridboard.h"
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
|
using cv::Mat;
|
||||||
|
|
||||||
|
class ArucoMap : public nodelet::Nodelet {
|
||||||
|
private:
|
||||||
|
ros::NodeHandle nh_, nh_priv_;
|
||||||
|
ros::Publisher img_pub_, pose_pub_;
|
||||||
|
ros::Subscriber markers_sub_, cinfo_sub;
|
||||||
|
cv::Ptr<cv::aruco::Board> board_;
|
||||||
|
Mat camera_matrix_, dist_coeffs_;
|
||||||
|
geometry_msgs::TransformStamped transform_;
|
||||||
|
geometry_msgs::PoseWithCovarianceStamped pose_;
|
||||||
|
tf2_ros::TransformBroadcaster br_;
|
||||||
|
tf2_ros::Buffer tf_buffer_;
|
||||||
|
tf2_ros::TransformListener tf_listener_{tf_buffer_};
|
||||||
|
visualization_msgs::MarkerArray vis_markers;
|
||||||
|
std::string snap_orientation_;
|
||||||
|
bool has_camera_info_ = false;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void onInit()
|
||||||
|
{
|
||||||
|
nh_ = getNodeHandle();
|
||||||
|
nh_priv_ = getPrivateNodeHandle();
|
||||||
|
|
||||||
|
image_transport::ImageTransport it_priv(nh_priv_);
|
||||||
|
|
||||||
|
// TODO: why image_transport doesn't work here?
|
||||||
|
img_pub_ = nh_priv_.advertise<sensor_msgs::Image>("image", 1, true);
|
||||||
|
|
||||||
|
board_ = cv::makePtr<cv::aruco::Board>();
|
||||||
|
board_->dictionary = cv::aruco::getPredefinedDictionary(
|
||||||
|
static_cast<cv::aruco::PREDEFINED_DICTIONARY_NAME>(nh_priv_.param("dictionary", 2)));
|
||||||
|
camera_matrix_ = cv::Mat::zeros(3, 3, CV_64F);
|
||||||
|
dist_coeffs_ = cv::Mat::zeros(8, 1, CV_64F);
|
||||||
|
|
||||||
|
std::string type, map, map_name;
|
||||||
|
nh_priv_.param<std::string>("type", type, "map");
|
||||||
|
|
||||||
|
if (type == "map") {
|
||||||
|
param(nh_priv_, "map", map);
|
||||||
|
loadMap(map);
|
||||||
|
} else if (type == "gridboard") {
|
||||||
|
createGridBoard();
|
||||||
|
} else {
|
||||||
|
ROS_FATAL("aruco_map: unknown type: %s", type.c_str());
|
||||||
|
ros::shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
nh_priv_.param<std::string>("name", map_name, "map");
|
||||||
|
nh_priv_.param<std::string>("frame_id", transform_.child_frame_id, "aruco_map");
|
||||||
|
nh_priv_.param<std::string>("snap_orientation", snap_orientation_, "");
|
||||||
|
|
||||||
|
pose_pub_ = nh_priv_.advertise<geometry_msgs::PoseWithCovarianceStamped>("pose", 1);
|
||||||
|
|
||||||
|
// TODO: use synchronised subscriber
|
||||||
|
markers_sub_ = nh_.subscribe("markers", 1, &ArucoMap::markersCallback, this);
|
||||||
|
cinfo_sub = nh_.subscribe("camera_info", 1, &ArucoMap::cinfoCallback, this);
|
||||||
|
|
||||||
|
publishMapImage();
|
||||||
|
ROS_INFO("aruco_map: ready");
|
||||||
|
}
|
||||||
|
|
||||||
|
void markersCallback(const aruco_pose::MarkerArray& markers)
|
||||||
|
{
|
||||||
|
if (!has_camera_info_) return;
|
||||||
|
if (markers.markers.empty()) return;
|
||||||
|
|
||||||
|
int count = markers.markers.size();
|
||||||
|
std::vector<int> ids;
|
||||||
|
std::vector<std::vector<cv::Point2f>> corners;
|
||||||
|
ids.reserve(count);
|
||||||
|
corners.reserve(count);
|
||||||
|
|
||||||
|
for(auto const &marker : markers.markers) {
|
||||||
|
ids.push_back(marker.id);
|
||||||
|
std::vector<cv::Point2f> marker_corners = {
|
||||||
|
cv::Point2f(marker.c1.x, marker.c1.y),
|
||||||
|
cv::Point2f(marker.c2.x, marker.c2.y),
|
||||||
|
cv::Point2f(marker.c3.x, marker.c3.y),
|
||||||
|
cv::Point2f(marker.c4.x, marker.c4.y)
|
||||||
|
};
|
||||||
|
corners.push_back(marker_corners);
|
||||||
|
}
|
||||||
|
|
||||||
|
Mat obj_points, img_points;
|
||||||
|
cv::Vec3d rvec, tvec;
|
||||||
|
|
||||||
|
if (snap_orientation_.empty()) {
|
||||||
|
// simple estimation
|
||||||
|
int valid = cv::aruco::estimatePoseBoard(corners, ids, board_, camera_matrix_, dist_coeffs_,
|
||||||
|
rvec, tvec, false);
|
||||||
|
if (!valid) return;
|
||||||
|
|
||||||
|
transform_.header.stamp = markers.header.stamp;
|
||||||
|
transform_.header.frame_id = markers.header.frame_id;
|
||||||
|
pose_.header = transform_.header;
|
||||||
|
fillPose(pose_.pose.pose, rvec, tvec);
|
||||||
|
fillTransform(transform_.transform, rvec, tvec);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// estimation with "snapping"
|
||||||
|
cv::aruco::getBoardObjectAndImagePoints(board_, corners, ids, obj_points, img_points);
|
||||||
|
if (obj_points.empty()) return;
|
||||||
|
|
||||||
|
double center_x = 0, center_y = 0;
|
||||||
|
alignObjPointsToCenter(obj_points, center_x, center_y);
|
||||||
|
|
||||||
|
int res = solvePnP(obj_points, img_points, camera_matrix_, dist_coeffs_, rvec, tvec, false);
|
||||||
|
if (!res) return;
|
||||||
|
|
||||||
|
fillTransform(transform_.transform, rvec, tvec);
|
||||||
|
try {
|
||||||
|
geometry_msgs::TransformStamped snap_to = tf_buffer_.lookupTransform(markers.header.frame_id,
|
||||||
|
snap_orientation_, markers.header.stamp, ros::Duration(0.02));
|
||||||
|
snapOrientation(transform_.transform.rotation, snap_to.transform.rotation);
|
||||||
|
} catch (const tf2::TransformException& e) {
|
||||||
|
ROS_WARN_THROTTLE(1, "aruco_map: can't snap: %s", e.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
geometry_msgs::TransformStamped shift;
|
||||||
|
shift.transform.translation.x = -center_x;
|
||||||
|
shift.transform.translation.y = -center_y;
|
||||||
|
shift.transform.rotation.w = 1;
|
||||||
|
tf2::doTransform(shift, transform_, transform_);
|
||||||
|
|
||||||
|
transform_.header.stamp = markers.header.stamp;
|
||||||
|
transform_.header.frame_id = markers.header.frame_id;
|
||||||
|
pose_.header = transform_.header;
|
||||||
|
transformToPose(transform_.transform, pose_.pose.pose);
|
||||||
|
}
|
||||||
|
|
||||||
|
br_.sendTransform(transform_);
|
||||||
|
pose_pub_.publish(pose_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cinfoCallback(const sensor_msgs::CameraInfoConstPtr& cinfo)
|
||||||
|
{
|
||||||
|
parseCameraInfo(cinfo, camera_matrix_, dist_coeffs_);
|
||||||
|
has_camera_info_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void alignObjPointsToCenter(Mat &obj_points, double ¢er_x, double ¢er_y) const
|
||||||
|
{
|
||||||
|
// Align object points to the center of mass
|
||||||
|
double sum_x = 0;
|
||||||
|
double sum_y = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < obj_points.rows; i++) {
|
||||||
|
sum_x += obj_points.at<float>(i, 0);
|
||||||
|
sum_y += obj_points.at<float>(i, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
center_x = sum_x / obj_points.rows;
|
||||||
|
center_y = sum_y / obj_points.rows;
|
||||||
|
|
||||||
|
for (int i = 0; i < obj_points.rows; i++) {
|
||||||
|
obj_points.at<float>(i, 0) -= center_x;
|
||||||
|
obj_points.at<float>(i, 1) -= center_y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadMap(std::string filename)
|
||||||
|
{
|
||||||
|
std::ifstream f(filename);
|
||||||
|
std::string line;
|
||||||
|
|
||||||
|
if (!f.good()) {
|
||||||
|
ROS_FATAL("aruco_map: %s - %s", strerror(errno), filename.c_str());
|
||||||
|
ros::shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
while (std::getline(f, line)) {
|
||||||
|
int id;
|
||||||
|
double length, x, y, z, yaw, pitch, roll;
|
||||||
|
|
||||||
|
std::istringstream s(line);
|
||||||
|
ROS_INFO("aruco_map: parse line: %s", line.c_str());
|
||||||
|
|
||||||
|
if (!(s >> id >> length >> x >> y >> z >> yaw >> pitch >> roll)) {
|
||||||
|
ROS_ERROR("aruco_map: cannot parse line: %s", line.c_str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
addMarker(id, length, x, y, z, yaw, pitch, roll);
|
||||||
|
}
|
||||||
|
|
||||||
|
ROS_INFO("aruco_map: loading %s complete (%d markers)", filename.c_str(), static_cast<int>(board_->ids.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void createGridBoard()
|
||||||
|
{
|
||||||
|
ROS_INFO("aruco_map: generate gridboard");
|
||||||
|
ROS_WARN("aruco_map: gridboard maps are deprecated");
|
||||||
|
|
||||||
|
int markers_x, markers_y, first_marker;
|
||||||
|
double markers_side, markers_sep_x, markers_sep_y;
|
||||||
|
std::vector<int> marker_ids;
|
||||||
|
nh_priv_.param<int>("markers_x", markers_x, 10);
|
||||||
|
nh_priv_.param<int>("markers_y", markers_y, 10);
|
||||||
|
nh_priv_.param<int>("first_marker", first_marker, 0);
|
||||||
|
|
||||||
|
param(nh_priv_, "markers_side", markers_side);
|
||||||
|
param(nh_priv_, "markers_sep_x", markers_sep_x);
|
||||||
|
param(nh_priv_, "markers_sep_y", markers_sep_y);
|
||||||
|
|
||||||
|
if (nh_priv_.getParam("marker_ids", marker_ids)) {
|
||||||
|
if ((unsigned int)(markers_x * markers_y) != marker_ids.size()) {
|
||||||
|
ROS_FATAL("~marker_ids length should be equal to ~markers_x * ~markers_y");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Fill marker_ids automatically
|
||||||
|
marker_ids.resize(markers_x * markers_y);
|
||||||
|
for (int i = 0; i < markers_x * markers_y; i++)
|
||||||
|
{
|
||||||
|
marker_ids.at(i) = first_marker++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createCustomGridBoard(board_, markers_x, markers_y, markers_side, markers_sep_x, markers_sep_y, marker_ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addMarker(int id, double length, double x, double y, double z,
|
||||||
|
double yaw, double pitch, double roll)
|
||||||
|
{
|
||||||
|
// Create transform
|
||||||
|
geometry_msgs::TransformStamped t;
|
||||||
|
t.transform.translation.x = x;
|
||||||
|
t.transform.translation.y = y;
|
||||||
|
t.transform.translation.z = z;
|
||||||
|
tf::Quaternion q;
|
||||||
|
q.setRPY(roll, pitch, yaw);
|
||||||
|
tf::quaternionTFToMsg(q, t.transform.rotation);
|
||||||
|
|
||||||
|
// TODO: process roll pitch yaw
|
||||||
|
vector<cv::Point3f> obj_points(4);
|
||||||
|
setMarkerObjectPoints(x, y, z, yaw, length, obj_points);
|
||||||
|
board_->ids.push_back(id);
|
||||||
|
board_->objPoints.push_back(obj_points);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMarkerObjectPoints(float x, float y, float z, float yaw, float length,
|
||||||
|
vector<cv::Point3f>& obj_points)
|
||||||
|
{
|
||||||
|
obj_points[0] = cv::Point3f(x - length / 2, y + length / 2, 0);
|
||||||
|
obj_points[1] = obj_points[0] + cv::Point3f(length, 0, 0);
|
||||||
|
obj_points[2] = obj_points[0] + cv::Point3f(length, -length, 0);
|
||||||
|
obj_points[3] = obj_points[0] + cv::Point3f(0, -length, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void publishMapImage()
|
||||||
|
{
|
||||||
|
cv::Mat image;
|
||||||
|
cv_bridge::CvImage msg;
|
||||||
|
cv::aruco::drawPlanarBoard(board_, cv::Size(2000, 2000), image, 50, 1);
|
||||||
|
cv::cvtColor(image, image, CV_GRAY2BGR);
|
||||||
|
msg.encoding = sensor_msgs::image_encodings::BGR8;
|
||||||
|
msg.image = image;
|
||||||
|
img_pub_.publish(msg.toImageMsg());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
PLUGINLIB_EXPORT_CLASS(ArucoMap, nodelet::Nodelet)
|
||||||
@@ -1,350 +0,0 @@
|
|||||||
#include <algorithm>
|
|
||||||
#include <nodelet/nodelet.h>
|
|
||||||
#include <image_transport/image_transport.h>
|
|
||||||
#include <cv_bridge/cv_bridge.h>
|
|
||||||
#include <opencv2/imgproc/imgproc.hpp>
|
|
||||||
#include <pluginlib/class_list_macros.h>
|
|
||||||
#include <geometry_msgs/TransformStamped.h>
|
|
||||||
#include <geometry_msgs/PoseStamped.h>
|
|
||||||
#include <geometry_msgs/PoseWithCovarianceStamped.h>
|
|
||||||
#include <visualization_msgs/MarkerArray.h>
|
|
||||||
#include <tf/transform_datatypes.h>
|
|
||||||
#include <opencv2/calib3d/calib3d.hpp>
|
|
||||||
#include <opencv2/opencv.hpp>
|
|
||||||
#include <opencv2/aruco.hpp>
|
|
||||||
#include <opencv2/aruco/dictionary.hpp>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <tf/transform_broadcaster.h>
|
|
||||||
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
using std::vector;
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
namespace aruco_pose {
|
|
||||||
|
|
||||||
class ArucoPose : public nodelet::Nodelet {
|
|
||||||
tf::TransformBroadcaster br;
|
|
||||||
cv::Ptr<cv::aruco::Dictionary> dictionary;
|
|
||||||
cv::Ptr<cv::aruco::DetectorParameters> parameters;
|
|
||||||
cv::Ptr<cv::aruco::Board> board;
|
|
||||||
std::string frame_id_;
|
|
||||||
image_transport::CameraSubscriber img_sub;
|
|
||||||
image_transport::Publisher img_pub;
|
|
||||||
ros::Publisher marker_pub;
|
|
||||||
ros::Publisher pose_pub;
|
|
||||||
ros::NodeHandle nh_, nh_priv_;
|
|
||||||
|
|
||||||
virtual void onInit();
|
|
||||||
void createBoard();
|
|
||||||
cv::Point3f getObjPointsCenter(cv::Mat objPoints);
|
|
||||||
void detect(const sensor_msgs::ImageConstPtr&, const sensor_msgs::CameraInfoConstPtr&);
|
|
||||||
void parseCameraInfo(const sensor_msgs::CameraInfoConstPtr&, cv::Mat&, cv::Mat&);
|
|
||||||
tf::Transform aruco2tf(cv::Mat rvec, cv::Mat tvec);
|
|
||||||
};
|
|
||||||
|
|
||||||
void ArucoPose::onInit() {
|
|
||||||
ROS_INFO("Initializing aruco_pose");
|
|
||||||
nh_ = getNodeHandle();
|
|
||||||
nh_priv_ = getPrivateNodeHandle();
|
|
||||||
|
|
||||||
nh_priv_.param("frame_id", frame_id_, std::string("aruco_map"));
|
|
||||||
|
|
||||||
dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_1000);
|
|
||||||
parameters = cv::aruco::DetectorParameters::create();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
createBoard();
|
|
||||||
}
|
|
||||||
catch (const std::exception &exc)
|
|
||||||
{
|
|
||||||
std::cerr << exc.what();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
image_transport::ImageTransport it(nh_);
|
|
||||||
img_sub = it.subscribeCamera("image", 1, &ArucoPose::detect, this);
|
|
||||||
|
|
||||||
image_transport::ImageTransport it_priv(nh_priv_);
|
|
||||||
img_pub = it_priv.advertise("debug", 1);
|
|
||||||
|
|
||||||
pose_pub = nh_priv_.advertise<geometry_msgs::PoseStamped>("pose", 1);
|
|
||||||
|
|
||||||
ROS_INFO("aruco_pose nodelet inited");
|
|
||||||
}
|
|
||||||
|
|
||||||
cv::Ptr<cv::aruco::Board> createCustomGridBoard(int markersX, int markersY, float markerLength, float markerSeparationX, float markerSeparationY,
|
|
||||||
const cv::Ptr<cv::aruco::Dictionary> &dictionary, std::vector<int> ids) {
|
|
||||||
|
|
||||||
CV_Assert(markersX > 0 && markersY > 0 && markerLength > 0 && markerSeparationX > 0 && markerSeparationY > 0);
|
|
||||||
|
|
||||||
cv::Ptr<cv::aruco::Board> res = cv::makePtr<cv::aruco::Board>();
|
|
||||||
|
|
||||||
res->dictionary = dictionary;
|
|
||||||
|
|
||||||
size_t totalMarkers = (size_t) markersX * markersY;
|
|
||||||
res->ids = ids;
|
|
||||||
res->objPoints.reserve(totalMarkers);
|
|
||||||
|
|
||||||
// calculate Board objPoints
|
|
||||||
float maxY = (float)markersY * markerLength + (markersY - 1) * markerSeparationY;
|
|
||||||
for(int y = 0; y < markersY; y++) {
|
|
||||||
for(int x = 0; x < markersX; x++) {
|
|
||||||
std::vector< cv::Point3f > corners;
|
|
||||||
corners.resize(4);
|
|
||||||
corners[0] = cv::Point3f(x * (markerLength + markerSeparationX),
|
|
||||||
maxY - y * (markerLength + markerSeparationY), 0);
|
|
||||||
corners[1] = corners[0] + cv::Point3f(markerLength, 0, 0);
|
|
||||||
corners[2] = corners[0] + cv::Point3f(markerLength, -markerLength, 0);
|
|
||||||
corners[3] = corners[0] + cv::Point3f(0, -markerLength, 0);
|
|
||||||
res->objPoints.push_back(corners);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
cv::Ptr<cv::aruco::Board> createCustomBoard(std::map<string, string> markers, const cv::Ptr<cv::aruco::Dictionary> &dictionary) {
|
|
||||||
cv::Ptr<cv::aruco::Board> res = cv::makePtr<cv::aruco::Board>();
|
|
||||||
|
|
||||||
res->dictionary = dictionary;
|
|
||||||
|
|
||||||
size_t total_markers = markers.size();
|
|
||||||
res->ids.reserve(total_markers);
|
|
||||||
res->objPoints.reserve(total_markers);
|
|
||||||
|
|
||||||
// Generate ids and objPoints
|
|
||||||
for(auto const &marker : markers) {
|
|
||||||
res->ids.push_back(std::stoi(marker.first));
|
|
||||||
|
|
||||||
vector<string> parts;
|
|
||||||
parts = strSplit(marker.second, " ");
|
|
||||||
|
|
||||||
float size = std::stof(parts.at(0));
|
|
||||||
float x = std::stof(parts.at(1));
|
|
||||||
float y = std::stof(parts.at(2));
|
|
||||||
float z = std::stof(parts.at(3));
|
|
||||||
float yaw = std::stof(parts.at(4));
|
|
||||||
float pitch = std::stof(parts.at(5));
|
|
||||||
float roll = std::stof(parts.at(6));
|
|
||||||
|
|
||||||
vector<cv::Point3f> corners;
|
|
||||||
corners.resize(4);
|
|
||||||
corners[0] = cv::Point3f(x - size / 2, y + size / 2, 0);
|
|
||||||
corners[1] = corners[0] + cv::Point3f(size, 0, 0);
|
|
||||||
corners[2] = corners[0] + cv::Point3f(size, -size, 0);
|
|
||||||
corners[3] = corners[0] + cv::Point3f(0, -size, 0);
|
|
||||||
|
|
||||||
// TODO: process yaw, pitch, roll
|
|
||||||
|
|
||||||
res->objPoints.push_back(corners);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "fix.cpp"
|
|
||||||
|
|
||||||
void ArucoPose::createBoard()
|
|
||||||
{
|
|
||||||
static auto map_image_pub = nh_priv_.advertise<sensor_msgs::Image>("map_image", 1, true);
|
|
||||||
cv_bridge::CvImage map_image_msg;
|
|
||||||
cv::Mat map_image;
|
|
||||||
|
|
||||||
std::string type;
|
|
||||||
|
|
||||||
nh_priv_.param<std::string>("type", type, "gridboard");
|
|
||||||
if (type == "gridboard")
|
|
||||||
{
|
|
||||||
ROS_INFO("Initialize gridboard");
|
|
||||||
|
|
||||||
int markers_x, markers_y, first_marker;
|
|
||||||
float markers_side, markers_sep_x, markers_sep_y;
|
|
||||||
std::vector<int> marker_ids;
|
|
||||||
nh_priv_.param<int>("markers_x", markers_x, 10);
|
|
||||||
nh_priv_.param<int>("markers_y", markers_y, 10);
|
|
||||||
nh_priv_.param<int>("first_marker", first_marker, 0);
|
|
||||||
|
|
||||||
if (!nh_priv_.getParam("markers_side", markers_side))
|
|
||||||
{
|
|
||||||
ROS_ERROR("gridboard: required parameter ~markers_side is not set.");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!nh_priv_.getParam("markers_sep_x", markers_sep_x))
|
|
||||||
{
|
|
||||||
if (!nh_priv_.getParam("markers_sep", markers_sep_x))
|
|
||||||
{
|
|
||||||
ROS_ERROR("gridboard: ~markers_sep_x or ~markers_sep parameters are required");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!nh_priv_.getParam("markers_sep_y", markers_sep_y))
|
|
||||||
{
|
|
||||||
if (!nh_priv_.getParam("markers_sep", markers_sep_y))
|
|
||||||
{
|
|
||||||
ROS_ERROR("gridboard: ~markers_sep_y or ~markers_sep parameters are required");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nh_priv_.getParam("marker_ids", marker_ids))
|
|
||||||
{
|
|
||||||
if (markers_x * markers_y != marker_ids.size())
|
|
||||||
{
|
|
||||||
ROS_FATAL("~marker_ids length should be equal to ~markers_x * ~markers_y");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Fill marker_ids automatically
|
|
||||||
marker_ids.resize(markers_x * markers_y);
|
|
||||||
for(int i = 0; i < markers_x * markers_y; i++)
|
|
||||||
{
|
|
||||||
marker_ids.at(i) = first_marker++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create grid board
|
|
||||||
board = createCustomGridBoard(markers_x, markers_y, markers_side, markers_sep_x, markers_sep_y, dictionary, marker_ids);
|
|
||||||
|
|
||||||
// Publish map image for debugging
|
|
||||||
_drawPlanarBoard(board, cv::Size(2000, 2000), map_image, 50, 1);
|
|
||||||
|
|
||||||
cv::cvtColor(map_image, map_image, CV_GRAY2BGR);
|
|
||||||
|
|
||||||
map_image_msg.encoding = sensor_msgs::image_encodings::BGR8;
|
|
||||||
map_image_msg.image = map_image;
|
|
||||||
map_image_pub.publish(map_image_msg.toImageMsg());
|
|
||||||
}
|
|
||||||
else if (type == "custom")
|
|
||||||
{
|
|
||||||
ROS_INFO("Initialize a custom board");
|
|
||||||
|
|
||||||
std::map<string, string> markers;
|
|
||||||
nh_priv_.getParam("markers", markers);
|
|
||||||
|
|
||||||
board = createCustomBoard(markers, dictionary);
|
|
||||||
|
|
||||||
ROS_INFO("Draw a custom board");
|
|
||||||
// Publish map image for debugging
|
|
||||||
_drawPlanarBoard(board, cv::Size(2000, 2000), map_image, 50, 1);
|
|
||||||
|
|
||||||
cv::cvtColor(map_image, map_image, CV_GRAY2BGR);
|
|
||||||
|
|
||||||
map_image_msg.encoding = sensor_msgs::image_encodings::BGR8;
|
|
||||||
map_image_msg.image = map_image;
|
|
||||||
map_image_pub.publish(map_image_msg.toImageMsg());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ROS_ERROR("Incorrect map type '%s'", type.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cv::Point3f ArucoPose::getObjPointsCenter(cv::Mat objPoints) {
|
|
||||||
float min_x = std::numeric_limits<float>::max();
|
|
||||||
float max_x = std::numeric_limits<float>::min();
|
|
||||||
float min_y = min_x, max_y = max_x;
|
|
||||||
for (int i = 0; i < objPoints.rows; i++) {
|
|
||||||
max_x = std::max(max_x, objPoints.at<float>(i, 0));
|
|
||||||
max_y = std::max(max_y, objPoints.at<float>(i, 1));
|
|
||||||
min_x = std::min(min_x, objPoints.at<float>(i, 0));
|
|
||||||
min_y = std::min(min_y, objPoints.at<float>(i, 1));
|
|
||||||
}
|
|
||||||
cv::Point3f res((min_x + max_x) / 2, (min_y + max_y) / 2, 0);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArucoPose::detect(const sensor_msgs::ImageConstPtr& msg, const sensor_msgs::CameraInfoConstPtr &cinfo) {
|
|
||||||
cv::Mat image = cv_bridge::toCvShare(msg, "bgr8")->image;
|
|
||||||
|
|
||||||
std::vector<int> markerIds;
|
|
||||||
std::vector<std::vector<cv::Point2f>> markerCorners;
|
|
||||||
std::vector<std::vector<cv::Point2f>> rejectedCandidates;
|
|
||||||
|
|
||||||
cv::aruco::detectMarkers(image, dictionary, markerCorners, markerIds, parameters, rejectedCandidates);
|
|
||||||
|
|
||||||
cv::Mat cameraMatrix(3, 3, CV_64F);
|
|
||||||
cv::Mat distCoeffs(8, 1, CV_64F);
|
|
||||||
parseCameraInfo(cinfo, cameraMatrix, distCoeffs);
|
|
||||||
|
|
||||||
int valid = 0;
|
|
||||||
cv::Mat rvec, tvec, objPoints;
|
|
||||||
|
|
||||||
if (markerIds.size() > 0) {
|
|
||||||
|
|
||||||
valid = _estimatePoseBoard(markerCorners, markerIds, board, cameraMatrix, distCoeffs,
|
|
||||||
rvec, tvec, false, objPoints);
|
|
||||||
|
|
||||||
if (valid) {
|
|
||||||
// Send map transform
|
|
||||||
tf::StampedTransform transform(aruco2tf(rvec, tvec), msg->header.stamp, cinfo->header.frame_id, frame_id_);
|
|
||||||
br.sendTransform(transform);
|
|
||||||
|
|
||||||
// Publish map pose
|
|
||||||
static geometry_msgs::PoseStamped ps;
|
|
||||||
ps.header.frame_id = frame_id_;
|
|
||||||
ps.header.stamp = msg->header.stamp;
|
|
||||||
ps.pose.orientation.w = 1;
|
|
||||||
pose_pub.publish(ps);
|
|
||||||
|
|
||||||
// Send reference point
|
|
||||||
cv::Point3f ref = getObjPointsCenter(objPoints);
|
|
||||||
tf::Vector3 ref_vector3 = tf::Vector3(ref.x, ref.y, ref.z);
|
|
||||||
tf::Quaternion q(0, 0, 0);
|
|
||||||
static tf::StampedTransform ref_transform;
|
|
||||||
ref_transform.stamp_ = msg->header.stamp;
|
|
||||||
ref_transform.frame_id_ = frame_id_;
|
|
||||||
ref_transform.child_frame_id_ = "aruco_map_reference";
|
|
||||||
ref_transform.setOrigin(ref_vector3);
|
|
||||||
ref_transform.setRotation(q);
|
|
||||||
br.sendTransform(ref_transform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (img_pub.getNumSubscribers() > 0)
|
|
||||||
{
|
|
||||||
cv::aruco::drawDetectedMarkers(image, markerCorners, markerIds); // draw markers
|
|
||||||
if (valid)
|
|
||||||
{
|
|
||||||
cv::aruco::drawAxis(image, cameraMatrix, distCoeffs, rvec, tvec, 0.3); // draw board axis
|
|
||||||
}
|
|
||||||
cv_bridge::CvImage out_msg;
|
|
||||||
out_msg.header.frame_id = msg->header.frame_id;
|
|
||||||
out_msg.header.stamp = msg->header.stamp;
|
|
||||||
out_msg.encoding = sensor_msgs::image_encodings::BGR8;
|
|
||||||
out_msg.image = image;
|
|
||||||
img_pub.publish(out_msg.toImageMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArucoPose::parseCameraInfo(const sensor_msgs::CameraInfoConstPtr &cinfo, cv::Mat &cameraMat, cv::Mat &distCoeffs) {
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
|
||||||
for (int j = 0; j < 3; ++j) {
|
|
||||||
cameraMat.at<double>(i, j) = cinfo->K[3 * i + j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int k = 0; k < cinfo->D.size(); k++) {
|
|
||||||
distCoeffs.at<double>(k) = cinfo->D[k];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tf::Transform ArucoPose::aruco2tf(cv::Mat rvec, cv::Mat tvec) {
|
|
||||||
|
|
||||||
cv::Mat rot;
|
|
||||||
cv::Rodrigues(rvec, rot);
|
|
||||||
|
|
||||||
tf::Matrix3x3 tf_rot(rot.at<double>(0,0), rot.at<double>(0,1), rot.at<double>(0,2),
|
|
||||||
rot.at<double>(1,0), rot.at<double>(1,1), rot.at<double>(1,2),
|
|
||||||
rot.at<double>(2,0), rot.at<double>(2,1), rot.at<double>(2,2));
|
|
||||||
tf::Vector3 tf_orig(tvec.at<double>(0,0), tvec.at<double>(1,0), tvec.at<double>(2,0));
|
|
||||||
return tf::Transform(tf_rot, tf_orig);
|
|
||||||
}
|
|
||||||
|
|
||||||
PLUGINLIB_EXPORT_CLASS(ArucoPose, nodelet::Nodelet)
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
using namespace cv;
|
|
||||||
using namespace cv::aruco;
|
|
||||||
|
|
||||||
// Temporal fix!
|
|
||||||
// TODO: remove
|
|
||||||
// fix strange bug in our OpenCV version
|
|
||||||
|
|
||||||
void _getBoardObjectAndImagePoints(const Ptr<aruco::Board> &board, InputArrayOfArrays detectedCorners,
|
|
||||||
InputArray detectedIds, OutputArray objPoints, OutputArray imgPoints) {
|
|
||||||
|
|
||||||
CV_Assert(board->ids.size() == board->objPoints.size());
|
|
||||||
CV_Assert(detectedIds.total() == detectedCorners.total());
|
|
||||||
|
|
||||||
size_t nDetectedMarkers = detectedIds.total();
|
|
||||||
|
|
||||||
std::vector< Point3f > objPnts;
|
|
||||||
objPnts.reserve(nDetectedMarkers);
|
|
||||||
|
|
||||||
std::vector< Point2f > imgPnts;
|
|
||||||
imgPnts.reserve(nDetectedMarkers);
|
|
||||||
|
|
||||||
// look for detected markers that belong to the board and get their information
|
|
||||||
for(unsigned int i = 0; i < nDetectedMarkers; i++) {
|
|
||||||
int currentId = detectedIds.getMat().ptr< int >(0)[i];
|
|
||||||
for(unsigned int j = 0; j < board->ids.size(); j++) {
|
|
||||||
if(currentId == board->ids[j]) {
|
|
||||||
for(int p = 0; p < 4; p++) {
|
|
||||||
objPnts.push_back(board->objPoints[j][p]);
|
|
||||||
imgPnts.push_back(detectedCorners.getMat(i).ptr< Point2f >(0)[p]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create output
|
|
||||||
Mat(objPnts).copyTo(objPoints);
|
|
||||||
Mat(imgPnts).copyTo(imgPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
int _estimatePoseBoard(InputArrayOfArrays _corners, InputArray _ids, const Ptr<aruco::Board> &board,
|
|
||||||
InputArray _cameraMatrix, InputArray _distCoeffs, OutputArray _rvec,
|
|
||||||
OutputArray _tvec, bool useExtrinsicGuess, Mat &objPoints) {
|
|
||||||
|
|
||||||
CV_Assert(_corners.total() == _ids.total());
|
|
||||||
|
|
||||||
// get object and image points for the solvePnP function
|
|
||||||
Mat /*objPoints, */imgPoints;
|
|
||||||
_getBoardObjectAndImagePoints(board, _corners, _ids, objPoints, imgPoints);
|
|
||||||
|
|
||||||
CV_Assert(imgPoints.total() == objPoints.total());
|
|
||||||
|
|
||||||
if(objPoints.total() == 0) // 0 of the detected markers in board
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// std::cout << "objPoints: " << objPoints << std::endl;
|
|
||||||
// std::cout << "imgPoints: " << imgPoints << std::endl;
|
|
||||||
|
|
||||||
solvePnP(objPoints, imgPoints, _cameraMatrix, _distCoeffs, _rvec, _tvec, useExtrinsicGuess);
|
|
||||||
|
|
||||||
// divide by four since all the four corners are concatenated in the array for each marker
|
|
||||||
return (int)objPoints.total() / 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _drawPlanarBoard(Board *_board, Size outSize, OutputArray _img, int marginSize,
|
|
||||||
int borderBits) {
|
|
||||||
|
|
||||||
CV_Assert(outSize.area() > 0);
|
|
||||||
CV_Assert(marginSize >= 0);
|
|
||||||
|
|
||||||
_img.create(outSize, CV_8UC1);
|
|
||||||
Mat out = _img.getMat();
|
|
||||||
out.setTo(Scalar::all(255));
|
|
||||||
out.adjustROI(-marginSize, -marginSize, -marginSize, -marginSize);
|
|
||||||
|
|
||||||
// calculate max and min values in XY plane
|
|
||||||
CV_Assert(_board->objPoints.size() > 0);
|
|
||||||
float minX, maxX, minY, maxY;
|
|
||||||
minX = maxX = _board->objPoints[0][0].x;
|
|
||||||
minY = maxY = _board->objPoints[0][0].y;
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < _board->objPoints.size(); i++) {
|
|
||||||
for(int j = 0; j < 4; j++) {
|
|
||||||
minX = min(minX, _board->objPoints[i][j].x);
|
|
||||||
maxX = max(maxX, _board->objPoints[i][j].x);
|
|
||||||
minY = min(minY, _board->objPoints[i][j].y);
|
|
||||||
maxY = max(maxY, _board->objPoints[i][j].y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float sizeX = maxX - minX;
|
|
||||||
float sizeY = maxY - minY;
|
|
||||||
|
|
||||||
// proportion transformations
|
|
||||||
float xReduction = sizeX / float(out.cols);
|
|
||||||
float yReduction = sizeY / float(out.rows);
|
|
||||||
|
|
||||||
// determine the zone where the markers are placed
|
|
||||||
if(xReduction > yReduction) {
|
|
||||||
int nRows = int(sizeY / xReduction);
|
|
||||||
int rowsMargins = (out.rows - nRows) / 2;
|
|
||||||
out.adjustROI(-rowsMargins, -rowsMargins, 0, 0);
|
|
||||||
} else {
|
|
||||||
int nCols = int(sizeX / yReduction);
|
|
||||||
int colsMargins = (out.cols - nCols) / 2;
|
|
||||||
out.adjustROI(0, 0, -colsMargins, -colsMargins);
|
|
||||||
}
|
|
||||||
|
|
||||||
// now paint each marker
|
|
||||||
Dictionary &dictionary = *(_board->dictionary);
|
|
||||||
Mat marker;
|
|
||||||
Point2f outCorners[3];
|
|
||||||
Point2f inCorners[3];
|
|
||||||
for(unsigned int m = 0; m < _board->objPoints.size(); m++) {
|
|
||||||
// transform corners to markerZone coordinates
|
|
||||||
for(int j = 0; j < 3; j++) {
|
|
||||||
Point2f pf = Point2f(_board->objPoints[m][j].x, _board->objPoints[m][j].y);
|
|
||||||
// move top left to 0, 0
|
|
||||||
pf -= Point2f(minX, minY);
|
|
||||||
pf.x = pf.x / sizeX * float(out.cols);
|
|
||||||
pf.y = (1.0f - pf.y / sizeY) * float(out.rows);
|
|
||||||
outCorners[j] = pf;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get marker
|
|
||||||
Size dst_sz(outCorners[2] - outCorners[0]); // assuming CCW order
|
|
||||||
dst_sz.width = dst_sz.height = std::min(dst_sz.width, dst_sz.height); //marker should be square
|
|
||||||
dictionary.drawMarker(_board->ids[m], dst_sz.width, marker, borderBits);
|
|
||||||
|
|
||||||
if((outCorners[0].y == outCorners[1].y) && (outCorners[1].x == outCorners[2].x)) {
|
|
||||||
// marker is aligned to image axes
|
|
||||||
marker.copyTo(out(Rect(outCorners[0], dst_sz)));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// interpolate tiny marker to marker position in markerZone
|
|
||||||
inCorners[0] = Point2f(-0.5f, -0.5f);
|
|
||||||
inCorners[1] = Point2f(marker.cols - 0.5f, -0.5f);
|
|
||||||
inCorners[2] = Point2f(marker.cols - 0.5f, marker.rows - 0.5f);
|
|
||||||
|
|
||||||
// remove perspective
|
|
||||||
Mat transformation = getAffineTransform(inCorners, outCorners);
|
|
||||||
warpAffine(marker, out, transformation, out.size(), INTER_LINEAR,
|
|
||||||
BORDER_TRANSPARENT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
22
aruco_pose/src/gridboard.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
void createCustomGridBoard(cv::Ptr<cv::aruco::Board>& board, int markersX, int markersY, float markerLength,
|
||||||
|
float markerSeparationX, float markerSeparationY, std::vector<int> ids)
|
||||||
|
{
|
||||||
|
size_t totalMarkers = (size_t) markersX * markersY;
|
||||||
|
board->ids = ids;
|
||||||
|
board->objPoints.reserve(totalMarkers);
|
||||||
|
|
||||||
|
// calculate Board objPoints
|
||||||
|
float maxY = (float)markersY * markerLength + (markersY - 1) * markerSeparationY;
|
||||||
|
for(int y = 0; y < markersY; y++) {
|
||||||
|
for(int x = 0; x < markersX; x++) {
|
||||||
|
std::vector< cv::Point3f > corners;
|
||||||
|
corners.resize(4);
|
||||||
|
corners[0] = cv::Point3f(x * (markerLength + markerSeparationX),
|
||||||
|
maxY - y * (markerLength + markerSeparationY), 0);
|
||||||
|
corners[1] = corners[0] + cv::Point3f(markerLength, 0, 0);
|
||||||
|
corners[2] = corners[0] + cv::Point3f(markerLength, -markerLength, 0);
|
||||||
|
corners[3] = corners[0] + cv::Point3f(0, -markerLength, 0);
|
||||||
|
board->objPoints.push_back(corners);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
std::vector<std::string> strSplit(const std::string& str, const std::string& delim)
|
|
||||||
{
|
|
||||||
std::vector<std::string> tokens;
|
|
||||||
size_t prev = 0, pos = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
pos = str.find(delim, prev);
|
|
||||||
if (pos == std::string::npos) pos = str.length();
|
|
||||||
std::string token = str.substr(prev, pos-prev);
|
|
||||||
if (!token.empty()) tokens.push_back(token);
|
|
||||||
prev = pos + delim.length();
|
|
||||||
}
|
|
||||||
while (pos < str.length() && prev < str.length());
|
|
||||||
return tokens;
|
|
||||||
}
|
|
||||||
109
aruco_pose/src/utils.h
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <ros/ros.h>
|
||||||
|
#include <tf/transform_datatypes.h>
|
||||||
|
#include <geometry_msgs/Quaternion.h>
|
||||||
|
#include <geometry_msgs/Pose.h>
|
||||||
|
#include <geometry_msgs/Vector3.h>
|
||||||
|
#include <sensor_msgs/CameraInfo.h>
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
|
||||||
|
// Read required param or shutdown the node
|
||||||
|
template<typename T>
|
||||||
|
static void param(ros::NodeHandle nh, const std::string& param_name, T& param_val)
|
||||||
|
{
|
||||||
|
if (!nh.getParam(param_name, param_val)) {
|
||||||
|
ROS_FATAL("Required param %s is not defined", param_name.c_str());
|
||||||
|
ros::shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void parseCameraInfo(const sensor_msgs::CameraInfoConstPtr& cinfo,
|
||||||
|
cv::Mat& matrix, cv::Mat& dist)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < 3; ++i)
|
||||||
|
for (unsigned int j = 0; j < 3; ++j)
|
||||||
|
matrix.at<double>(i, j) = cinfo->K[3 * i + j];
|
||||||
|
|
||||||
|
for (unsigned int k = 0; k < cinfo->D.size(); k++)
|
||||||
|
dist.at<double>(k) = cinfo->D[k];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void rotatePoint(cv::Point3f& p, cv::Point3f origin, float angle)
|
||||||
|
{
|
||||||
|
float s = sin(angle);
|
||||||
|
float c = cos(angle);
|
||||||
|
|
||||||
|
// translate point back to origin:
|
||||||
|
p.x -= origin.x;
|
||||||
|
p.y -= origin.y;
|
||||||
|
|
||||||
|
// rotate point
|
||||||
|
float xnew = p.x * c - p.y * s;
|
||||||
|
float ynew = p.x * s + p.y * c;
|
||||||
|
|
||||||
|
// translate point back:
|
||||||
|
p.x = xnew + origin.x;
|
||||||
|
p.y = ynew + origin.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void fillPose(geometry_msgs::Pose& pose, const cv::Vec3d& rvec, const cv::Vec3d& tvec)
|
||||||
|
{
|
||||||
|
pose.position.x = tvec[0];
|
||||||
|
pose.position.y = tvec[1];
|
||||||
|
pose.position.z = tvec[2];
|
||||||
|
|
||||||
|
double angle = norm(rvec);
|
||||||
|
cv::Vec3d axis = rvec / angle;
|
||||||
|
|
||||||
|
tf2::Quaternion q;
|
||||||
|
q.setRotation(tf2::Vector3(axis[0], axis[1], axis[2]), angle);
|
||||||
|
|
||||||
|
pose.orientation.w = q.w();
|
||||||
|
pose.orientation.x = q.x();
|
||||||
|
pose.orientation.y = q.y();
|
||||||
|
pose.orientation.z = q.z();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void fillTransform(geometry_msgs::Transform& transform, const cv::Vec3d& rvec, const cv::Vec3d& tvec)
|
||||||
|
{
|
||||||
|
transform.translation.x = tvec[0];
|
||||||
|
transform.translation.y = tvec[1];
|
||||||
|
transform.translation.z = tvec[2];
|
||||||
|
|
||||||
|
double angle = norm(rvec);
|
||||||
|
cv::Vec3d axis = rvec / angle;
|
||||||
|
|
||||||
|
tf2::Quaternion q;
|
||||||
|
q.setRotation(tf2::Vector3(axis[0], axis[1], axis[2]), angle);
|
||||||
|
|
||||||
|
transform.rotation.w = q.w();
|
||||||
|
transform.rotation.x = q.x();
|
||||||
|
transform.rotation.y = q.y();
|
||||||
|
transform.rotation.z = q.z();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void fillTranslation(geometry_msgs::Vector3& translation, const cv::Vec3d& tvec)
|
||||||
|
{
|
||||||
|
translation.x = tvec[0];
|
||||||
|
translation.y = tvec[1];
|
||||||
|
translation.z = tvec[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void snapOrientation(geometry_msgs::Quaternion& to, const geometry_msgs::Quaternion& from)
|
||||||
|
{
|
||||||
|
tf::Quaternion q;
|
||||||
|
q.setRPY(0, 0, -tf::getYaw(to) + tf::getYaw(from));
|
||||||
|
tf::Quaternion pq;
|
||||||
|
tf::quaternionMsgToTF(from, pq);
|
||||||
|
pq = pq * q;
|
||||||
|
tf::quaternionTFToMsg(pq, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void transformToPose(const geometry_msgs::Transform& transform, geometry_msgs::Pose& pose)
|
||||||
|
{
|
||||||
|
pose.position.x = transform.translation.x;
|
||||||
|
pose.position.y = transform.translation.y;
|
||||||
|
pose.position.z = transform.translation.z;
|
||||||
|
pose.orientation = transform.rotation;
|
||||||
|
}
|
||||||
6
builder/assets/butterfly.service
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Butterfly Terminal Server
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/local/bin/butterfly.server.py --host="0.0.0.0" --unsecure
|
||||||
|
User=pi
|
||||||
5
builder/assets/butterfly.socket
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[Socket]
|
||||||
|
ListenStream=57575
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=sockets.target
|
||||||
@@ -4,7 +4,7 @@ Requires=roscore.service
|
|||||||
After=roscore.service
|
After=roscore.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
EnvironmentFile=/home/pi/catkin_ws/src/clever/deploy/roscore.env
|
EnvironmentFile=/lib/systemd/system/roscore.env
|
||||||
ExecStart=/opt/ros/kinetic/bin/roslaunch clever clever.launch --wait
|
ExecStart=/opt/ros/kinetic/bin/roslaunch clever clever.launch --wait
|
||||||
Restart=on-abort
|
Restart=on-abort
|
||||||
|
|
||||||
78
builder/assets/hardware_setup.sh
Executable file
@@ -0,0 +1,78 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Script for build the image. Used builder script of the target repo
|
||||||
|
# For build: docker run --privileged -it --rm -v /dev:/dev -v $(pwd):/builder/repo smirart/builder
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Copter Express Technologies
|
||||||
|
#
|
||||||
|
# Author: Artem Smirnov <urpylka@gmail.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # Exit immidiately on non-zero result
|
||||||
|
|
||||||
|
echo_stamp() {
|
||||||
|
# TEMPLATE: echo_stamp <TEXT> <TYPE>
|
||||||
|
# TYPE: SUCCESS, ERROR, INFO
|
||||||
|
|
||||||
|
# More info there https://www.shellhacks.com/ru/bash-colors/
|
||||||
|
|
||||||
|
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
|
||||||
|
TEXT="\e[1m$TEXT\e[0m" # BOLD
|
||||||
|
|
||||||
|
case "$2" in
|
||||||
|
SUCCESS)
|
||||||
|
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
|
||||||
|
ERROR)
|
||||||
|
TEXT="\e[31m${TEXT}\e[0m";; # RED
|
||||||
|
*)
|
||||||
|
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
|
||||||
|
esac
|
||||||
|
echo -e ${TEXT}
|
||||||
|
}
|
||||||
|
|
||||||
|
##################################################
|
||||||
|
# Configure hardware interfaces
|
||||||
|
##################################################
|
||||||
|
|
||||||
|
# 1. Enable sshd
|
||||||
|
echo_stamp "#1 Turn on sshd"
|
||||||
|
touch /boot/ssh
|
||||||
|
# /usr/bin/raspi-config nonint do_ssh 0
|
||||||
|
|
||||||
|
# 2. Enable GPIO
|
||||||
|
echo_stamp "#2 GPIO enabled by default"
|
||||||
|
|
||||||
|
# 3. Enable I2C
|
||||||
|
echo_stamp "#3 Turn on I2C"
|
||||||
|
/usr/bin/raspi-config nonint do_i2c 0
|
||||||
|
|
||||||
|
# 4. Enable SPI
|
||||||
|
echo_stamp "#4 Turn on SPI"
|
||||||
|
/usr/bin/raspi-config nonint do_spi 0
|
||||||
|
|
||||||
|
# 5. Enable raspicam
|
||||||
|
echo_stamp "#5 Turn on raspicam"
|
||||||
|
/usr/bin/raspi-config nonint do_camera 0
|
||||||
|
|
||||||
|
# 6. Enable hardware UART
|
||||||
|
echo_stamp "#6 Turn on UART"
|
||||||
|
# Temporary solution
|
||||||
|
# https://github.com/RPi-Distro/raspi-config/pull/75
|
||||||
|
/usr/bin/raspi-config nonint do_serial 1
|
||||||
|
/usr/bin/raspi-config nonint set_config_var enable_uart 1 /boot/config.txt
|
||||||
|
/usr/bin/raspi-config nonint set_config_var dtoverlay pi3-disable-bt /boot/config.txt
|
||||||
|
systemctl disable hciuart.service
|
||||||
|
|
||||||
|
# After adding to Raspbian OS
|
||||||
|
# https://github.com/RPi-Distro/raspi-config/commit/d6d9ecc0d9cbe4aaa9744ae733b9cb239e79c116
|
||||||
|
#/usr/bin/raspi-config nonint do_serial 2
|
||||||
|
|
||||||
|
# 7. Enable V4L driver http://robocraft.ru/blog/electronics/3158.html
|
||||||
|
#echo "bcm2835-v4l2" >> /etc/modules
|
||||||
|
echo_stamp "#7 Turn on v4l2 driver"
|
||||||
|
if ! grep -q "^bcm2835-v4l2" /etc/modules;
|
||||||
|
then printf "bcm2835-v4l2\n" >> /etc/modules
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo_stamp "#8 End of configure hardware interfaces"
|
||||||
13
builder/assets/index.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<h1>CLEVER Drone Kit Tools</h1>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<!-- <li><a href="">View user reference</a> (<a href="http://clever.copterexpress.com">http://clever.copterexpress.com</a> snapshot)</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> -->
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
document.querySelector("#wvs").href = location.origin + ':8080';
|
||||||
|
document.querySelector("#butterfly").href = location.origin + ':57575';
|
||||||
|
</script>
|
||||||
43
builder/assets/init_rpi.sh
Executable file
@@ -0,0 +1,43 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Script for build the image. Used builder script of the target repo
|
||||||
|
# For build: docker run --privileged -it --rm -v /dev:/dev -v $(pwd):/builder/repo smirart/builder
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Copter Express Technologies
|
||||||
|
#
|
||||||
|
# Author: Artem Smirnov <urpylka@gmail.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # Exit immidiately on non-zero result
|
||||||
|
|
||||||
|
echo_stamp() {
|
||||||
|
# TEMPLATE: echo_stamp <TEXT> <TYPE>
|
||||||
|
# TYPE: SUCCESS, ERROR, INFO
|
||||||
|
|
||||||
|
# More info there https://www.shellhacks.com/ru/bash-colors/
|
||||||
|
|
||||||
|
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
|
||||||
|
TEXT="\e[1m$TEXT\e[0m" # BOLD
|
||||||
|
|
||||||
|
case "$2" in
|
||||||
|
SUCCESS)
|
||||||
|
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
|
||||||
|
ERROR)
|
||||||
|
TEXT="\e[31m${TEXT}\e[0m";; # RED
|
||||||
|
*)
|
||||||
|
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
|
||||||
|
esac
|
||||||
|
echo -e ${TEXT}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_stamp "Rename SSID"
|
||||||
|
sudo sed -i.OLD "s/CLEVER/CLEVER-$(head -c 100 /dev/urandom | xxd -ps -c 100 | sed -e 's/[^0-9]//g' | cut -c 1-4)/g" /etc/wpa_supplicant/wpa_supplicant.conf
|
||||||
|
|
||||||
|
echo_stamp "Harware setup"
|
||||||
|
/root/hardware_setup.sh
|
||||||
|
|
||||||
|
echo_stamp "Remove init scripts"
|
||||||
|
rm /root/init_rpi.sh /root/hardware_setup.sh
|
||||||
|
|
||||||
|
echo_stamp "End of initialization of the image"
|
||||||
@@ -418,10 +418,6 @@
|
|||||||
local-name: nodelet_core/nodelet
|
local-name: nodelet_core/nodelet
|
||||||
uri: https://github.com/ros-gbp/nodelet_core-release/archive/release/kinetic/nodelet/1.9.14-0.tar.gz
|
uri: https://github.com/ros-gbp/nodelet_core-release/archive/release/kinetic/nodelet/1.9.14-0.tar.gz
|
||||||
version: nodelet_core-release-release-kinetic-nodelet-1.9.14-0
|
version: nodelet_core-release-release-kinetic-nodelet-1.9.14-0
|
||||||
- tar:
|
|
||||||
local-name: opencv3
|
|
||||||
uri: https://github.com/ros-gbp/opencv3-release/archive/release/kinetic/opencv3/3.3.1-5.tar.gz
|
|
||||||
version: opencv3-release-release-kinetic-opencv3-3.3.1-5
|
|
||||||
- tar:
|
- tar:
|
||||||
local-name: orocos_kinematics_dynamics/orocos_kdl
|
local-name: orocos_kinematics_dynamics/orocos_kdl
|
||||||
uri: https://github.com/smits/orocos-kdl-release/archive/release/kinetic/orocos_kdl/1.3.1-0.tar.gz
|
uri: https://github.com/smits/orocos-kdl-release/archive/release/kinetic/orocos_kdl/1.3.1-0.tar.gz
|
||||||
@@ -676,5 +672,5 @@
|
|||||||
version: vision_opencv-release-release-kinetic-cv_bridge-1.12.8-0
|
version: vision_opencv-release-release-kinetic-cv_bridge-1.12.8-0
|
||||||
- tar:
|
- tar:
|
||||||
local-name: web_video_server
|
local-name: web_video_server
|
||||||
uri: https://github.com/RobotWebTools-release/web_video_server-release/archive/release/kinetic/web_video_server/0.0.7-0.tar.gz
|
uri: https://github.com/RobotWebTools-release/web_video_server-release/archive/release/kinetic/web_video_server/0.1.0-0.tar.gz
|
||||||
version: web_video_server-release-release-kinetic-web_video_server-0.0.7-0
|
version: web_video_server-release-release-kinetic-web_video_server-0.1.0-0
|
||||||
528
builder/assets/kinetic-rosdep-clever.yaml
Normal file
@@ -0,0 +1,528 @@
|
|||||||
|
actionlib:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-actionlib]
|
||||||
|
actionlib_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-actionlib-msgs]
|
||||||
|
angles:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-angles]
|
||||||
|
async_web_server_cpp:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-async-web-server-cpp]
|
||||||
|
bond:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-bond]
|
||||||
|
bondcpp:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-bondcpp]
|
||||||
|
bondpy:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-bondpy]
|
||||||
|
camera_calibration_parsers:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-camera-calibration-parsers]
|
||||||
|
camera_info_manager:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-camera-info-manager]
|
||||||
|
catkin:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-catkin]
|
||||||
|
class_loader:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-class-loader]
|
||||||
|
cmake_modules:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-cmake-modules]
|
||||||
|
cpp_common:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-cpp-common]
|
||||||
|
cv_bridge:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-cv-bridge]
|
||||||
|
cv_camera:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-cv-camera=0.3.1-0stretch]
|
||||||
|
diagnostic_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-diagnostic-msgs]
|
||||||
|
diagnostic_updater:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-diagnostic-updater]
|
||||||
|
eigen_conversions:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-eigen-conversions]
|
||||||
|
gencpp:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-gencpp]
|
||||||
|
geneus:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-geneus]
|
||||||
|
genlisp:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-genlisp]
|
||||||
|
genmsg:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-genmsg]
|
||||||
|
gennodejs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-gennodejs]
|
||||||
|
genpy:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-genpy]
|
||||||
|
geographic_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-geographic-msgs]
|
||||||
|
geometry_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-geometry-msgs]
|
||||||
|
image_transport:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-image-transport]
|
||||||
|
libmavconn:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-libmavconn]
|
||||||
|
lxml:
|
||||||
|
debian:
|
||||||
|
stretch: [python-lxml=3.7.1-1]
|
||||||
|
mavlink:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-mavlink]
|
||||||
|
mavros:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-mavros]
|
||||||
|
mavros_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-mavros-msgs]
|
||||||
|
mavros_extras:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-mavros-extras]
|
||||||
|
message_filters:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-message-filters]
|
||||||
|
message_generation:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-message-generation]
|
||||||
|
message_runtime:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-message-runtime]
|
||||||
|
mjpg-streamer:
|
||||||
|
debian:
|
||||||
|
stretch: [mjpg-streamer=2.0]
|
||||||
|
mk:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-mk]
|
||||||
|
nav_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-nav-msgs]
|
||||||
|
nodelet:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-nodelet]
|
||||||
|
opencv3:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-opencv3]
|
||||||
|
orocos_kdl:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-orocos-kdl]
|
||||||
|
pluginlib:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-pluginlib]
|
||||||
|
python_orocos_kdl:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-python-orocos-kdl]
|
||||||
|
ros:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-ros]
|
||||||
|
ros_comm:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-ros-comm]
|
||||||
|
ros_environment:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-ros-environment]
|
||||||
|
rosapi:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosapi]
|
||||||
|
rosauth:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosauth]
|
||||||
|
rosbag:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosbag]
|
||||||
|
rosbag_migration_rule:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosbag-migration-rule]
|
||||||
|
rosbag_storage:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosbag-storage]
|
||||||
|
rosbash:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosbash]
|
||||||
|
rosboost_cfg:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosboost-cfg]
|
||||||
|
rosbridge_library:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosbridge-library]
|
||||||
|
rosbridge_server:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosbridge-server]
|
||||||
|
rosbuild:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosbuild]
|
||||||
|
rosclean:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosclean]
|
||||||
|
rosconsole:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosconsole]
|
||||||
|
rosconsole_bridge:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosconsole-bridge]
|
||||||
|
roscpp:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-roscpp]
|
||||||
|
roscpp_serialization:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-roscpp-serialization]
|
||||||
|
roscpp_traits:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-roscpp-traits]
|
||||||
|
roscreate:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-roscreate]
|
||||||
|
rosgraph:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosgraph]
|
||||||
|
rosgraph_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosgraph-msgs]
|
||||||
|
roslang:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-roslang]
|
||||||
|
roslaunch:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-roslaunch]
|
||||||
|
roslib:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-roslib]
|
||||||
|
roslint:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-roslint]
|
||||||
|
roslisp:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-roslisp]
|
||||||
|
roslz4:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-roslz4]
|
||||||
|
rosmake:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosmake]
|
||||||
|
rosmaster:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosmaster]
|
||||||
|
rosmsg:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosmsg]
|
||||||
|
rosnode:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosnode]
|
||||||
|
rosout:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosout]
|
||||||
|
rospack:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rospack]
|
||||||
|
rosparam:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosparam]
|
||||||
|
rospy:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rospy]
|
||||||
|
rospy_tutorials:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rospy-tutorials]
|
||||||
|
rosserial_client:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosserial-client]
|
||||||
|
rosserial_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosserial-msgs]
|
||||||
|
rosserial_python:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosserial-python]
|
||||||
|
rosservice:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosservice]
|
||||||
|
rostest:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rostest]
|
||||||
|
rostime:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rostime]
|
||||||
|
rostopic:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rostopic]
|
||||||
|
rosunit:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-rosunit]
|
||||||
|
roswtf:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-roswtf]
|
||||||
|
sensor_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-sensor-msgs]
|
||||||
|
smclib:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-smclib]
|
||||||
|
std_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-std-msgs]
|
||||||
|
std_srvs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-std-srvs]
|
||||||
|
stereo_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-stereo-msgs]
|
||||||
|
tf2:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-tf2]
|
||||||
|
tf2_bullet:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-tf2-bullet]
|
||||||
|
tf2_eigen:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-tf2-eigen]
|
||||||
|
tf2_geometry_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-tf2-geometry-msgs]
|
||||||
|
tf2_kdl:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-tf2-kdl]
|
||||||
|
tf2_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-tf2-msgs]
|
||||||
|
tf2_py:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-tf2-py]
|
||||||
|
tf2_ros:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-tf2-ros]
|
||||||
|
tf2_sensor_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-tf2-sensor-msgs]
|
||||||
|
tf2_tools:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-tf2-tools]
|
||||||
|
tf:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-tf]
|
||||||
|
topic_tools:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-topic-tools]
|
||||||
|
trajectory_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-trajectory-msgs]
|
||||||
|
urdf:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-urdf]
|
||||||
|
urdf_parser_plugin:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-urdf-parser-plugin]
|
||||||
|
uuid_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-uuid-msgs]
|
||||||
|
visualization_msgs:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-visualization-msgs]
|
||||||
|
xmlrpcpp:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-xmlrpcpp]
|
||||||
|
boost:
|
||||||
|
debian:
|
||||||
|
stretch: [libboost-all-dev]
|
||||||
|
bullet:
|
||||||
|
debian:
|
||||||
|
stretch: [libbullet-dev]
|
||||||
|
bzip2:
|
||||||
|
debian:
|
||||||
|
stretch: [libbz2-dev]
|
||||||
|
cmake:
|
||||||
|
debian:
|
||||||
|
stretch: [cmake]
|
||||||
|
cppunit:
|
||||||
|
debian:
|
||||||
|
stretch: [libcppunit-dev]
|
||||||
|
eigen:
|
||||||
|
debian:
|
||||||
|
stretch: [libeigen3-dev]
|
||||||
|
geographiclib-tools:
|
||||||
|
debian:
|
||||||
|
stretch: [geographiclib-tools]
|
||||||
|
geographiclib:
|
||||||
|
debian:
|
||||||
|
stretch: [libgeographic-dev]
|
||||||
|
google-mock:
|
||||||
|
debian:
|
||||||
|
stretch: [google-mock]
|
||||||
|
graphviz:
|
||||||
|
debian:
|
||||||
|
stretch: [graphviz]
|
||||||
|
gtest:
|
||||||
|
debian:
|
||||||
|
stretch: [libgtest-dev]
|
||||||
|
libconsole-bridge-dev:
|
||||||
|
debian:
|
||||||
|
stretch: [libconsole-bridge-dev]
|
||||||
|
libjpeg:
|
||||||
|
debian:
|
||||||
|
stretch: [libjpeg-dev]
|
||||||
|
libpng-dev:
|
||||||
|
debian:
|
||||||
|
stretch: [libpng-dev]
|
||||||
|
libpoco-dev:
|
||||||
|
debian:
|
||||||
|
stretch: [libpoco-dev]
|
||||||
|
libssl-dev:
|
||||||
|
debian:
|
||||||
|
stretch: [libssl-dev]
|
||||||
|
libtiff-dev:
|
||||||
|
debian:
|
||||||
|
stretch: [libtiff5-dev]
|
||||||
|
liburdfdom-dev:
|
||||||
|
debian:
|
||||||
|
stretch: [liburdfdom-dev]
|
||||||
|
liburdfdom-headers-dev:
|
||||||
|
debian:
|
||||||
|
stretch: [liburdfdom-headers-dev]
|
||||||
|
libv4l-dev:
|
||||||
|
debian:
|
||||||
|
stretch: [libv4l-dev]
|
||||||
|
libvtk-qt:
|
||||||
|
debian:
|
||||||
|
stretch: [libvtk6-qt-dev]
|
||||||
|
libwebp-dev:
|
||||||
|
debian:
|
||||||
|
stretch: [libwebp-dev]
|
||||||
|
log4cxx:
|
||||||
|
debian:
|
||||||
|
stretch: [liblog4cxx-dev]
|
||||||
|
lz4:
|
||||||
|
debian:
|
||||||
|
stretch: [liblz4-dev]
|
||||||
|
pkg-config:
|
||||||
|
debian:
|
||||||
|
stretch: [pkg-config]
|
||||||
|
protobuf:
|
||||||
|
debian:
|
||||||
|
stretch: [libprotobuf10]
|
||||||
|
python-bson:
|
||||||
|
debian:
|
||||||
|
stretch: [python-bson]
|
||||||
|
python-catkin-pkg:
|
||||||
|
debian:
|
||||||
|
stretch: [python-catkin-pkg]
|
||||||
|
python-coverage:
|
||||||
|
debian:
|
||||||
|
stretch: [python-coverage]
|
||||||
|
python-defusedxml:
|
||||||
|
debian:
|
||||||
|
stretch: [python-defusedxml]
|
||||||
|
python-empy:
|
||||||
|
debian:
|
||||||
|
stretch: [python-empy]
|
||||||
|
python-future:
|
||||||
|
debian:
|
||||||
|
stretch: [python-future]
|
||||||
|
python-imaging:
|
||||||
|
debian:
|
||||||
|
stretch: [python-imaging]
|
||||||
|
python-lxml:
|
||||||
|
debian:
|
||||||
|
stretch: [python-lxml]
|
||||||
|
python-mock:
|
||||||
|
debian:
|
||||||
|
stretch: [python-mock]
|
||||||
|
python-netifaces:
|
||||||
|
debian:
|
||||||
|
stretch: [python-netifaces]
|
||||||
|
python-nose:
|
||||||
|
debian:
|
||||||
|
stretch: [python-nose]
|
||||||
|
python-numpy:
|
||||||
|
debian:
|
||||||
|
stretch: [python-numpy]
|
||||||
|
python-paramiko:
|
||||||
|
debian:
|
||||||
|
stretch: [python-paramiko]
|
||||||
|
python-rosdep:
|
||||||
|
debian:
|
||||||
|
stretch: [python-rosdep]
|
||||||
|
python-rospkg:
|
||||||
|
debian:
|
||||||
|
stretch: [python-rospkg]
|
||||||
|
python-serial:
|
||||||
|
debian:
|
||||||
|
stretch: [python-serial]
|
||||||
|
python-setuptools:
|
||||||
|
debian:
|
||||||
|
stretch: [python-setuptools]
|
||||||
|
python-sip:
|
||||||
|
debian:
|
||||||
|
stretch: [python-sip-dev]
|
||||||
|
python-tornado:
|
||||||
|
debian:
|
||||||
|
stretch: [python-tornado]
|
||||||
|
python-twisted-core:
|
||||||
|
debian:
|
||||||
|
stretch: [python-twisted-core]
|
||||||
|
python-websocket:
|
||||||
|
debian:
|
||||||
|
stretch: [python-websocket]
|
||||||
|
python-wxtools:
|
||||||
|
debian:
|
||||||
|
stretch: [python-wxtools]
|
||||||
|
python-yaml:
|
||||||
|
debian:
|
||||||
|
stretch: [python-yaml]
|
||||||
|
python:
|
||||||
|
debian:
|
||||||
|
stretch: [python-dev]
|
||||||
|
sbcl:
|
||||||
|
debian:
|
||||||
|
stretch: [sbcl]
|
||||||
|
tinyxml2:
|
||||||
|
debian:
|
||||||
|
stretch: [libtinyxml2-dev]
|
||||||
|
tinyxml:
|
||||||
|
debian:
|
||||||
|
stretch: [libtinyxml-dev]
|
||||||
|
uuid:
|
||||||
|
debian:
|
||||||
|
stretch: [uuid-dev]
|
||||||
|
web_video_server:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-web-video-server]
|
||||||
|
v4l-utils:
|
||||||
|
debian:
|
||||||
|
stretch: [v4l-utils]
|
||||||
|
yaml-cpp:
|
||||||
|
debian:
|
||||||
|
stretch: [libyaml-cpp-dev]
|
||||||
|
zlib:
|
||||||
|
debian:
|
||||||
|
stretch: [zlib1g-dev]
|
||||||
|
compressed_depth_image_transport:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-compressed-depth-image-transport]
|
||||||
|
compressed_image_transport:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-compressed-image-transport]
|
||||||
|
dynamic_reconfigure:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-dynamic-reconfigure]
|
||||||
|
theora_image_transport:
|
||||||
|
debian:
|
||||||
|
stretch: [ros-kinetic-theora-image-transport]
|
||||||
|
libogg:
|
||||||
|
debian:
|
||||||
|
stretch: [libtheora0=1.1.1+dfsg.1-14]
|
||||||
57
builder/assets/monkey-clever
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# Default Host - Configuration
|
||||||
|
# ============================
|
||||||
|
# Here the variable principals of the program are defined in respect
|
||||||
|
# to the configuration of the different types of directives.
|
||||||
|
|
||||||
|
[HOST]
|
||||||
|
# ServerName:
|
||||||
|
# -----------
|
||||||
|
# Allow you to set a host and domain name (e.g monkey.linuxchile.cl). If
|
||||||
|
# you are working in a local network just set your IP address or if you
|
||||||
|
# are working like localhost set your loopback address (127.0.0.1).
|
||||||
|
|
||||||
|
ServerName 0.0.0.0
|
||||||
|
|
||||||
|
# DocumentRoot:
|
||||||
|
# -------------
|
||||||
|
# This variable corresponds to the location of the main server directory
|
||||||
|
# of the web pages, where the files of your site are located.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# DocumentRoot /home/krypton/htdocs
|
||||||
|
|
||||||
|
DocumentRoot /usr/share/monkey-static
|
||||||
|
|
||||||
|
# Redirect:
|
||||||
|
# ---------
|
||||||
|
# Under specific conditions, you may want the server performs a HTTP
|
||||||
|
# redirect when this Virtual Host is reach. If that is the case, append
|
||||||
|
# to the Redirect key the value of the address where to redirect the
|
||||||
|
# HTTP client.
|
||||||
|
#
|
||||||
|
# Redirect http://monkey-project.com
|
||||||
|
|
||||||
|
[LOGGER]
|
||||||
|
# AccessLog:
|
||||||
|
# ----------
|
||||||
|
# Registration file of correct request.
|
||||||
|
|
||||||
|
AccessLog /var/log/monkey-clever/access.log
|
||||||
|
|
||||||
|
# ErrorLog:
|
||||||
|
# ---------
|
||||||
|
# Registration file of incorrect request.
|
||||||
|
|
||||||
|
ErrorLog /var/log/monkey-clever/error.log
|
||||||
|
|
||||||
|
[ERROR_PAGES]
|
||||||
|
404 404.html
|
||||||
|
|
||||||
|
[HANDLERS]
|
||||||
|
# FastCGI
|
||||||
|
# =======
|
||||||
|
# Match /.*\.php fastcgi
|
||||||
|
|
||||||
|
# CGI
|
||||||
|
# ===
|
||||||
|
# Match /cgi-bin/.*\.cgi cgi
|
||||||
9
builder/assets/monkey.service
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Monkey web-server
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/sbin/monkey --port 80 --workers 1
|
||||||
|
Restart=on-abort
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -3,7 +3,7 @@ Description=Launcher for the ROS master, parameter server and rosout logging nod
|
|||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
EnvironmentFile=/home/pi/catkin_ws/src/clever/deploy/roscore.env
|
EnvironmentFile=/lib/systemd/system/roscore.env
|
||||||
ExecStart=/opt/ros/kinetic/bin/roscore
|
ExecStart=/opt/ros/kinetic/bin/roscore
|
||||||
Restart=on-abort
|
Restart=on-abort
|
||||||
|
|
||||||
106
builder/image-build.sh
Executable file
@@ -0,0 +1,106 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Script for build the image. Used builder script of the target repo
|
||||||
|
# For build: docker run --privileged -it --rm -v /dev:/dev -v $(pwd):/builder/repo smirart/builder
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Copter Express Technologies
|
||||||
|
#
|
||||||
|
# Author: Artem Smirnov <urpylka@gmail.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # Exit immidiately on non-zero result
|
||||||
|
|
||||||
|
SOURCE_IMAGE="http://repo.coex.space/2018-06-27-raspbian-stretch-lite.zip"
|
||||||
|
|
||||||
|
export DEBIAN_FRONTEND=${DEBIAN_FRONTEND:='noninteractive'}
|
||||||
|
export LANG=${LANG:='C.UTF-8'}
|
||||||
|
export LC_ALL=${LC_ALL:='C.UTF-8'}
|
||||||
|
|
||||||
|
echo_stamp() {
|
||||||
|
# TEMPLATE: echo_stamp <TEXT> <TYPE>
|
||||||
|
# TYPE: SUCCESS, ERROR, INFO
|
||||||
|
|
||||||
|
# More info there https://www.shellhacks.com/ru/bash-colors/
|
||||||
|
|
||||||
|
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
|
||||||
|
TEXT="\e[1m$TEXT\e[0m" # BOLD
|
||||||
|
|
||||||
|
case "$2" in
|
||||||
|
SUCCESS)
|
||||||
|
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
|
||||||
|
ERROR)
|
||||||
|
TEXT="\e[31m${TEXT}\e[0m";; # RED
|
||||||
|
*)
|
||||||
|
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
|
||||||
|
esac
|
||||||
|
echo -e ${TEXT}
|
||||||
|
}
|
||||||
|
|
||||||
|
BUILDER_DIR="/builder"
|
||||||
|
REPO_DIR="${BUILDER_DIR}/repo"
|
||||||
|
SCRIPTS_DIR="${REPO_DIR}/builder"
|
||||||
|
IMAGES_DIR="${REPO_DIR}/images"
|
||||||
|
|
||||||
|
[[ ! -d ${SCRIPTS_DIR} ]] && (echo_stamp "Directory ${SCRIPTS_DIR} doesn't exist" "ERROR"; exit 1)
|
||||||
|
[[ ! -d ${IMAGES_DIR} ]] && mkdir ${IMAGES_DIR} && echo_stamp "Directory ${IMAGES_DIR} was created successful" "SUCCESS"
|
||||||
|
|
||||||
|
if [[ -z ${TRAVIS_TAG} ]]; then IMAGE_VERSION="$(cd ${REPO_DIR}; git log --format=%h -1)"; else IMAGE_VERSION="${TRAVIS_TAG}"; fi
|
||||||
|
# IMAGE_VERSION="${TRAVIS_TAG:=$(cd ${REPO_DIR}; git log --format=%h -1)}"
|
||||||
|
REPO_URL="$(cd ${REPO_DIR}; git remote --verbose | grep origin | grep fetch | cut -f2 | cut -d' ' -f1 | sed 's/git@github\.com\:/https\:\/\/github.com\//')"
|
||||||
|
REPO_NAME="$(basename -s '.git' ${REPO_URL})"
|
||||||
|
IMAGE_NAME="${REPO_NAME}_${IMAGE_VERSION}.img"
|
||||||
|
IMAGE_PATH="${IMAGES_DIR}/${IMAGE_NAME}"
|
||||||
|
|
||||||
|
get_image() {
|
||||||
|
# TEMPLATE: get_image <IMAGE_PATH> <RPI_DONWLOAD_URL>
|
||||||
|
local BUILD_DIR=$(dirname $1)
|
||||||
|
local RPI_ZIP_NAME=$(basename $2)
|
||||||
|
local RPI_IMAGE_NAME=$(echo ${RPI_ZIP_NAME} | sed 's/zip/img/')
|
||||||
|
|
||||||
|
if [ ! -e "${BUILD_DIR}/${RPI_ZIP_NAME}" ]; then
|
||||||
|
echo_stamp "Downloading original Linux distribution" \
|
||||||
|
&& wget -nv -O ${BUILD_DIR}/${RPI_ZIP_NAME} $2 \
|
||||||
|
&& echo_stamp "Downloading complete" "SUCCESS" \
|
||||||
|
|| (echo_stamp "Downloading was failed!" "ERROR"; exit 1)
|
||||||
|
else echo_stamp "Linux distribution already donwloaded"; fi
|
||||||
|
|
||||||
|
echo_stamp "Unzipping Linux distribution image" \
|
||||||
|
&& unzip -p ${BUILD_DIR}/${RPI_ZIP_NAME} ${RPI_IMAGE_NAME} > $1 \
|
||||||
|
&& echo_stamp "Unzipping complete" "SUCCESS" \
|
||||||
|
|| (echo_stamp "Unzipping was failed!" "ERROR"; exit 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
get_image ${IMAGE_PATH} ${SOURCE_IMAGE}
|
||||||
|
|
||||||
|
# Make free space
|
||||||
|
${BUILDER_DIR}/image-resize.sh ${IMAGE_PATH} max '7G'
|
||||||
|
|
||||||
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/init_rpi.sh' '/root/'
|
||||||
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/hardware_setup.sh' '/root/'
|
||||||
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-init.sh' ${IMAGE_VERSION} ${SOURCE_IMAGE}
|
||||||
|
|
||||||
|
# Monkey
|
||||||
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/monkey-clever' '/root/'
|
||||||
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/index.html' '/usr/share/monkey-static/'
|
||||||
|
|
||||||
|
# Butterfly
|
||||||
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/butterfly.service' '/lib/systemd/system/'
|
||||||
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/butterfly.socket' '/lib/systemd/system/'
|
||||||
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/monkey.service' '/lib/systemd/system/'
|
||||||
|
# software install
|
||||||
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-software.sh'
|
||||||
|
# network setup
|
||||||
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-network.sh'
|
||||||
|
|
||||||
|
# If RPi then use a one thread to build a ROS package on RPi, else use all
|
||||||
|
[[ $(arch) == 'armv7l' ]] && NUMBER_THREADS=1 || NUMBER_THREADS=$(nproc --all)
|
||||||
|
# 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.env' '/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/kinetic-ros-clever.rosinstall' '/home/pi/ros_catkin_ws/'
|
||||||
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-ros.sh' ${REPO_URL} ${IMAGE_VERSION} false false ${NUMBER_THREADS}
|
||||||
|
|
||||||
|
${BUILDER_DIR}/image-resize.sh ${IMAGE_PATH}
|
||||||
54
builder/image-init.sh
Executable file
@@ -0,0 +1,54 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Script for initialisation image
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Copter Express Technologies
|
||||||
|
#
|
||||||
|
# Author: Artem Smirnov <urpylka@gmail.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # Exit immidiately on non-zero result
|
||||||
|
|
||||||
|
echo_stamp() {
|
||||||
|
# TEMPLATE: echo_stamp <TEXT> <TYPE>
|
||||||
|
# TYPE: SUCCESS, ERROR, INFO
|
||||||
|
|
||||||
|
# More info there https://www.shellhacks.com/ru/bash-colors/
|
||||||
|
|
||||||
|
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
|
||||||
|
TEXT="\e[1m$TEXT\e[0m" # BOLD
|
||||||
|
|
||||||
|
case "$2" in
|
||||||
|
SUCCESS)
|
||||||
|
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
|
||||||
|
ERROR)
|
||||||
|
TEXT="\e[31m${TEXT}\e[0m";; # RED
|
||||||
|
*)
|
||||||
|
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
|
||||||
|
esac
|
||||||
|
echo -e ${TEXT}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_stamp "Write CLEVER information"
|
||||||
|
|
||||||
|
# Clever image version
|
||||||
|
echo "$1" >> /etc/clever_version
|
||||||
|
# Origin image file name
|
||||||
|
echo "${2%.*}" >> /etc/clever_origin
|
||||||
|
|
||||||
|
echo_stamp "Write magic script to /etc/rc.local"
|
||||||
|
MAGIC_SCRIPT="sudo /root/init_rpi.sh; sudo sed -i '/sudo \\\/root\\\/init_rpi.sh/d' /etc/rc.local && sudo reboot"
|
||||||
|
sed -i "19a${MAGIC_SCRIPT}" /etc/rc.local
|
||||||
|
|
||||||
|
# It needs for autosizer.sh & maybe that is correct
|
||||||
|
echo_stamp "Change boot partition"
|
||||||
|
sed -i 's/root=[^ ]*/root=\/dev\/mmcblk0p2/' /boot/cmdline.txt
|
||||||
|
sed -i 's/.* \/boot vfat defaults 0 2$/\/dev\/mmcblk0p1 \/boot vfat defaults 0 2/' /etc/fstab
|
||||||
|
sed -i 's/.* \/ ext4 defaults,noatime 0 1$/\/dev\/mmcblk0p2 \/ ext4 defaults,noatime 0 1/' /etc/fstab
|
||||||
|
|
||||||
|
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 "End of init image"
|
||||||
73
builder/image-network.sh
Executable file
@@ -0,0 +1,73 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Script for network configure
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Copter Express Technologies
|
||||||
|
#
|
||||||
|
# Author: Artem Smirnov <urpylka@gmail.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # Exit immidiately on non-zero result
|
||||||
|
|
||||||
|
echo_stamp() {
|
||||||
|
# TEMPLATE: echo_stamp <TEXT> <TYPE>
|
||||||
|
# TYPE: SUCCESS, ERROR, INFO
|
||||||
|
|
||||||
|
# More info there https://www.shellhacks.com/ru/bash-colors/
|
||||||
|
|
||||||
|
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
|
||||||
|
TEXT="\e[1m$TEXT\e[0m" # BOLD
|
||||||
|
|
||||||
|
case "$2" in
|
||||||
|
SUCCESS)
|
||||||
|
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
|
||||||
|
ERROR)
|
||||||
|
TEXT="\e[31m${TEXT}\e[0m";; # RED
|
||||||
|
*)
|
||||||
|
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
|
||||||
|
esac
|
||||||
|
echo -e ${TEXT}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_stamp "#1 Write to /etc/wpa_supplicant/wpa_supplicant.conf"
|
||||||
|
|
||||||
|
# TODO: Use wpa_cli insted direct file edit
|
||||||
|
cat << EOF >> /etc/wpa_supplicant/wpa_supplicant.conf
|
||||||
|
network={
|
||||||
|
ssid="CLEVER"
|
||||||
|
psk="cleverwifi"
|
||||||
|
mode=2
|
||||||
|
proto=RSN
|
||||||
|
key_mgmt=WPA-PSK
|
||||||
|
pairwise=CCMP
|
||||||
|
group=CCMP
|
||||||
|
auth_alg=OPEN
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo_stamp "#2 Write STATIC to /etc/dhcpcd.conf"
|
||||||
|
|
||||||
|
cat << EOF >> /etc/dhcpcd.conf
|
||||||
|
interface wlan0
|
||||||
|
static ip_address=192.168.11.1/24
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo_stamp "#3 Write dhcp-config to /etc/dnsmasq.conf"
|
||||||
|
|
||||||
|
cat << EOF >> /etc/dnsmasq.conf
|
||||||
|
interface=wlan0
|
||||||
|
address=/clever/coex/192.168.11.1
|
||||||
|
dhcp-range=192.168.11.100,192.168.11.200,12h
|
||||||
|
no-hosts
|
||||||
|
filterwin2k
|
||||||
|
bogus-priv
|
||||||
|
domain-needed
|
||||||
|
quiet-dhcp6
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#echo_stamp "#4 Write magic script for rename SSID to /etc/rc.local"
|
||||||
|
#RENAME_SSID="sudo sed -i.OLD \"s/CLEVER/CLEVER-\$(head -c 100 /dev/urandom | xxd -ps -c 100 | sed -e 's/[^0-9]//g' | cut -c 1-4)/g\" /etc/wpa_supplicant/wpa_supplicant.conf && sudo sed -i '/sudo sed/d' /etc/rc.local && sudo reboot"
|
||||||
|
#sed -i "19a$RENAME_SSID" /etc/rc.local
|
||||||
|
|
||||||
|
echo_stamp "#5 End of network installation"
|
||||||
176
builder/image-ros.sh
Executable file
@@ -0,0 +1,176 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Script for build the image. Used builder script of the target repo
|
||||||
|
# For build: docker run --privileged -it --rm -v /dev:/dev -v $(pwd):/builder/repo smirart/builder
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Copter Express Technologies
|
||||||
|
#
|
||||||
|
# Author: Artem Smirnov <urpylka@gmail.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # Exit immidiately on non-zero result
|
||||||
|
|
||||||
|
REPO=$1
|
||||||
|
REF=$2
|
||||||
|
INSTALL_ROS_PACK_SOURCES=$3
|
||||||
|
DISCOVER_ROS_PACK=$4
|
||||||
|
NUMBER_THREADS=$5
|
||||||
|
|
||||||
|
echo_stamp() {
|
||||||
|
# TEMPLATE: echo_stamp <TEXT> <TYPE>
|
||||||
|
# TYPE: SUCCESS, ERROR, INFO
|
||||||
|
|
||||||
|
# More info there https://www.shellhacks.com/ru/bash-colors/
|
||||||
|
|
||||||
|
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
|
||||||
|
TEXT="\e[1m$TEXT\e[0m" # BOLD
|
||||||
|
|
||||||
|
case "$2" in
|
||||||
|
SUCCESS)
|
||||||
|
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
|
||||||
|
ERROR)
|
||||||
|
TEXT="\e[31m${TEXT}\e[0m";; # RED
|
||||||
|
*)
|
||||||
|
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
|
||||||
|
esac
|
||||||
|
echo -e ${TEXT}
|
||||||
|
}
|
||||||
|
|
||||||
|
# https://gist.github.com/letmaik/caa0f6cc4375cbfcc1ff26bd4530c2a3
|
||||||
|
# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh
|
||||||
|
my_travis_retry() {
|
||||||
|
local result=0
|
||||||
|
local count=1
|
||||||
|
while [ $count -le 3 ]; do
|
||||||
|
[ $result -ne 0 ] && {
|
||||||
|
echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2
|
||||||
|
}
|
||||||
|
# ! { } ignores set -e, see https://stackoverflow.com/a/4073372
|
||||||
|
! { "$@"; result=$?; }
|
||||||
|
[ $result -eq 0 ] && break
|
||||||
|
count=$(($count + 1))
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
[ $count -gt 3 ] && {
|
||||||
|
echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO: 'kinetic-rosdep-clever.yaml' should add only if we use our repo?
|
||||||
|
echo_stamp "Init rosdep" \
|
||||||
|
&& rosdep init \
|
||||||
|
&& echo "yaml file:///etc/ros/rosdep/kinetic-rosdep-clever.yaml" >> /etc/ros/rosdep/sources.list.d/20-default.list \
|
||||||
|
&& rosdep update
|
||||||
|
|
||||||
|
resolve_rosdep() {
|
||||||
|
# TEMPLATE: resolve_rosdep <CATKIN_PATH> <ROS_DISTRO> <OS_DISTRO> <OS_VERSION>
|
||||||
|
CATKIN_PATH=$1
|
||||||
|
ROS_DISTRO='kinetic'
|
||||||
|
OS_DISTRO='debian'
|
||||||
|
OS_VERSION='stretch'
|
||||||
|
|
||||||
|
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} -r --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 \
|
||||||
|
--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
|
||||||
|
|
||||||
|
echo_stamp "Installing CLEVER" \
|
||||||
|
&& git clone ${REPO} /home/pi/catkin_ws/src/clever \
|
||||||
|
&& cd /home/pi/catkin_ws/src/clever \
|
||||||
|
&& echo "REF: ${REF}" \
|
||||||
|
&& git checkout ${REF} \
|
||||||
|
&& cd /home/pi/catkin_ws \
|
||||||
|
&& 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 \
|
||||||
|
&& catkin_make -j${NUMBER_THREADS} -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
&& systemctl enable roscore \
|
||||||
|
&& systemctl enable clever \
|
||||||
|
&& echo_stamp "All CLEVER was installed!" "SUCCESS" \
|
||||||
|
|| (echo_stamp "CLEVER installation was failed!" "ERROR"; exit 1)
|
||||||
|
|
||||||
|
# TODO move GeographicLib datasets to Mavros debian package
|
||||||
|
echo_stamp "Install GeographicLib datasets (needs for mavros)" \
|
||||||
|
&& wget -qO- https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh | bash
|
||||||
|
|
||||||
|
echo_stamp "Change permissions for catkin_ws"
|
||||||
|
chown -Rf pi:pi /home/pi/catkin_ws
|
||||||
|
|
||||||
|
echo_stamp "Setup ROS environment"
|
||||||
|
cat << EOF >> /home/pi/.bashrc
|
||||||
|
LANG='C.UTF-8'
|
||||||
|
LC_ALL='C.UTF-8'
|
||||||
|
ROS_DISTRO='kinetic'
|
||||||
|
export ROS_IP='192.168.11.1'
|
||||||
|
source /opt/ros/kinetic/setup.bash
|
||||||
|
source /home/pi/catkin_ws/devel/setup.bash
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#echo_stamp "Removing local apt mirror"
|
||||||
|
# Restore original sources.list
|
||||||
|
#mv /var/sources.list.bak /etc/apt/sources.list
|
||||||
|
# Clean apt cache
|
||||||
|
apt-get clean -qq > /dev/null
|
||||||
|
# Remove local mirror repository key
|
||||||
|
#apt-key del COEX-MIRROR
|
||||||
|
|
||||||
|
echo_stamp "END of ROS INSTALLATION"
|
||||||
130
builder/image-software.sh
Executable file
@@ -0,0 +1,130 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Script for install software to the image.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Copter Express Technologies
|
||||||
|
#
|
||||||
|
# Author: Artem Smirnov <urpylka@gmail.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # Exit immidiately on non-zero result
|
||||||
|
|
||||||
|
echo_stamp() {
|
||||||
|
# TEMPLATE: echo_stamp <TEXT> <TYPE>
|
||||||
|
# TYPE: SUCCESS, ERROR, INFO
|
||||||
|
|
||||||
|
# More info there https://www.shellhacks.com/ru/bash-colors/
|
||||||
|
|
||||||
|
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
|
||||||
|
TEXT="\e[1m${TEXT}\e[0m" # BOLD
|
||||||
|
|
||||||
|
case "$2" in
|
||||||
|
SUCCESS)
|
||||||
|
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
|
||||||
|
ERROR)
|
||||||
|
TEXT="\e[31m${TEXT}\e[0m";; # RED
|
||||||
|
*)
|
||||||
|
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
|
||||||
|
esac
|
||||||
|
echo -e ${TEXT}
|
||||||
|
}
|
||||||
|
|
||||||
|
# https://gist.github.com/letmaik/caa0f6cc4375cbfcc1ff26bd4530c2a3
|
||||||
|
# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh
|
||||||
|
my_travis_retry() {
|
||||||
|
local result=0
|
||||||
|
local count=1
|
||||||
|
while [ $count -le 3 ]; do
|
||||||
|
[ $result -ne 0 ] && {
|
||||||
|
echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2
|
||||||
|
}
|
||||||
|
# ! { } ignores set -e, see https://stackoverflow.com/a/4073372
|
||||||
|
! { "$@"; result=$?; }
|
||||||
|
[ $result -eq 0 ] && break
|
||||||
|
count=$(($count + 1))
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
[ $count -gt 3 ] && {
|
||||||
|
echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_stamp "Install apt keys & repos"
|
||||||
|
|
||||||
|
# TODO: This STDOUT consist 'OK'
|
||||||
|
curl http://repo.coex.space/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~deb9u2 > /dev/null \
|
||||||
|
&& apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
|
||||||
|
|
||||||
|
echo "deb http://packages.ros.org/ros/ubuntu stretch main" > /etc/apt/sources.list.d/ros-latest.list
|
||||||
|
echo "deb http://repo.coex.space/rpi-ros-kinetic stretch main" > /etc/apt/sources.list.d/rpi-ros-kinetic.list
|
||||||
|
echo "deb http://repo.coex.space/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 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 \
|
||||||
|
git \
|
||||||
|
dnsmasq=2.76-5+rpt1+deb9u1 \
|
||||||
|
tmux=2.3-4 \
|
||||||
|
vim=2:8.0.0197-4+deb9u1 \
|
||||||
|
cmake=3.7.2-1 \
|
||||||
|
python-pip=9.0.1-2+rpt2 \
|
||||||
|
python3-pip=9.0.1-2+rpt2 \
|
||||||
|
libjpeg8-dev=8d1-2 \
|
||||||
|
tcpdump \
|
||||||
|
ltrace \
|
||||||
|
libpoco-dev=1.7.6+dfsg1-5+deb9u1 \
|
||||||
|
python-rosdep=0.12.2-1 \
|
||||||
|
python-rosinstall-generator=0.1.14-1 \
|
||||||
|
python-wstool=0.1.17-1 \
|
||||||
|
python-rosinstall=0.7.8-1 \
|
||||||
|
build-essential=12.3 \
|
||||||
|
libffi-dev \
|
||||||
|
monkey=1.6.9-1 \
|
||||||
|
&& echo_stamp "Everything was installed!" "SUCCESS" \
|
||||||
|
|| (echo_stamp "Some packages wasn't installed!" "ERROR"; exit 1)
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
echo_stamp "Upgrade pip"
|
||||||
|
my_travis_retry pip install --upgrade pip
|
||||||
|
my_travis_retry pip3 install --upgrade pip3
|
||||||
|
|
||||||
|
echo_stamp "Install and enable Butterfly (web terminal)"
|
||||||
|
my_travis_retry pip3 install butterfly
|
||||||
|
my_travis_retry pip3 install butterfly[systemd]
|
||||||
|
systemctl enable butterfly.socket
|
||||||
|
|
||||||
|
echo_stamp "Setup Monkey"
|
||||||
|
mv /etc/monkey/sites/default /etc/monkey/sites/default.orig
|
||||||
|
mv /root/monkey-clever /etc/monkey/sites/default
|
||||||
|
systemctl enable monkey.service
|
||||||
|
|
||||||
|
echo_stamp "Add .vimrc"
|
||||||
|
cat << EOF > /home/pi/.vimrc
|
||||||
|
set mouse-=a
|
||||||
|
syntax on
|
||||||
|
autocmd BufNewFile,BufRead *.launch set syntax=xml
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo_stamp "End of software installation"
|
||||||
@@ -21,6 +21,9 @@ find_package(catkin REQUIRED COMPONENTS
|
|||||||
tf
|
tf
|
||||||
tf2
|
tf2
|
||||||
tf2_geometry_msgs
|
tf2_geometry_msgs
|
||||||
|
tf2_ros
|
||||||
|
image_transport
|
||||||
|
cv_bridge
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -121,7 +124,7 @@ generate_messages(
|
|||||||
## DEPENDS: system dependencies of this project that dependent projects also need
|
## DEPENDS: system dependencies of this project that dependent projects also need
|
||||||
catkin_package(
|
catkin_package(
|
||||||
# INCLUDE_DIRS include
|
# INCLUDE_DIRS include
|
||||||
# LIBRARIES clever
|
LIBRARIES clever
|
||||||
# CATKIN_DEPENDS other_catkin_pkg
|
# CATKIN_DEPENDS other_catkin_pkg
|
||||||
# DEPENDS system_lib
|
# DEPENDS system_lib
|
||||||
)
|
)
|
||||||
@@ -137,7 +140,11 @@ include_directories(
|
|||||||
${catkin_INCLUDE_DIRS}
|
${catkin_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
## Declare a C++ library
|
# Declare a C++ library
|
||||||
|
add_library(clever
|
||||||
|
src/optical_flow.cpp
|
||||||
|
)
|
||||||
|
|
||||||
add_library(fcu_horiz
|
add_library(fcu_horiz
|
||||||
src/fcu_horiz.cpp
|
src/fcu_horiz.cpp
|
||||||
)
|
)
|
||||||
@@ -156,8 +163,20 @@ add_library(aruco_vpe
|
|||||||
## The recommended prefix ensures that target names across packages don't collide
|
## The recommended prefix ensures that target names across packages don't collide
|
||||||
add_executable(rc src/rc.cpp)
|
add_executable(rc src/rc.cpp)
|
||||||
|
|
||||||
|
add_executable(camera_markers src/camera_markers.cpp)
|
||||||
|
|
||||||
|
add_executable(frames src/frames.cpp)
|
||||||
|
|
||||||
|
add_executable(vpe_publisher src/vpe_publisher.cpp)
|
||||||
|
|
||||||
target_link_libraries(rc ${catkin_LIBRARIES})
|
target_link_libraries(rc ${catkin_LIBRARIES})
|
||||||
|
|
||||||
|
target_link_libraries(camera_markers ${catkin_LIBRARIES})
|
||||||
|
|
||||||
|
target_link_libraries(frames ${catkin_LIBRARIES})
|
||||||
|
|
||||||
|
target_link_libraries(vpe_publisher ${catkin_LIBRARIES})
|
||||||
|
|
||||||
## Rename C++ executable without prefix
|
## Rename C++ executable without prefix
|
||||||
## The above recommended prefix causes long target names, the following renames the
|
## The above recommended prefix causes long target names, the following renames the
|
||||||
## target back to the shorter version for ease of user use
|
## target back to the shorter version for ease of user use
|
||||||
@@ -169,6 +188,10 @@ target_link_libraries(rc ${catkin_LIBRARIES})
|
|||||||
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||||
|
|
||||||
## Specify libraries to link a library or executable target against
|
## Specify libraries to link a library or executable target against
|
||||||
|
target_link_libraries(clever
|
||||||
|
${catkin_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(fcu_horiz
|
target_link_libraries(fcu_horiz
|
||||||
${catkin_LIBRARIES}
|
${catkin_LIBRARIES}
|
||||||
"/opt/ros/kinetic/lib/libtf2_ros.so"
|
"/opt/ros/kinetic/lib/libtf2_ros.so"
|
||||||
|
|||||||
@@ -1,24 +1,35 @@
|
|||||||
<launch>
|
<launch>
|
||||||
<remap from="image" to="main_camera/image_raw"/>
|
<arg name="aruco_detect" default="true"/>
|
||||||
<remap from="camera_info" to="main_camera/camera_info"/>
|
<arg name="aruco_map" default="false"/>
|
||||||
|
<arg name="aruco_vpe" default="false"/>
|
||||||
|
|
||||||
<node pkg="nodelet" type="nodelet" name="aruco_pose" args="load aruco_pose/aruco_pose nodelet_manager" clear_params="true">
|
<!-- detect aruco markers, estimate poses -->
|
||||||
<param name="frame_id" value="aruco_map_raw"/>
|
<node pkg="nodelet" if="$(arg aruco_detect)" clear_params="true" type="nodelet" name="aruco_detect" args="load aruco_pose/aruco_detect nodelet_manager" output="screen">
|
||||||
<param name="type" value="gridboard"/>
|
<remap from="image_raw" to="main_camera/image_raw"/>
|
||||||
<param name="markers_x" value="1"/>
|
<remap from="camera_info" to="main_camera/camera_info"/>
|
||||||
<param name="markers_y" value="6"/>
|
|
||||||
<param name="first_marker" value="240"/>
|
|
||||||
<param name="markers_side" value="0.3362"/>
|
|
||||||
<param name="markers_sep" value="0.46"/>
|
|
||||||
|
|
||||||
<!-- Custom gridboard: -->
|
<param name="length" value="0.32"/>
|
||||||
<!--<rosparam param="marker_ids">[6, 5, 4, 3, 2, 1]</rosparam>-->
|
<param name="snap_orientation" value="local_origin"/>
|
||||||
|
<param name="estimate_poses" value="true"/>
|
||||||
</node>
|
</node>
|
||||||
|
|
||||||
<node pkg="nodelet" type="nodelet" name="aruco_vpe" args="load clever/aruco_vpe nodelet_manager" clear_params="true">
|
<!-- estimate aruco map pose -->
|
||||||
<param name="aruco_orientation" value="local_origin"/>
|
<node pkg="nodelet" clear_params="true" type="nodelet" name="aruco_map" if="$(arg aruco_map)" args="load aruco_pose/aruco_map nodelet_manager" output="screen">
|
||||||
<!--<param name="aruco_orientation" value="local_origin_upside_down"/>-->
|
<remap from="markers" to="aruco_detect/markers"/>
|
||||||
|
<remap from="camera_info" to="main_camera/camera_info"/>
|
||||||
|
<param name="type" value="map"/>
|
||||||
|
<param name="map" value="$(find aruco_pose)/map/map.txt"/>
|
||||||
|
<param name="snap_orientation" value="local_origin"/>
|
||||||
|
</node>
|
||||||
|
|
||||||
<param name="use_mocap" value="true"/>
|
<!-- vpe publisher from aruco markers -->
|
||||||
|
<node name="vpe_publisher" pkg="clever" type="vpe_publisher" output="screen" if="$(arg aruco_vpe)">
|
||||||
|
<!-- <remap from="~markers" to="aruco_detect/markers"/> -->
|
||||||
|
<!-- <remap from="~pose_pub" to="mavros/mocap/pose"/> --> <!-- publish MOCAP -->
|
||||||
|
<remap from="~pose_cov" to="aruco_map/pose"/>
|
||||||
|
<remap from="~pose_pub" to="mavros/vision_pose/pose"/> <!-- publish VPE -->
|
||||||
|
<param name="frame_id" value="aruco_map"/>
|
||||||
|
<param name="child_frame_id" value="fcu"/>
|
||||||
|
<param name="publish_zero" value="true"/>
|
||||||
</node>
|
</node>
|
||||||
</launch>
|
</launch>
|
||||||
|
|||||||
@@ -2,46 +2,50 @@
|
|||||||
<arg name="fcu_conn" default="usb"/>
|
<arg name="fcu_conn" default="usb"/>
|
||||||
<arg name="fcu_ip" default="127.0.0.1"/>
|
<arg name="fcu_ip" default="127.0.0.1"/>
|
||||||
<arg name="gcs_bridge" default="tcp"/>
|
<arg name="gcs_bridge" default="tcp"/>
|
||||||
<arg name="viz" default="true"/>
|
|
||||||
<arg name="web_server" default="false"/>
|
|
||||||
<arg name="web_video_server" default="true"/>
|
<arg name="web_video_server" default="true"/>
|
||||||
<arg name="rosbridge" default="true"/>
|
<arg name="rosbridge" default="true"/>
|
||||||
<arg name="main_camera" default="true"/>
|
<arg name="main_camera" default="true"/>
|
||||||
|
<arg name="optical_flow" default="false"/>
|
||||||
<arg name="aruco" default="false"/>
|
<arg name="aruco" default="false"/>
|
||||||
<arg name="rc" value="true"/>
|
<arg name="rc" default="true"/>
|
||||||
<arg name="fpv_camera" default="false"/>
|
|
||||||
<arg name="fpv_camera_device" default="/dev/v4l/by-id/usb-HD_Camera_Manufacturer_USB_2.0_Camera-video-index0"/>
|
|
||||||
<arg name="arduino" default="false"/>
|
<arg name="arduino" default="false"/>
|
||||||
|
<arg name="vl53l1x" default="false"/>
|
||||||
|
|
||||||
<!-- mavros -->
|
<!-- mavros -->
|
||||||
<include file="$(find clever)/launch/mavros.launch">
|
<include file="$(find clever)/launch/mavros.launch">
|
||||||
<arg name="fcu_conn" value="$(arg fcu_conn)"/>
|
<arg name="fcu_conn" value="$(arg fcu_conn)"/>
|
||||||
<arg name="fcu_ip" value="$(arg fcu_ip)"/>
|
<arg name="fcu_ip" value="$(arg fcu_ip)"/>
|
||||||
<arg name="gcs_bridge" value="$(arg gcs_bridge)"/>
|
<arg name="gcs_bridge" value="$(arg gcs_bridge)"/>
|
||||||
<arg name="viz" value="$(arg viz)"/>
|
<arg name="viz" value="true"/>
|
||||||
</include>
|
</include>
|
||||||
|
|
||||||
<!-- web server -->
|
|
||||||
<include file="$(find clever)/launch/web_server.launch" if="$(arg web_server)"/>
|
|
||||||
|
|
||||||
<!-- web video server -->
|
<!-- web video server -->
|
||||||
<node name="web_video_server" pkg="web_video_server" type="web_video_server" if="$(arg web_video_server)" required="false" respawn="true" respawn_delay="5"/>
|
<node name="web_video_server" pkg="web_video_server" type="web_video_server" if="$(arg web_video_server)" required="false" respawn="true" respawn_delay="5"/>
|
||||||
|
|
||||||
<!-- aruco vpe -->
|
<!-- aruco -->
|
||||||
<include file="$(find clever)/launch/aruco.launch" if="$(arg aruco)"/>
|
<include file="$(find clever)/launch/aruco.launch" if="$(arg aruco)"/>
|
||||||
|
|
||||||
|
<!-- optical flow -->
|
||||||
|
<node pkg="nodelet" type="nodelet" name="optical_flow" args="load clever/optical_flow nodelet_manager" if="$(arg optical_flow)" clear_params="true">
|
||||||
|
<remap from="image" to="main_camera/image_raw"/>
|
||||||
|
<remap from="camera_info" to="main_camera/camera_info"/>
|
||||||
|
</node>
|
||||||
|
|
||||||
<!-- main nodelet manager -->
|
<!-- main nodelet manager -->
|
||||||
<node pkg="nodelet" type="nodelet" name="nodelet_manager" args="manager" output="screen" clear_params="true">
|
<node pkg="nodelet" type="nodelet" name="nodelet_manager" args="manager" output="screen" clear_params="true">
|
||||||
<param name="num_worker_threads" value="2"/>
|
<param name="num_worker_threads" value="4"/>
|
||||||
</node>
|
</node>
|
||||||
|
|
||||||
<node pkg="tf2_ros" type="static_transform_publisher" name="local_origin_upside_down_frame" args="0 0 0 3.1415926 3.1415926 0 local_origin local_origin_upside_down"/>
|
<node pkg="tf2_ros" type="static_transform_publisher" name="local_origin_upside_down_frame" args="0 0 0 3.1415926 3.1415926 0 local_origin local_origin_upside_down"/>
|
||||||
|
|
||||||
<!-- fcu_horiz frame -->
|
|
||||||
<node pkg="nodelet" type="nodelet" name="fcu_horiz" args="standalone clever/fcu_horiz" output="screen" clear_params="true"/>
|
|
||||||
|
|
||||||
<!-- simplified offboard control -->
|
<!-- simplified offboard control -->
|
||||||
<node name="simple_offboard" pkg="clever" type="simple_offboard.py" output="screen"/>
|
<node name="simple_offboard" pkg="clever" type="simple_offboard.py" output="screen"/>
|
||||||
|
<!-- Auxiliary frames -->
|
||||||
|
<node name="frames" pkg="clever" type="frames" output="screen">
|
||||||
|
<param name="body/frame_id" value="fcu_horiz"/>
|
||||||
|
</node>
|
||||||
|
|
||||||
|
|
||||||
<!-- main camera -->
|
<!-- main camera -->
|
||||||
<include file="$(find clever)/launch/main_camera.launch" if="$(arg main_camera)"/>
|
<include file="$(find clever)/launch/main_camera.launch" if="$(arg main_camera)"/>
|
||||||
@@ -49,14 +53,15 @@
|
|||||||
<!-- rosbridge -->
|
<!-- rosbridge -->
|
||||||
<include file="$(find rosbridge_server)/launch/rosbridge_websocket.launch" if="$(eval rosbridge or rc)"/>
|
<include file="$(find rosbridge_server)/launch/rosbridge_websocket.launch" if="$(eval rosbridge or rc)"/>
|
||||||
|
|
||||||
|
<!-- vl53l1x ToF rangefinder -->
|
||||||
|
<node name="vl53l1x" pkg="clever" type="vl53l1x.py" output="screen" if="$(arg vl53l1x)">
|
||||||
|
<param name="z_shift" value="-0.05"/>
|
||||||
|
<!-- <remap from="~range" to="mavros/distance_sensor/rangefinder_3_sub"/> -->
|
||||||
|
</node>
|
||||||
|
|
||||||
<!-- rc backend -->
|
<!-- rc backend -->
|
||||||
<node name="rc" pkg="clever" type="rc" output="screen" if="$(arg rc)"/>
|
<node name="rc" pkg="clever" type="rc" output="screen" if="$(arg rc)"/>
|
||||||
|
|
||||||
<!-- FPV video streaming -->
|
|
||||||
<include file="$(find clever)/launch/fpv_camera.launch" if="$(arg fpv_camera)">
|
|
||||||
<arg name="device" value="$(arg fpv_camera_device)"/>
|
|
||||||
</include>
|
|
||||||
|
|
||||||
<!-- Arduino bridge -->
|
<!-- Arduino bridge -->
|
||||||
<include file="$(find clever)/launch/arduino.launch" if="$(arg arduino)"/>
|
<include file="$(find clever)/launch/arduino.launch" if="$(arg arduino)"/>
|
||||||
</launch>
|
</launch>
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
<launch>
|
|
||||||
<remap to="mavros/local_position/pose" from="local_position"/>
|
|
||||||
<remap to="mavros/setpoint_position/local" from="local_setpoint"/>
|
|
||||||
|
|
||||||
<node name="copter_visualization" pkg="mavros_extras" type="copter_visualization"/>
|
|
||||||
|
|
||||||
<param name="copter_visualization/fixed_frame_id" value="local_origin"/>
|
|
||||||
<param name="copter_visualization/child_frame_id" value="fcu"/>
|
|
||||||
<param name="copter_visualization/marker_scale" value="1"/>
|
|
||||||
<param name="copter_visualization/max_track_size" value="500"/>
|
|
||||||
<param name="copter_visualization/num_rotors" value="4"/>
|
|
||||||
</launch>
|
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
<launch>
|
<launch>
|
||||||
|
<!-- Camera position and orientation are represented by fcu -> main_camera_optical transform -->
|
||||||
|
<!-- static_transform_publisher arguments: x y z yaw pitch roll frame_id child_frame_id -->
|
||||||
|
|
||||||
<!-- clever 2 -->
|
<!-- clever 2 -->
|
||||||
<!--<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0 0 -0.07 -1.5707963 0 3.1415926 fcu main_camera_optical"/>-->
|
<!--<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0 0 -0.07 -1.5707963 0 3.1415926 fcu main_camera_optical"/>-->
|
||||||
|
|
||||||
@@ -16,8 +19,14 @@
|
|||||||
<!-- setting camera FPS -->
|
<!-- setting camera FPS -->
|
||||||
<param name="rate" value="100"/>
|
<param name="rate" value="100"/>
|
||||||
<param name="cv_cap_prop_fps" value="40"/>
|
<param name="cv_cap_prop_fps" value="40"/>
|
||||||
|
<param name="capture_delay" value="0.02"/>
|
||||||
|
|
||||||
<param name="image_width" value="320"/>
|
<param name="image_width" value="320"/>
|
||||||
<param name="image_height" value="240"/>
|
<param name="image_height" value="240"/>
|
||||||
</node>
|
</node>
|
||||||
|
|
||||||
|
<!-- camera visualization markers -->
|
||||||
|
<node pkg="clever" type="camera_markers" ns="main_camera" name="main_camera_markers">
|
||||||
|
<param name="scale" value="3.0"/>
|
||||||
|
</node>
|
||||||
</launch>
|
</launch>
|
||||||
|
|||||||
@@ -1,58 +1,96 @@
|
|||||||
<launch>
|
<launch>
|
||||||
<arg name="fcu_conn" default="uart"/>
|
<arg name="fcu_conn" default="usb"/>
|
||||||
<arg name="fcu_ip" default="127.0.0.1"/>
|
<arg name="fcu_ip" default="127.0.0.1"/>
|
||||||
<arg name="gcs_bridge" default="tcp"/>
|
<arg name="gcs_bridge" default="tcp"/>
|
||||||
<arg name="viz" default="true"/>
|
<arg name="viz" default="true"/>
|
||||||
<arg name="respawn" default="true"/>
|
<arg name="respawn" default="true"/>
|
||||||
|
|
||||||
<node pkg="mavros" type="mavros_node" name="mavros" required="false" clear_params="true" respawn="$(arg respawn)" respawn_delay="5" output="screen">
|
<node pkg="mavros" type="mavros_node" name="mavros" required="false" clear_params="true" respawn="$(arg respawn)" respawn_delay="5" output="screen">
|
||||||
<!-- UART connection -->
|
<!-- UART connection -->
|
||||||
<param name="fcu_url" value="/dev/ttyAMA0:921600" if="$(eval fcu_conn is None or fcu_conn == 'uart')"/>
|
<param name="fcu_url" value="/dev/ttyAMA0:921600" if="$(eval fcu_conn is None or fcu_conn == 'uart')"/>
|
||||||
|
|
||||||
<!-- USB connection -->
|
<!-- USB connection -->
|
||||||
<param name="fcu_url" value="/dev/ttyACM0" if="$(eval fcu_conn == 'usb')"/>
|
<param name="fcu_url" value="/dev/ttyACM0" if="$(eval fcu_conn == 'usb')"/>
|
||||||
|
|
||||||
<!-- sitl -->
|
<!-- sitl -->
|
||||||
<param name="fcu_url" value="udp://@$(arg fcu_ip):14557" if="$(eval fcu_conn == 'udp')"/>
|
<param name="fcu_url" value="udp://@$(arg fcu_ip):14557" if="$(eval fcu_conn == 'udp')"/>
|
||||||
|
|
||||||
<!-- gcs bridge -->
|
<!-- gcs bridge -->
|
||||||
<param name="gcs_url" value="tcp-l://0.0.0.0:5760" if="$(eval gcs_bridge == 'tcp')"/>
|
<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')"/>
|
<param name="gcs_url" value="udp://0.0.0.0:14550@14550" if="$(eval gcs_bridge == 'udp')"/>
|
||||||
<param name="gcs_url" value="udp-b://$(env ROS_IP):14550@14550" if="$(eval gcs_bridge == 'udp-b')"/>
|
<param name="gcs_url" value="udp-b://$(env ROS_IP):14550@14550" if="$(eval gcs_bridge == 'udp-b')"/>
|
||||||
<param name="gcs_url" value="udp-pb://$(env ROS_IP):14550@14550" if="$(eval gcs_bridge == 'udp-pb')"/>
|
<param name="gcs_url" value="udp-pb://$(env ROS_IP):14550@14550" if="$(eval gcs_bridge == 'udp-pb')"/>
|
||||||
<param name="gcs_url" value="" if="$(eval not gcs_bridge)"/>
|
<param name="gcs_url" value="" if="$(eval not gcs_bridge)"/>
|
||||||
<param name="gcs_quiet_mode" value="true"/>
|
<param name="gcs_quiet_mode" value="true"/>
|
||||||
<param name="conn/timeout" value="8"/>
|
<param name="conn/timeout" value="8"/>
|
||||||
|
|
||||||
<!-- default px4 params -->
|
<!-- default px4 params -->
|
||||||
<rosparam command="load" file="$(find mavros)/launch/px4_config.yaml"/>
|
<rosparam command="load" file="$(find mavros)/launch/px4_config.yaml"/>
|
||||||
|
|
||||||
<!-- additional params -->
|
<!-- rangefinders -->
|
||||||
<param name="local_position/frame_id" value="local_origin"/>
|
<rosparam>
|
||||||
<param name="local_position/tf/send" value="true"/>
|
distance_sensor:
|
||||||
<param name="local_position/tf/frame_id" value="local_origin"/>
|
rangefinder_0:
|
||||||
<param name="local_position/tf/child_frame_id" value="fcu"/>
|
id: 0
|
||||||
<param name="global_position/tf/send" value="false"/>
|
frame_id: "rangefinder"
|
||||||
<param name="imu/frame_id" value="fcu"/>
|
orientation: PITCH_270
|
||||||
<rosparam param="plugin_blacklist">
|
field_of_view: 0.5
|
||||||
- safety_area
|
rangefinder_1:
|
||||||
- image_pub
|
id: 1
|
||||||
- vibration
|
frame_id: "rangefinder"
|
||||||
- distance_sensor
|
orientation: PITCH_270
|
||||||
- rangefinder
|
field_of_view: 0.5
|
||||||
- 3dr_radio
|
rangefinder_2_sub:
|
||||||
- actuator_control
|
subscriber: true
|
||||||
- hil_controls
|
id: 2
|
||||||
- vfr_hud
|
orientation: PITCH_270
|
||||||
- px4flow
|
rangefinder_3_sub:
|
||||||
- vision_speed_estimate
|
subscriber: true
|
||||||
- fake_gps
|
id: 3
|
||||||
- cam_imu_sync
|
orientation: PITCH_270
|
||||||
- hil
|
</rosparam>
|
||||||
- adsb
|
|
||||||
</rosparam>
|
<!-- additional params -->
|
||||||
|
<param name="local_position/frame_id" value="local_origin"/>
|
||||||
|
<param name="local_position/tf/send" value="true"/>
|
||||||
|
<param name="local_position/tf/frame_id" value="local_origin"/>
|
||||||
|
<param name="local_position/tf/child_frame_id" value="fcu"/>
|
||||||
|
<param name="global_position/tf/send" value="false"/>
|
||||||
|
<param name="imu/frame_id" value="fcu"/>
|
||||||
|
<rosparam param="plugin_blacklist">
|
||||||
|
- safety_area
|
||||||
|
- image_pub
|
||||||
|
- vibration
|
||||||
|
- rangefinder
|
||||||
|
- 3dr_radio
|
||||||
|
- actuator_control
|
||||||
|
- hil_controls
|
||||||
|
- vfr_hud
|
||||||
|
- vision_speed_estimate
|
||||||
|
- fake_gps
|
||||||
|
- cam_imu_sync
|
||||||
|
- hil
|
||||||
|
- adsb
|
||||||
|
- waypoint
|
||||||
|
- obstacle_distance
|
||||||
|
- setpoint_accel
|
||||||
|
- trajectory
|
||||||
|
- wind_estimation
|
||||||
|
- home_position
|
||||||
|
</rosparam>
|
||||||
</node>
|
</node>
|
||||||
|
|
||||||
|
<!-- Rangefinders frame -->
|
||||||
|
<node pkg="tf2_ros" type="static_transform_publisher" name="rangefinder_frame" args="0 0 -0.05 0 1.5707963268 0 fcu rangefinder"/>
|
||||||
|
|
||||||
<!-- Copter visualization -->
|
<!-- Copter visualization -->
|
||||||
<include file="$(find clever)/launch/copter_visualization.launch" if="$(arg viz)"/>
|
<node name="copter_visualization" pkg="mavros_extras" type="copter_visualization" if="$(arg viz)">
|
||||||
|
<remap to="mavros/local_position/pose" from="local_position"/>
|
||||||
|
<remap to="mavros/setpoint_position/local" from="local_setpoint"/>
|
||||||
|
<param name="fixed_frame_id" value="local_origin"/>
|
||||||
|
<param name="child_frame_id" value="fcu"/>
|
||||||
|
<param name="marker_scale" value="1"/>
|
||||||
|
<param name="max_track_size" value="20"/>
|
||||||
|
<param name="num_rotors" value="4"/>
|
||||||
|
</node>
|
||||||
</launch>
|
</launch>
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
<launch>
|
<launch>
|
||||||
<!-- Clever configuration for testing in sitl -->
|
<!-- Clever configuration for testing in sitl -->
|
||||||
<arg name="ip" default="127.0.0.1"/>
|
<arg name="ip" default="127.0.0.1"/>
|
||||||
<arg name="rosbridge" default="true"/>
|
<arg name="rosbridge" default="false"/>
|
||||||
|
|
||||||
<include file="$(find clever)/launch/clever.launch">
|
<include file="$(find clever)/launch/clever.launch">
|
||||||
<arg name="fcu_conn" value="udp"/>
|
<arg name="fcu_conn" value="udp"/>
|
||||||
<arg name="fcu_ip" value="$(arg ip)"/>
|
<arg name="fcu_ip" value="$(arg ip)"/>
|
||||||
<arg name="gcs_bridge" value="false"/>
|
<arg name="gcs_bridge" value="false"/>
|
||||||
|
<arg name="optical_flow" value="false"/>
|
||||||
|
<arg name="web_server" default="false"/>
|
||||||
<arg name="web_video_server" default="false"/>
|
<arg name="web_video_server" default="false"/>
|
||||||
<arg name="main_camera" default="false"/>
|
<arg name="main_camera" default="false"/>
|
||||||
<arg name="fpv_camera" default="false"/>
|
|
||||||
<arg name="rosbridge" value="$(arg rosbridge)"/>
|
<arg name="rosbridge" value="$(arg rosbridge)"/>
|
||||||
<arg name="web_server" default="false"/>
|
|
||||||
<arg name="aruco" default="false"/>
|
<arg name="aruco" default="false"/>
|
||||||
|
<arg name="vl53l1x" default="false"/>
|
||||||
|
<arg name="rc" default="false"/>
|
||||||
</include>
|
</include>
|
||||||
</launch>
|
</launch>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
<launch>
|
|
||||||
<node name="web_server" pkg="clever" type="web_server.py" output="screen">
|
|
||||||
<param name="path" value="$(find clever)/static"/>
|
|
||||||
</node>
|
|
||||||
</launch>
|
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
<library path="lib/libclever">
|
||||||
|
<class name="clever/optical_flow" type="OpticalFlow" base_class_type="nodelet::Nodelet">
|
||||||
|
<description/>
|
||||||
|
</class>
|
||||||
|
</library>
|
||||||
<library path="lib/libfcu_horiz">
|
<library path="lib/libfcu_horiz">
|
||||||
<class name="clever/fcu_horiz" type="FcuHoriz" base_class_type="nodelet::Nodelet">
|
<class name="clever/fcu_horiz" type="FcuHoriz" base_class_type="nodelet::Nodelet">
|
||||||
<description/>
|
<description/>
|
||||||
|
|||||||
@@ -2,55 +2,40 @@
|
|||||||
<package>
|
<package>
|
||||||
<name>clever</name>
|
<name>clever</name>
|
||||||
<version>0.0.1</version>
|
<version>0.0.1</version>
|
||||||
<description>The clever package</description>
|
<description>The CLEVER package</description>
|
||||||
|
|
||||||
<!-- One maintainer tag required, multiple allowed, one person per tag -->
|
|
||||||
<!-- Example: -->
|
|
||||||
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
|
|
||||||
<maintainer email="okalachev@gmail.com">Oleg Kalachev</maintainer>
|
<maintainer email="okalachev@gmail.com">Oleg Kalachev</maintainer>
|
||||||
|
<license>MIT</license>
|
||||||
|
|
||||||
|
<!--url type="website">http://wiki.ros.org/clever</url-->
|
||||||
|
<author email="okalachev@gmail.com">Oleg Kalachev</author>
|
||||||
|
<author email="urpylka@gmail.com">Artem Smirnov</author>
|
||||||
|
|
||||||
<!-- One license tag required, multiple allowed, one license per tag -->
|
|
||||||
<!-- Commonly used license strings: -->
|
|
||||||
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
|
|
||||||
<license>TODO</license>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Url tags are optional, but multiple are allowed, one per tag -->
|
|
||||||
<!-- Optional attribute type can be: website, bugtracker, or repository -->
|
|
||||||
<!-- Example: -->
|
|
||||||
<!-- <url type="website">http://wiki.ros.org/clever</url> -->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Author tags are optional, multiple are allowed, one per tag -->
|
|
||||||
<!-- Authors do not have to be maintainers, but could be -->
|
|
||||||
<!-- Example: -->
|
|
||||||
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- The *_depend tags are used to specify dependencies -->
|
|
||||||
<!-- Dependencies can be catkin packages or system dependencies -->
|
|
||||||
<!-- Examples: -->
|
|
||||||
<!-- Use build_depend for packages you need at compile time: -->
|
<!-- Use build_depend for packages you need at compile time: -->
|
||||||
<!-- <build_depend>message_generation</build_depend> -->
|
|
||||||
<!-- Use buildtool_depend for build tool packages: -->
|
|
||||||
<!-- <buildtool_depend>catkin</buildtool_depend> -->
|
|
||||||
<!-- Use run_depend for packages you need at runtime: -->
|
|
||||||
<!-- <run_depend>message_runtime</run_depend> -->
|
|
||||||
<!-- Use test_depend for packages you need only for testing: -->
|
|
||||||
<!-- <test_depend>gtest</test_depend> -->
|
|
||||||
<buildtool_depend>catkin</buildtool_depend>
|
|
||||||
|
|
||||||
<build_depend>nodelet</build_depend>
|
<build_depend>nodelet</build_depend>
|
||||||
<build_depend>roscpp</build_depend>
|
<build_depend>roscpp</build_depend>
|
||||||
|
<build_depend>visualization_msgs</build_depend>
|
||||||
<run_depend>nodelet</run_depend>
|
<build_depend>tf2_geometry_msgs</build_depend>
|
||||||
|
<!-- Use buildtool_depend for build tool packages: -->
|
||||||
|
<buildtool_depend>catkin</buildtool_depend>
|
||||||
|
<!-- Use run_depend for packages you need at runtime: -->
|
||||||
|
<run_depend>catkin</run_depend>
|
||||||
<run_depend>roscpp</run_depend>
|
<run_depend>roscpp</run_depend>
|
||||||
|
<run_depend>nodelet</run_depend>
|
||||||
|
<run_depend>mavros</run_depend>
|
||||||
|
<run_depend>mavros_extras</run_depend>
|
||||||
|
<run_depend>lxml</run_depend>
|
||||||
|
<run_depend>cv_camera</run_depend>
|
||||||
|
<run_depend>mjpg-streamer</run_depend>
|
||||||
|
<run_depend>rosbridge_server</run_depend>
|
||||||
|
<run_depend>web_video_server</run_depend>
|
||||||
|
<run_depend>ros_comm</run_depend>r
|
||||||
|
<!-- Use test_depend for packages you need only for testing: -->
|
||||||
|
<!-- <test_depend>gtest</test_depend> -->
|
||||||
|
|
||||||
<!-- The export tag contains other, unspecified, tags -->
|
<!-- The export tag contains other, unspecified, tags -->
|
||||||
<export>
|
<export>
|
||||||
<nodelet plugin="${prefix}/nodelet_plugins.xml" />
|
<nodelet plugin="${prefix}/nodelet_plugins.xml" />
|
||||||
<!-- Other tools can request additional information be placed here -->
|
<!-- Other tools can request additional information be placed here -->
|
||||||
|
|
||||||
</export>
|
</export>
|
||||||
</package>
|
</package>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
flask==0.12.2
|
flask==0.12.3
|
||||||
geopy==1.11.0
|
geopy==1.11.0
|
||||||
pymavlink==2.2.10
|
pymavlink==2.2.10
|
||||||
|
smbus2==0.2.1
|
||||||
|
VL53L1X==0.0.2
|
||||||
|
|||||||
101
clever/src/camera_markers.cpp
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Visualization marker for camera alignment
|
||||||
|
* Copyright (C) 2018 Copter Express Technologies
|
||||||
|
*
|
||||||
|
* Author: Oleg Kalachev <okalachev@gmail.com>
|
||||||
|
*
|
||||||
|
* Distributed under MIT License (available at https://opensource.org/licenses/MIT).
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <ros/ros.h>
|
||||||
|
#include <sensor_msgs/CameraInfo.h>
|
||||||
|
#include <visualization_msgs/Marker.h>
|
||||||
|
#include <visualization_msgs/MarkerArray.h>
|
||||||
|
|
||||||
|
using namespace visualization_msgs;
|
||||||
|
|
||||||
|
double markers_scale;
|
||||||
|
std::string camera_frame;
|
||||||
|
|
||||||
|
MarkerArray createMarkers() {
|
||||||
|
MarkerArray markers;
|
||||||
|
|
||||||
|
Marker lens;
|
||||||
|
lens.header.frame_id = camera_frame;
|
||||||
|
lens.ns = "camera_markers";
|
||||||
|
lens.id = 0;
|
||||||
|
lens.action = Marker::ADD;
|
||||||
|
lens.type = visualization_msgs::Marker::CYLINDER;
|
||||||
|
lens.frame_locked = true;
|
||||||
|
lens.scale.x = 0.013 * markers_scale;
|
||||||
|
lens.scale.y = 0.013 * markers_scale;
|
||||||
|
lens.scale.z = 0.015 * markers_scale;
|
||||||
|
lens.color.r = 0.3;
|
||||||
|
lens.color.g = 0.3;
|
||||||
|
lens.color.b = 0.3;
|
||||||
|
lens.color.a = 0.9;
|
||||||
|
lens.pose.position.z = 0.0075 * markers_scale;
|
||||||
|
lens.pose.orientation.w = 1;
|
||||||
|
|
||||||
|
Marker board;
|
||||||
|
board.header.frame_id = camera_frame;
|
||||||
|
board.ns = "camera_markers";
|
||||||
|
board.id = 1;
|
||||||
|
board.action = Marker::ADD;
|
||||||
|
board.type = Marker::CUBE;
|
||||||
|
board.frame_locked = true;
|
||||||
|
board.scale.x = 0.024 * markers_scale;
|
||||||
|
board.scale.y = 0.024 * markers_scale;
|
||||||
|
board.scale.z = 0.001 * markers_scale;
|
||||||
|
board.color.r = 0.0;
|
||||||
|
board.color.g = 0.8;
|
||||||
|
board.color.b = 0.0;
|
||||||
|
board.color.a = 0.9;
|
||||||
|
board.pose.orientation.w = 1;
|
||||||
|
|
||||||
|
Marker wire;
|
||||||
|
wire.header.frame_id = camera_frame;
|
||||||
|
wire.ns = "camera_markers";
|
||||||
|
wire.id = 2;
|
||||||
|
wire.action = Marker::ADD;
|
||||||
|
wire.type = Marker::CUBE;
|
||||||
|
wire.frame_locked = true;
|
||||||
|
wire.scale.x = 0.014 * markers_scale;
|
||||||
|
wire.scale.y = 0.04 * markers_scale;
|
||||||
|
wire.scale.z = 0.001 * markers_scale;
|
||||||
|
wire.color.r = 0.9;
|
||||||
|
wire.color.g = 0.9;
|
||||||
|
wire.color.b = 1.0;
|
||||||
|
wire.color.a = 0.8;
|
||||||
|
wire.pose.position.x = 0;
|
||||||
|
wire.pose.position.y = (0.01 + 0.02) * markers_scale;
|
||||||
|
wire.pose.position.z = 0.002 * markers_scale;
|
||||||
|
wire.pose.orientation.w = 1;
|
||||||
|
|
||||||
|
markers.markers.push_back(lens);
|
||||||
|
markers.markers.push_back(board);
|
||||||
|
markers.markers.push_back(wire);
|
||||||
|
|
||||||
|
return markers;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
ros::init(argc, argv, "camera_markers", ros::init_options::AnonymousName);
|
||||||
|
ros::NodeHandle nh, nh_priv("~");
|
||||||
|
|
||||||
|
nh_priv.param("scale", markers_scale, 1.0);
|
||||||
|
|
||||||
|
// wait for camera info
|
||||||
|
auto camera_info = ros::topic::waitForMessage<sensor_msgs::CameraInfo>("camera_info", nh);
|
||||||
|
camera_frame = camera_info->header.frame_id;
|
||||||
|
|
||||||
|
ros::Publisher markers_pub = nh.advertise<visualization_msgs::MarkerArray>("camera_markers", 1, true);
|
||||||
|
markers_pub.publish(createMarkers());
|
||||||
|
|
||||||
|
ROS_INFO("Camera markers initialized");
|
||||||
|
ros::spin();
|
||||||
|
}
|
||||||
@@ -4,5 +4,4 @@
|
|||||||
# fpv_camera <video_device> <http port>
|
# fpv_camera <video_device> <http port>
|
||||||
|
|
||||||
echo "Starting FPV camera $1 on :$2"
|
echo "Starting FPV camera $1 on :$2"
|
||||||
cd /home/pi/mjpg-streamer/mjpg-streamer-experimental
|
mjpg_streamer -i "/usr/lib/input_uvc.so -d $1 -r 320x240 -f 30" -o "/usr/lib/output_http.so -w /usr/share/mjpg_streamer/www -p $2"
|
||||||
./mjpg_streamer -i "./input_uvc.so -d $1 -r 320x240 -f 30" -o "./output_http.so -w ./www -p $2"
|
|
||||||
|
|||||||
63
clever/src/frames.cpp
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Auxiliary TF frames for CLEVER drone kit:
|
||||||
|
* - Body frame (drone body with zero pitch and roll).
|
||||||
|
* - TODO: REP-0105 `odom` frame emulation: continuous frame without discrete jumps.
|
||||||
|
* - TODO: Terrain frame (base on ALTITUDE message).
|
||||||
|
* - TODO: map_upside_down frame
|
||||||
|
* - TODO: home frame?
|
||||||
|
*
|
||||||
|
* Copyright (C) 2018 Copter Express Technologies
|
||||||
|
*
|
||||||
|
* Author: Oleg Kalachev <okalachev@gmail.com>
|
||||||
|
*
|
||||||
|
* Distributed under MIT License (available at https://opensource.org/licenses/MIT).
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: consider implementing as a mavros plugin
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <ros/ros.h>
|
||||||
|
#include <tf/transform_datatypes.h>
|
||||||
|
#include <tf2_ros/transform_broadcaster.h>
|
||||||
|
#include <geometry_msgs/TransformStamped.h>
|
||||||
|
#include <geometry_msgs/PoseStamped.h>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
static std::shared_ptr<tf2_ros::TransformBroadcaster> br;
|
||||||
|
static geometry_msgs::TransformStamped body;
|
||||||
|
|
||||||
|
inline void publishBody(const geometry_msgs::PoseStamped& pose)
|
||||||
|
{
|
||||||
|
// Get only yaw from pose
|
||||||
|
tf::Quaternion q;
|
||||||
|
q.setRPY(0, 0, tf::getYaw(pose.pose.orientation));
|
||||||
|
tf::quaternionTFToMsg(q, body.transform.rotation);
|
||||||
|
|
||||||
|
body.transform.translation.x = pose.pose.position.x;
|
||||||
|
body.transform.translation.y = pose.pose.position.y;
|
||||||
|
body.transform.translation.z = pose.pose.position.z;
|
||||||
|
body.header.frame_id = pose.header.frame_id;
|
||||||
|
body.header.stamp = pose.header.stamp;
|
||||||
|
br->sendTransform(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
void poseCallback(const geometry_msgs::PoseStamped& pose)
|
||||||
|
{
|
||||||
|
publishBody(pose);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
ros::init(argc, argv, "frames");
|
||||||
|
ros::NodeHandle nh, nh_priv("~");
|
||||||
|
|
||||||
|
nh_priv.param<string>("body/frame_id", body.child_frame_id, "body");
|
||||||
|
|
||||||
|
br = std::make_shared<tf2_ros::TransformBroadcaster>();
|
||||||
|
ros::Subscriber pose_sub = nh.subscribe("mavros/local_position/pose", 1, &poseCallback);
|
||||||
|
ROS_INFO("frames: ready");
|
||||||
|
ros::spin();
|
||||||
|
}
|
||||||
85
clever/src/interactive.py
Executable file
@@ -0,0 +1,85 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import copy
|
||||||
|
|
||||||
|
import rospy
|
||||||
|
import tf.transformations as t
|
||||||
|
from interactive_markers.interactive_marker_server import InteractiveMarkerServer
|
||||||
|
from visualization_msgs.msg import Marker, InteractiveMarker, InteractiveMarkerControl, InteractiveMarkerFeedback
|
||||||
|
from clever import srv
|
||||||
|
|
||||||
|
|
||||||
|
def make_box(msg):
|
||||||
|
marker = Marker()
|
||||||
|
|
||||||
|
marker.type = Marker.CUBE
|
||||||
|
marker.scale.x = msg.scale * 0.3
|
||||||
|
marker.scale.y = msg.scale * 0.3
|
||||||
|
marker.scale.z = msg.scale * 0.3
|
||||||
|
marker.color.r = 0.5
|
||||||
|
marker.color.g = 0.5
|
||||||
|
marker.color.b = 0.5
|
||||||
|
marker.color.a = 1.0
|
||||||
|
marker.pose.orientation.w = 1
|
||||||
|
|
||||||
|
return marker
|
||||||
|
|
||||||
|
|
||||||
|
def make_box_control(msg):
|
||||||
|
control = InteractiveMarkerControl()
|
||||||
|
control.always_visible = True
|
||||||
|
control.orientation.w = 1
|
||||||
|
control.markers.append(make_box(msg))
|
||||||
|
msg.controls.append(control)
|
||||||
|
return control
|
||||||
|
|
||||||
|
|
||||||
|
def make_quadcopter_marker():
|
||||||
|
marker = InteractiveMarker()
|
||||||
|
marker.header.frame_id = 'fcu'
|
||||||
|
marker.header.stamp = rospy.get_rostime()
|
||||||
|
marker.scale = 1
|
||||||
|
marker.pose.orientation.w = 1
|
||||||
|
|
||||||
|
marker.name = 'quadcopter'
|
||||||
|
marker.description = 'Quadcopter'
|
||||||
|
|
||||||
|
make_box_control(marker)
|
||||||
|
|
||||||
|
control = InteractiveMarkerControl()
|
||||||
|
control.orientation.w = 1
|
||||||
|
control.orientation.x = 0
|
||||||
|
control.orientation.y = 1
|
||||||
|
control.orientation.z = 0
|
||||||
|
control.interaction_mode = InteractiveMarkerControl.MOVE_ROTATE
|
||||||
|
marker.controls.append(copy.deepcopy(control))
|
||||||
|
control.interaction_mode = InteractiveMarkerControl.MOVE_AXIS
|
||||||
|
marker.controls.append(control)
|
||||||
|
|
||||||
|
return marker
|
||||||
|
|
||||||
|
|
||||||
|
navigate = rospy.ServiceProxy('navigate', srv.Navigate)
|
||||||
|
|
||||||
|
|
||||||
|
def process_feedback(feedback):
|
||||||
|
if feedback.event_type != InteractiveMarkerFeedback.MOUSE_UP:
|
||||||
|
return
|
||||||
|
|
||||||
|
p = feedback.pose.position
|
||||||
|
o = feedback.pose.orientation
|
||||||
|
yaw = t.euler_from_quaternion((o.x, o.y, o.z, o.w), axes='rzyx')[0]
|
||||||
|
rospy.loginfo('Navigate to %s', p)
|
||||||
|
rospy.loginfo(navigate(x=p.x, y=p.y, z=p.z, yaw=yaw, speed=2,
|
||||||
|
frame_id=feedback.header.frame_id, auto_arm=True))
|
||||||
|
|
||||||
|
|
||||||
|
rospy.init_node('quadcopter_im')
|
||||||
|
|
||||||
|
server = InteractiveMarkerServer('quadcopter_im')
|
||||||
|
|
||||||
|
int_marker = make_quadcopter_marker()
|
||||||
|
server.insert(int_marker, process_feedback)
|
||||||
|
server.applyChanges()
|
||||||
|
|
||||||
|
rospy.loginfo('Interactive quadcopter marker initialized')
|
||||||
|
rospy.spin()
|
||||||
200
clever/src/optical_flow.cpp
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
/*
|
||||||
|
* Optical Flow node for PX4
|
||||||
|
* Copyright (C) 2018 Copter Express Technologies
|
||||||
|
*
|
||||||
|
* Author: Oleg Kalachev <okalachev@gmail.com>
|
||||||
|
*
|
||||||
|
* Distributed under MIT License (available at https://opensource.org/licenses/MIT).
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <cmath>
|
||||||
|
#include <nodelet/nodelet.h>
|
||||||
|
#include <pluginlib/class_list_macros.h>
|
||||||
|
#include <image_transport/image_transport.h>
|
||||||
|
#include <cv_bridge/cv_bridge.h>
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include <tf/transform_datatypes.h>
|
||||||
|
#include <tf2/exceptions.h>
|
||||||
|
#include <tf2/convert.h>
|
||||||
|
#include <tf2_ros/transform_listener.h>
|
||||||
|
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
|
||||||
|
#include <mavros_msgs/OpticalFlowRad.h>
|
||||||
|
#include <sensor_msgs/Imu.h>
|
||||||
|
#include <geometry_msgs/Vector3Stamped.h>
|
||||||
|
#include <geometry_msgs/PointStamped.h>
|
||||||
|
#include <geometry_msgs/TwistStamped.h>
|
||||||
|
|
||||||
|
using cv::Mat;
|
||||||
|
|
||||||
|
class OpticalFlow : public nodelet::Nodelet
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OpticalFlow():
|
||||||
|
camera_matrix_(3, 3, CV_64F),
|
||||||
|
dist_coeffs_(8, 1, CV_64F),
|
||||||
|
tf_listener_(tf_buffer_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ros::Publisher flow_pub_, velo_pub_, shift_pub_;
|
||||||
|
ros::Time prev_stamp_;
|
||||||
|
std::string fcu_frame_id_;
|
||||||
|
image_transport::CameraSubscriber img_sub_;
|
||||||
|
image_transport::Publisher img_pub_;
|
||||||
|
mavros_msgs::OpticalFlowRad flow_;
|
||||||
|
int roi_, roi_2_;
|
||||||
|
Mat hann_;
|
||||||
|
Mat prev_, curr_;
|
||||||
|
Mat camera_matrix_, dist_coeffs_;
|
||||||
|
tf2_ros::Buffer tf_buffer_;
|
||||||
|
tf2_ros::TransformListener tf_listener_;
|
||||||
|
|
||||||
|
void onInit()
|
||||||
|
{
|
||||||
|
ros::NodeHandle& nh = getNodeHandle();
|
||||||
|
ros::NodeHandle& nh_priv = getPrivateNodeHandle();
|
||||||
|
image_transport::ImageTransport it(nh);
|
||||||
|
image_transport::ImageTransport it_priv(nh_priv);
|
||||||
|
|
||||||
|
nh_priv.param<std::string>("mavros/local_position/tf/child_frame_id", fcu_frame_id_, "fcu");
|
||||||
|
nh_priv.param("roi", roi_, 128);
|
||||||
|
roi_2_ = roi_ / 2;
|
||||||
|
|
||||||
|
img_sub_ = it.subscribeCamera("image", 1, &OpticalFlow::flow, this);
|
||||||
|
img_pub_ = it_priv.advertise("debug", 1);
|
||||||
|
flow_pub_ = nh.advertise<mavros_msgs::OpticalFlowRad>("mavros/px4flow/raw/send", 1);
|
||||||
|
velo_pub_ = nh_priv.advertise<geometry_msgs::TwistStamped>("angular_velocity", 1);
|
||||||
|
shift_pub_ = nh_priv.advertise<geometry_msgs::Vector3Stamped>("shift", 1);
|
||||||
|
|
||||||
|
flow_.integrated_xgyro = NAN; // no IMU available
|
||||||
|
flow_.integrated_ygyro = NAN;
|
||||||
|
flow_.integrated_zgyro = NAN;
|
||||||
|
flow_.time_delta_distance_us = 0;
|
||||||
|
flow_.distance = -1; // no distance sensor available
|
||||||
|
flow_.temperature = 0;
|
||||||
|
|
||||||
|
ROS_INFO("Optical Flow initialized");
|
||||||
|
}
|
||||||
|
|
||||||
|
void parseCameraInfo(const sensor_msgs::CameraInfoConstPtr &cinfo) {
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
for (int j = 0; j < 3; ++j) {
|
||||||
|
camera_matrix_.at<double>(i, j) = cinfo->K[3 * i + j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int k = 0; k < cinfo->D.size(); k++) {
|
||||||
|
dist_coeffs_.at<double>(k) = cinfo->D[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawFlow(Mat& frame, double x, double y, double quality) const
|
||||||
|
{
|
||||||
|
double brightness = (1 - quality) * 25;;
|
||||||
|
cv::Scalar color(brightness, brightness, brightness);
|
||||||
|
double radius = std::sqrt(x * x + y * y);
|
||||||
|
|
||||||
|
// draw a circle and line indicating the shift direction...
|
||||||
|
cv::Point center(frame.cols >> 1, frame.rows >> 1);
|
||||||
|
cv::circle(frame, center, (int)(radius*5), color, 3, cv::LINE_AA);
|
||||||
|
cv::line(frame, center, cv::Point(center.x + (int)(x*5), center.y + (int)(y*5)), color, 3, cv::LINE_AA);
|
||||||
|
}
|
||||||
|
|
||||||
|
void flow(const sensor_msgs::ImageConstPtr& msg, const sensor_msgs::CameraInfoConstPtr& cinfo)
|
||||||
|
{
|
||||||
|
parseCameraInfo(cinfo);
|
||||||
|
|
||||||
|
auto img = cv_bridge::toCvShare(msg, "mono8")->image;
|
||||||
|
|
||||||
|
// Apply ROI
|
||||||
|
if (roi_ != 0) {
|
||||||
|
img = img(cv::Rect((msg->width / 2 - roi_2_), (msg->height / 2 - roi_2_), roi_, roi_));
|
||||||
|
}
|
||||||
|
|
||||||
|
img.convertTo(curr_, CV_64F);
|
||||||
|
|
||||||
|
if (prev_.empty()) {
|
||||||
|
prev_ = curr_.clone();
|
||||||
|
prev_stamp_ = msg->header.stamp;
|
||||||
|
cv::createHanningWindow(hann_, curr_.size(), CV_64F);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
double response;
|
||||||
|
cv::Point2d shift = cv::phaseCorrelate(prev_, curr_, hann_, &response);
|
||||||
|
|
||||||
|
// Publish raw shift in pixels
|
||||||
|
static geometry_msgs::Vector3Stamped shift_vec;
|
||||||
|
shift_vec.header.stamp = msg->header.stamp;
|
||||||
|
shift_vec.header.frame_id = msg->header.frame_id;
|
||||||
|
shift_vec.vector.x = shift.x;
|
||||||
|
shift_vec.vector.y = shift.y;
|
||||||
|
shift_pub_.publish(shift_vec);
|
||||||
|
|
||||||
|
// Undistort flow in pixels
|
||||||
|
uint32_t flow_center_x = msg->width / 2;
|
||||||
|
uint32_t flow_center_y = msg->height / 2;
|
||||||
|
shift.x += flow_center_x;
|
||||||
|
shift.y += flow_center_y;
|
||||||
|
|
||||||
|
std::vector<cv::Point2d> points_dist = { shift };
|
||||||
|
std::vector<cv::Point2d> points_undist(1);
|
||||||
|
|
||||||
|
cv::undistortPoints(points_dist, points_undist, camera_matrix_, dist_coeffs_, cv::noArray(), camera_matrix_);
|
||||||
|
points_undist[0].x -= flow_center_x;
|
||||||
|
points_undist[0].y -= flow_center_y;
|
||||||
|
|
||||||
|
// Calculate flow in radians
|
||||||
|
double focal_length_x = camera_matrix_.at<double>(0, 0);
|
||||||
|
double focal_length_y = camera_matrix_.at<double>(1, 1);
|
||||||
|
double flow_x = atan2(points_undist[0].x, focal_length_x);
|
||||||
|
double flow_y = atan2(points_undist[0].y, focal_length_y);
|
||||||
|
|
||||||
|
// // Convert to FCU frame
|
||||||
|
static geometry_msgs::Vector3Stamped flow_camera, flow_fcu;
|
||||||
|
flow_camera.header.frame_id = msg->header.frame_id;
|
||||||
|
flow_camera.header.stamp = msg->header.stamp;
|
||||||
|
flow_camera.vector.x = flow_y; // +y means counter-clockwise rotation around Y axis
|
||||||
|
flow_camera.vector.y = -flow_x; // +x means clockwise rotation around X axis
|
||||||
|
tf_buffer_.transform(flow_camera, flow_fcu, fcu_frame_id_);
|
||||||
|
|
||||||
|
// Calculate integration time
|
||||||
|
ros::Duration integration_time = msg->header.stamp - prev_stamp_;
|
||||||
|
uint32_t integration_time_us = integration_time.toSec() * 1.0e6;
|
||||||
|
|
||||||
|
// Publish flow in fcu frame
|
||||||
|
flow_.header.stamp = /*prev_stamp_*/ msg->header.stamp;
|
||||||
|
flow_.integration_time_us = integration_time_us;
|
||||||
|
flow_.integrated_x = flow_fcu.vector.x;
|
||||||
|
flow_.integrated_y = flow_fcu.vector.y;
|
||||||
|
flow_.quality = (uint8_t)(response * 255);
|
||||||
|
flow_pub_.publish(flow_);
|
||||||
|
|
||||||
|
// Publish debug image
|
||||||
|
if (img_pub_.getNumSubscribers() > 0) {
|
||||||
|
// publish debug image
|
||||||
|
drawFlow(img, shift_vec.vector.x, shift_vec.vector.y, response);
|
||||||
|
cv_bridge::CvImage out_msg;
|
||||||
|
out_msg.header.frame_id = msg->header.frame_id;
|
||||||
|
out_msg.header.stamp = msg->header.stamp;
|
||||||
|
out_msg.encoding = sensor_msgs::image_encodings::MONO8;
|
||||||
|
out_msg.image = img;
|
||||||
|
img_pub_.publish(out_msg.toImageMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Publish estimated angular velocity
|
||||||
|
static geometry_msgs::TwistStamped velo;
|
||||||
|
velo.header.stamp = msg->header.stamp;
|
||||||
|
velo.header.frame_id = fcu_frame_id_;
|
||||||
|
velo.twist.angular.x = flow_.integrated_x / integration_time.toSec();
|
||||||
|
velo.twist.angular.y = flow_.integrated_y / integration_time.toSec();
|
||||||
|
velo_pub_.publish(velo);
|
||||||
|
|
||||||
|
prev_ = curr_.clone();
|
||||||
|
prev_stamp_ = msg->header.stamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
PLUGINLIB_EXPORT_CLASS(OpticalFlow, nodelet::Nodelet)
|
||||||
@@ -1,107 +1,229 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import math
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
|
import re
|
||||||
|
import traceback
|
||||||
import rospy
|
import rospy
|
||||||
from std_srvs.srv import Trigger
|
from std_srvs.srv import Trigger
|
||||||
from sensor_msgs.msg import Image, CameraInfo, NavSatFix, Imu
|
from sensor_msgs.msg import Image, CameraInfo, NavSatFix, Imu, Range
|
||||||
from mavros_msgs.msg import State
|
from mavros_msgs.msg import State, OpticalFlowRad
|
||||||
from geometry_msgs.msg import PoseStamped, TwistStamped
|
from geometry_msgs.msg import PoseStamped, TwistStamped
|
||||||
|
from aruco_pose.msg import MarkerArray
|
||||||
|
|
||||||
|
|
||||||
# TODO: roscore is running
|
# TODO: roscore is running
|
||||||
|
# TODO: clever.service is running
|
||||||
|
# TODO: check attitude is present
|
||||||
|
# TODO: disk free space
|
||||||
# TODO: local_origin, fcu, fcu_horiz
|
# TODO: local_origin, fcu, fcu_horiz
|
||||||
# TODO: rc service
|
# TODO: rc service
|
||||||
# TODO: perform commander check in PX4
|
# TODO: perform commander check, ekf2 status on PX4
|
||||||
|
# TODO: check if FCU params setter succeed
|
||||||
|
# TODO: selfcheck ROS service (with blacklists for checks)
|
||||||
|
|
||||||
|
|
||||||
rospy.init_node('selfcheck')
|
rospy.init_node('selfcheck')
|
||||||
|
|
||||||
|
|
||||||
|
failures = []
|
||||||
|
|
||||||
|
|
||||||
|
def failure(text, *args):
|
||||||
|
failures.append(text % args)
|
||||||
|
|
||||||
|
|
||||||
|
def check(name):
|
||||||
|
def inner(fn):
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
failures[:] = []
|
||||||
|
try:
|
||||||
|
fn(*args, **kwargs)
|
||||||
|
for f in failures:
|
||||||
|
rospy.logwarn('%s: %s', name, f)
|
||||||
|
except Exception as e:
|
||||||
|
traceback.print_exc()
|
||||||
|
rospy.logwarn('%s: exception occured', name)
|
||||||
|
return
|
||||||
|
if not failures:
|
||||||
|
rospy.loginfo('%s: OK', name)
|
||||||
|
return wrapper
|
||||||
|
return inner
|
||||||
|
|
||||||
|
|
||||||
|
@check('FCU')
|
||||||
def check_fcu():
|
def check_fcu():
|
||||||
try:
|
try:
|
||||||
state = rospy.wait_for_message('mavros/state', State, timeout=3)
|
state = rospy.wait_for_message('mavros/state', State, timeout=3)
|
||||||
if not state.connected:
|
if not state.connected:
|
||||||
raise Exception('No connection to the FCU')
|
failure('No connection to the FCU (check wiring)')
|
||||||
except rospy.ROSException:
|
except rospy.ROSException:
|
||||||
raise Exception('No MAVROS state')
|
failure('No MAVROS state (check wiring)')
|
||||||
|
|
||||||
|
|
||||||
|
@check('Camera')
|
||||||
def check_camera(name):
|
def check_camera(name):
|
||||||
try:
|
try:
|
||||||
rospy.wait_for_message(name + '/image_raw', Image, timeout=3)
|
img = rospy.wait_for_message(name + '/image_raw', Image, timeout=1)
|
||||||
except rospy.ROSException:
|
except rospy.ROSException:
|
||||||
raise Exception('No %s camera images' % name)
|
failure('%s: No images (is the camera connected properly?)', name)
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
rospy.wait_for_message(name + '/camera_info', CameraInfo, timeout=3)
|
info = rospy.wait_for_message(name + '/camera_info', CameraInfo, timeout=1)
|
||||||
except rospy.ROSException:
|
except rospy.ROSException:
|
||||||
raise Exception('No %s camera camera info' % name)
|
failure('%s: No calibration info', name)
|
||||||
|
return
|
||||||
|
|
||||||
|
if img.width != info.width:
|
||||||
|
failure('%s: Calibration width doesn\'t match image width (%d != %d)', name, info.width, img.width)
|
||||||
|
if img.height != info.height:
|
||||||
|
failure('%s: Calibration height doesn\'t match image height (%d != %d))', name, info.height, img.height)
|
||||||
|
|
||||||
|
|
||||||
|
@check('Aruco detector')
|
||||||
def check_aruco():
|
def check_aruco():
|
||||||
try:
|
try:
|
||||||
rospy.wait_for_message('aruco_pose/debug', Image, timeout=3)
|
rospy.wait_for_message('aruco_detect/markers', MarkerArray, timeout=0.5)
|
||||||
except rospy.ROSException:
|
except rospy.ROSException:
|
||||||
raise Exception('No aruco_pose/debug topic')
|
failure('No aruco markers detection')
|
||||||
|
|
||||||
|
|
||||||
|
@check('Visual position estimate')
|
||||||
|
def check_vpe():
|
||||||
|
try:
|
||||||
|
rospy.wait_for_message('mavros/vision_pose/pose', PoseStamped, timeout=1)
|
||||||
|
except rospy.ROSException:
|
||||||
|
try:
|
||||||
|
rospy.wait_for_message('mavros/mocap/pose', PoseStamped, timeout=1)
|
||||||
|
except rospy.ROSException:
|
||||||
|
failure('No VPE or MoCap messages')
|
||||||
|
|
||||||
|
|
||||||
|
@check('Simple offboard node')
|
||||||
def check_simpleoffboard():
|
def check_simpleoffboard():
|
||||||
try:
|
try:
|
||||||
rospy.wait_for_service('navigate', timeout=3)
|
rospy.wait_for_service('navigate', timeout=3)
|
||||||
rospy.wait_for_service('get_telemetry', timeout=3)
|
rospy.wait_for_service('get_telemetry', timeout=3)
|
||||||
rospy.wait_for_service('land', timeout=3)
|
rospy.wait_for_service('land', timeout=3)
|
||||||
except rospy.ROSException:
|
except rospy.ROSException:
|
||||||
raise Exception('No simple_offboard services')
|
failure('No simple_offboard services')
|
||||||
|
|
||||||
|
|
||||||
|
@check('IMU')
|
||||||
def check_imu():
|
def check_imu():
|
||||||
try:
|
try:
|
||||||
rospy.wait_for_message('mavros/imu/data', Imu, timeout=3)
|
rospy.wait_for_message('mavros/imu/data', Imu, timeout=1)
|
||||||
except rospy.ROSException:
|
except rospy.ROSException:
|
||||||
raise Exception('No IMU data')
|
failure('No IMU data (check flight controller calibration)')
|
||||||
|
|
||||||
|
|
||||||
|
@check('Local position')
|
||||||
def check_local_position():
|
def check_local_position():
|
||||||
try:
|
try:
|
||||||
rospy.wait_for_message('mavros/local_position/pose', PoseStamped, timeout=3)
|
rospy.wait_for_message('mavros/local_position/pose', PoseStamped, timeout=1)
|
||||||
except rospy.ROSException:
|
except rospy.ROSException:
|
||||||
raise Exception('No local position')
|
failure('No local position')
|
||||||
|
|
||||||
|
|
||||||
|
@check('Velocity estimation')
|
||||||
def check_velocity():
|
def check_velocity():
|
||||||
try:
|
try:
|
||||||
velocity = rospy.wait_for_message('mavros/local_position/velocity', TwistStamped, timeout=3)
|
velocity = rospy.wait_for_message('mavros/local_position/velocity', TwistStamped, timeout=1)
|
||||||
horiz = math.hypot(velocity.twist.linear.x, velocity.twist.linear.y)
|
horiz = math.hypot(velocity.twist.linear.x, velocity.twist.linear.y)
|
||||||
vert = velocity.twist.linear.z
|
vert = velocity.twist.linear.z
|
||||||
if abs(horiz) > 0.1:
|
if abs(horiz) > 0.1:
|
||||||
raise Exception('Horizontal velocity estimation is %s m/s; is the copter staying still?' % horiz)
|
failure('Horizontal velocity estimation is %.2f m/s; is copter staying still?' % horiz)
|
||||||
if abs(vert) > 0.1:
|
if abs(vert) > 0.1:
|
||||||
raise Exception('Vertical velocity estimation is %s m/s; is the copter staying still?' % vert)
|
failure('Vertical velocity estimation is %.2f m/s; is copter staying still?' % vert)
|
||||||
|
|
||||||
|
angular = velocity.twist.angular
|
||||||
|
ANGULAR_VELOCITY_LIMIT = 0.01
|
||||||
|
if abs(angular.x) > ANGULAR_VELOCITY_LIMIT:
|
||||||
|
failure('Pitch rate estimation is %.2f rad/s (%.2f deg/s); is copter staying still?',
|
||||||
|
angular.x, math.degrees(angular.x))
|
||||||
|
if abs(angular.y) > ANGULAR_VELOCITY_LIMIT:
|
||||||
|
failure('Pitch rate estimation is %.2f rad/s (%.2f deg/s); is copter staying still?',
|
||||||
|
angular.y, math.degrees(angular.y))
|
||||||
|
if abs(angular.z) > ANGULAR_VELOCITY_LIMIT:
|
||||||
|
failure('Pitch rate estimation is %.2f rad/s (%.2f deg/s); is copter staying still?',
|
||||||
|
angular.z, math.degrees(angular.z))
|
||||||
except rospy.ROSException:
|
except rospy.ROSException:
|
||||||
raise Exception('No velocity estimation')
|
failure('No velocity estimation')
|
||||||
|
|
||||||
|
|
||||||
|
@check('Global position (GPS)')
|
||||||
def check_global_position():
|
def check_global_position():
|
||||||
try:
|
try:
|
||||||
rospy.wait_for_message('mavros/global_position/global', PoseStamped, timeout=3)
|
rospy.wait_for_message('mavros/global_position/global', NavSatFix, timeout=1)
|
||||||
except rospy.ROSException:
|
except rospy.ROSException:
|
||||||
raise Exception('No global position')
|
failure('No global position')
|
||||||
|
|
||||||
|
|
||||||
def check(name, fn):
|
@check('Optical flow')
|
||||||
|
def check_optical_flow():
|
||||||
|
# TODO:check FPS!
|
||||||
try:
|
try:
|
||||||
fn()
|
rospy.wait_for_message('mavros/px4flow/raw/send', OpticalFlowRad, timeout=0.5)
|
||||||
rospy.loginfo('%s: OK', name)
|
except rospy.ROSException:
|
||||||
except BaseException as e:
|
failure('No optical flow data (from Raspberry)')
|
||||||
rospy.logwarn('%s: %s', name, str(e))
|
|
||||||
|
|
||||||
|
@check('Rangefinder')
|
||||||
|
def check_rangefinder():
|
||||||
|
# TODO: check FPS!
|
||||||
|
try:
|
||||||
|
rospy.wait_for_message('mavros/distance_sensor/rangefinder_3_sub', Range, timeout=0.5)
|
||||||
|
except rospy.ROSException:
|
||||||
|
failure('No randefinder data from Raspberry')
|
||||||
|
try:
|
||||||
|
rospy.wait_for_message('mavros/distance_sensor/rangefinder_0', Range, timeout=0.5)
|
||||||
|
except rospy.ROSException:
|
||||||
|
failure('No rangefinder data from PX4')
|
||||||
|
|
||||||
|
|
||||||
|
@check('Boot duration')
|
||||||
|
def check_boot_duration():
|
||||||
|
proc = Popen('systemd-analyze', stdout=PIPE)
|
||||||
|
proc.wait()
|
||||||
|
output = proc.communicate()[0]
|
||||||
|
r = re.compile(r'([\d\.]+)s$')
|
||||||
|
duration = float(r.search(output).groups()[0])
|
||||||
|
if duration > 15:
|
||||||
|
failure('long Raspbian boot duration: %ss (systemd-analyze for analyzing)', duration)
|
||||||
|
|
||||||
|
|
||||||
|
@check('CPU usage')
|
||||||
|
def check_cpu_usage():
|
||||||
|
WHITELIST = 'nodelet',
|
||||||
|
CMD = "top -n 1 -b -i | tail -n +8 | awk '{ printf(\"%-8s\\t%-8s\\t%-8s\\n\", $1, $9, $12); }'"
|
||||||
|
proc = Popen(CMD, stdout=PIPE, shell=True)
|
||||||
|
proc.wait()
|
||||||
|
output = proc.communicate()[0]
|
||||||
|
processes = output.split('\n')
|
||||||
|
for process in processes:
|
||||||
|
if not process:
|
||||||
|
continue
|
||||||
|
pid, cpu, cmd = process.split('\t')
|
||||||
|
|
||||||
|
if cmd.strip() not in WHITELIST and float(cpu) > 30:
|
||||||
|
failure('High CPU usage (%s%%) detected: %s (PID %s)',
|
||||||
|
cpu.strip(), cmd.strip(), pid.strip())
|
||||||
|
|
||||||
|
|
||||||
def selfcheck():
|
def selfcheck():
|
||||||
check('FCU', check_fcu)
|
check_fcu()
|
||||||
check('Simple offboard node', check_simpleoffboard)
|
check_imu()
|
||||||
check('Main camera node', lambda: check_camera('main_camera'))
|
check_local_position()
|
||||||
check('aruco_pose/debug topic', check_aruco)
|
check_velocity()
|
||||||
check('IMU data', check_imu)
|
check_global_position()
|
||||||
check('Local position', check_local_position)
|
check_camera('main_camera')
|
||||||
check('Velocity estimation', check_velocity)
|
check_aruco()
|
||||||
check('Global position (GPS)', check_global_position)
|
check_simpleoffboard()
|
||||||
|
check_optical_flow()
|
||||||
|
check_vpe()
|
||||||
|
check_rangefinder()
|
||||||
|
check_cpu_usage()
|
||||||
|
check_boot_duration()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -83,12 +83,13 @@ AUTO_ARM = AUTO_OFFBOARD and rospy.get_param('~auto_arm', True)
|
|||||||
OFFBOARD_TIMEOUT = rospy.Duration(rospy.get_param('~offboard_timeout', 3))
|
OFFBOARD_TIMEOUT = rospy.Duration(rospy.get_param('~offboard_timeout', 3))
|
||||||
ARM_TIMEOUT = rospy.Duration(rospy.get_param('~arm_timeout', 5))
|
ARM_TIMEOUT = rospy.Duration(rospy.get_param('~arm_timeout', 5))
|
||||||
LOCAL_POSITION_TIMEOUT = rospy.Duration(rospy.get_param('~local_position_timeout', 0.5))
|
LOCAL_POSITION_TIMEOUT = rospy.Duration(rospy.get_param('~local_position_timeout', 0.5))
|
||||||
NAVIGATE_AFTER_ARMED = rospy.Duration(rospy.get_param('~navigate_after_armed', False))
|
NAVIGATE_AFTER_ARMED = rospy.Duration(rospy.get_param('~navigate_after_armed', True))
|
||||||
TRANSFORM_TIMEOUT = rospy.Duration(rospy.get_param('~transform_timeout', 3))
|
TRANSFORM_TIMEOUT = rospy.Duration(rospy.get_param('~transform_timeout', 3))
|
||||||
SETPOINT_RATE = rospy.get_param('~setpoint_rate', 30)
|
SETPOINT_RATE = rospy.get_param('~setpoint_rate', 30)
|
||||||
LOCAL_FRAME = rospy.get_param('~local_frame', 'local_origin')
|
LOCAL_FRAME = rospy.get_param('mavros/local_position/frame_id', 'local_origin')
|
||||||
LAND_MODE = rospy.get_param('~land_mode', 'AUTO.LAND')
|
LAND_MODE = rospy.get_param('~land_mode', 'AUTO.LAND')
|
||||||
LAND_TIMEOUT = rospy.Duration(rospy.get_param('~land_timeout', 2))
|
LAND_TIMEOUT = rospy.Duration(rospy.get_param('~land_timeout', 2))
|
||||||
|
DEFAULT_SPEED = rospy.get_param('~default_speed', 0.5)
|
||||||
|
|
||||||
|
|
||||||
def offboard_and_arm():
|
def offboard_and_arm():
|
||||||
@@ -120,6 +121,8 @@ def offboard_and_arm():
|
|||||||
|
|
||||||
ps = PoseStamped()
|
ps = PoseStamped()
|
||||||
vs = Vector3Stamped()
|
vs = Vector3Stamped()
|
||||||
|
pt = PositionTarget()
|
||||||
|
at = AttitudeTarget()
|
||||||
|
|
||||||
|
|
||||||
BRAKE_TIME = rospy.Duration(0)
|
BRAKE_TIME = rospy.Duration(0)
|
||||||
@@ -128,7 +131,10 @@ BRAKE_TIME = rospy.Duration(0)
|
|||||||
def get_navigate_setpoint(stamp, start, finish, start_stamp, speed):
|
def get_navigate_setpoint(stamp, start, finish, start_stamp, speed):
|
||||||
distance = math.sqrt((finish.z - start.z)**2 + (finish.x - start.x)**2 + (finish.y - start.y)**2)
|
distance = math.sqrt((finish.z - start.z)**2 + (finish.x - start.x)**2 + (finish.y - start.y)**2)
|
||||||
time = rospy.Duration(distance / speed)
|
time = rospy.Duration(distance / speed)
|
||||||
k = (stamp - start_stamp) / time
|
if time == rospy.Duration(0):
|
||||||
|
k = 0
|
||||||
|
else:
|
||||||
|
k = (stamp - start_stamp) / time
|
||||||
time_left = start_stamp + time - stamp
|
time_left = start_stamp + time - stamp
|
||||||
|
|
||||||
if BRAKE_TIME and time_left < BRAKE_TIME:
|
if BRAKE_TIME and time_left < BRAKE_TIME:
|
||||||
@@ -158,14 +164,17 @@ def get_publisher_and_message(req, stamp, continued=True, update_frame=True):
|
|||||||
ps.header.stamp = stamp
|
ps.header.stamp = stamp
|
||||||
vs.header.stamp = stamp
|
vs.header.stamp = stamp
|
||||||
|
|
||||||
|
# don't block on setpoints publishing
|
||||||
|
transform_timeout = rospy.Duration(0.1) if continued else TRANSFORM_TIMEOUT
|
||||||
|
|
||||||
if isinstance(req, (srv.NavigateRequest, srv.NavigateGlobalRequest)):
|
if isinstance(req, (srv.NavigateRequest, srv.NavigateGlobalRequest)):
|
||||||
global current_nav_start, current_nav_start_stamp, current_nav_finish
|
global current_nav_start, current_nav_start_stamp, current_nav_finish
|
||||||
|
|
||||||
if update_frame:
|
if update_frame:
|
||||||
ps.header.frame_id = req.frame_id or LOCAL_FRAME
|
ps.header.frame_id = req.frame_id or LOCAL_FRAME
|
||||||
ps.pose.position = Point(getattr(req, 'x', 0), getattr(req, 'y', 0), req.z)
|
ps.pose.position = Point(getattr(req, 'x', 0), getattr(req, 'y', 0), req.z)
|
||||||
ps.pose.orientation = orientation_from_euler(0, 0, req.yaw)
|
ps.pose.orientation = orientation_from_euler(0, 0, req.yaw, axes='sxyz')
|
||||||
current_nav_finish = tf_buffer.transform(ps, LOCAL_FRAME, TRANSFORM_TIMEOUT)
|
current_nav_finish = tf_buffer.transform(ps, LOCAL_FRAME, transform_timeout)
|
||||||
|
|
||||||
if isinstance(req, srv.NavigateGlobalRequest):
|
if isinstance(req, srv.NavigateGlobalRequest):
|
||||||
# Recalculate x and y from lat and lon
|
# Recalculate x and y from lat and lon
|
||||||
@@ -183,32 +192,34 @@ def get_publisher_and_message(req, stamp, continued=True, update_frame=True):
|
|||||||
current_nav_start_stamp, req.speed)
|
current_nav_start_stamp, req.speed)
|
||||||
|
|
||||||
yaw_rate_flag = math.isnan(req.yaw)
|
yaw_rate_flag = math.isnan(req.yaw)
|
||||||
msg = PositionTarget(coordinate_frame=PT.FRAME_LOCAL_NED,
|
msg = pt
|
||||||
type_mask=PT.IGNORE_VX + PT.IGNORE_VY + PT.IGNORE_VZ +
|
msg.coordinate_frame = PT.FRAME_LOCAL_NED
|
||||||
PT.IGNORE_AFX + PT.IGNORE_AFY + PT.IGNORE_AFZ +
|
msg.type_mask = PT.IGNORE_VX + PT.IGNORE_VY + PT.IGNORE_VZ + \
|
||||||
(PT.IGNORE_YAW if yaw_rate_flag else PT.IGNORE_YAW_RATE),
|
PT.IGNORE_AFX + PT.IGNORE_AFY + PT.IGNORE_AFZ + \
|
||||||
position=setpoint,
|
(PT.IGNORE_YAW if yaw_rate_flag else PT.IGNORE_YAW_RATE)
|
||||||
yaw=euler_from_orientation(current_nav_finish.pose.orientation, 'szyx')[2] - math.pi / 2,
|
msg.position = setpoint
|
||||||
yaw_rate=req.yaw_rate)
|
msg.yaw = euler_from_orientation(current_nav_finish.pose.orientation, 'sxyz')[2]
|
||||||
|
msg.yaw_rate = req.yaw_rate
|
||||||
return position_pub, msg
|
return position_pub, msg
|
||||||
|
|
||||||
elif isinstance(req, (srv.SetPositionRequest, srv.SetPositionGlobalRequest)):
|
elif isinstance(req, (srv.SetPositionRequest, srv.SetPositionGlobalRequest)):
|
||||||
ps.header.frame_id = req.frame_id or LOCAL_FRAME
|
ps.header.frame_id = req.frame_id or LOCAL_FRAME
|
||||||
ps.pose.position = Point(getattr(req, 'x', 0), getattr(req, 'y', 0), req.z)
|
ps.pose.position = Point(getattr(req, 'x', 0), getattr(req, 'y', 0), req.z)
|
||||||
ps.pose.orientation = orientation_from_euler(0, 0, req.yaw)
|
ps.pose.orientation = orientation_from_euler(0, 0, req.yaw)
|
||||||
pose_local = tf_buffer.transform(ps, LOCAL_FRAME, TRANSFORM_TIMEOUT)
|
pose_local = tf_buffer.transform(ps, LOCAL_FRAME, transform_timeout)
|
||||||
|
|
||||||
if isinstance(req, srv.SetPositionGlobalRequest):
|
if isinstance(req, srv.SetPositionGlobalRequest):
|
||||||
pose_local.pose.position.x, pose_local.pose.position.y = global_to_local(req.lat, req.lon)
|
pose_local.pose.position.x, pose_local.pose.position.y = global_to_local(req.lat, req.lon)
|
||||||
|
|
||||||
yaw_rate_flag = math.isnan(req.yaw)
|
yaw_rate_flag = math.isnan(req.yaw)
|
||||||
msg = PositionTarget(coordinate_frame=PT.FRAME_LOCAL_NED,
|
msg = pt
|
||||||
type_mask=PT.IGNORE_VX + PT.IGNORE_VY + PT.IGNORE_VZ +
|
msg.coordinate_frame = PT.FRAME_LOCAL_NED
|
||||||
PT.IGNORE_AFX + PT.IGNORE_AFY + PT.IGNORE_AFZ +
|
msg.type_mask = PT.IGNORE_VX + PT.IGNORE_VY + PT.IGNORE_VZ + \
|
||||||
(PT.IGNORE_YAW if yaw_rate_flag else PT.IGNORE_YAW_RATE),
|
PT.IGNORE_AFX + PT.IGNORE_AFY + PT.IGNORE_AFZ + \
|
||||||
position=pose_local.pose.position,
|
(PT.IGNORE_YAW if yaw_rate_flag else PT.IGNORE_YAW_RATE)
|
||||||
yaw=euler_from_orientation(pose_local.pose.orientation, 'szyx')[2] - math.pi / 2,
|
msg.position = pose_local.pose.position
|
||||||
yaw_rate=req.yaw_rate)
|
msg.yaw = euler_from_orientation(pose_local.pose.orientation, 'sxyz')[2]
|
||||||
|
msg.yaw_rate = req.yaw_rate
|
||||||
return position_pub, msg
|
return position_pub, msg
|
||||||
|
|
||||||
elif isinstance(req, srv.SetVelocityRequest):
|
elif isinstance(req, srv.SetVelocityRequest):
|
||||||
@@ -216,32 +227,37 @@ def get_publisher_and_message(req, stamp, continued=True, update_frame=True):
|
|||||||
vs.header.frame_id = req.frame_id or LOCAL_FRAME
|
vs.header.frame_id = req.frame_id or LOCAL_FRAME
|
||||||
ps.header.frame_id = req.frame_id or LOCAL_FRAME
|
ps.header.frame_id = req.frame_id or LOCAL_FRAME
|
||||||
ps.pose.orientation = orientation_from_euler(0, 0, req.yaw)
|
ps.pose.orientation = orientation_from_euler(0, 0, req.yaw)
|
||||||
pose_local = tf_buffer.transform(ps, LOCAL_FRAME, TRANSFORM_TIMEOUT)
|
pose_local = tf_buffer.transform(ps, LOCAL_FRAME, transform_timeout)
|
||||||
vector_local = tf_buffer.transform(vs, LOCAL_FRAME, TRANSFORM_TIMEOUT)
|
vector_local = tf_buffer.transform(vs, LOCAL_FRAME, transform_timeout)
|
||||||
|
|
||||||
yaw_rate_flag = math.isnan(req.yaw)
|
yaw_rate_flag = math.isnan(req.yaw)
|
||||||
msg = PositionTarget(coordinate_frame=PT.FRAME_LOCAL_NED,
|
msg = pt
|
||||||
type_mask=PT.IGNORE_PX + PT.IGNORE_PY + PT.IGNORE_PZ +
|
msg.coordinate_frame = PT.FRAME_LOCAL_NED
|
||||||
PT.IGNORE_AFX + PT.IGNORE_AFY + PT.IGNORE_AFZ +
|
msg.type_mask = PT.IGNORE_PX + PT.IGNORE_PY + PT.IGNORE_PZ + \
|
||||||
(PT.IGNORE_YAW if yaw_rate_flag else PT.IGNORE_YAW_RATE),
|
PT.IGNORE_AFX + PT.IGNORE_AFY + PT.IGNORE_AFZ + \
|
||||||
velocity=vector_local.vector,
|
(PT.IGNORE_YAW if yaw_rate_flag else PT.IGNORE_YAW_RATE)
|
||||||
yaw=euler_from_orientation(pose_local.pose.orientation, 'szyx')[2] - math.pi / 2,
|
msg.velocity = vector_local.vector
|
||||||
yaw_rate=req.yaw_rate)
|
msg.yaw = euler_from_orientation(pose_local.pose.orientation, 'sxyz')[2]
|
||||||
|
msg.yaw_rate = req.yaw_rate
|
||||||
return position_pub, msg
|
return position_pub, msg
|
||||||
|
|
||||||
elif isinstance(req, srv.SetAttitudeRequest):
|
elif isinstance(req, srv.SetAttitudeRequest):
|
||||||
ps.header.frame_id = req.frame_id or LOCAL_FRAME
|
ps.header.frame_id = req.frame_id or LOCAL_FRAME
|
||||||
ps.pose.orientation = orientation_from_euler(req.roll, req.pitch, req.yaw)
|
ps.pose.orientation = orientation_from_euler(req.roll, req.pitch, req.yaw)
|
||||||
pose_local = tf_buffer.transform(ps, LOCAL_FRAME, TRANSFORM_TIMEOUT)
|
pose_local = tf_buffer.transform(ps, LOCAL_FRAME, transform_timeout)
|
||||||
msg = AttitudeTarget(orientation=pose_local.pose.orientation,
|
msg = at
|
||||||
thrust=req.thrust,
|
msg.orientation = pose_local.pose.orientation
|
||||||
type_mask=AT.IGNORE_YAW_RATE + AT.IGNORE_PITCH_RATE + AT.IGNORE_ROLL_RATE)
|
msg.thrust = req.thrust
|
||||||
|
msg.type_mask = AT.IGNORE_YAW_RATE + AT.IGNORE_PITCH_RATE + AT.IGNORE_ROLL_RATE
|
||||||
return attitude_pub, msg
|
return attitude_pub, msg
|
||||||
|
|
||||||
elif isinstance(req, srv.SetRatesRequest):
|
elif isinstance(req, srv.SetRatesRequest):
|
||||||
msg = AttitudeTarget(thrust=req.thrust,
|
msg = at
|
||||||
type_mask=AttitudeTarget.IGNORE_ATTITUDE,
|
msg.thrust = req.thrust
|
||||||
body_rate=Vector3(req.roll_rate, req.pitch_rate, req.yaw_rate))
|
msg.type_mask = AT.IGNORE_ATTITUDE
|
||||||
|
msg.body_rate.x = req.roll_rate
|
||||||
|
msg.body_rate.y = req.pitch_rate
|
||||||
|
msg.body_rate.z = req.yaw_rate
|
||||||
return attitude_pub, msg
|
return attitude_pub, msg
|
||||||
|
|
||||||
|
|
||||||
@@ -261,9 +277,12 @@ def handle(req):
|
|||||||
rospy.logwarn('No connection to the FCU')
|
rospy.logwarn('No connection to the FCU')
|
||||||
return {'message': 'No connection to the FCU'}
|
return {'message': 'No connection to the FCU'}
|
||||||
|
|
||||||
if isinstance(req, (srv.NavigateRequest, srv.NavigateGlobalRequest)) and req.speed <= 0:
|
if isinstance(req, (srv.NavigateRequest, srv.NavigateGlobalRequest)):
|
||||||
rospy.logwarn('Navigate speed must be greater than zero, %s passed')
|
if req.speed < 0:
|
||||||
return {'message': 'Navigate speed must be greater than zero, %s passed' % req.speed}
|
rospy.logwarn('Navigate speed must be positive, %s passed')
|
||||||
|
return {'message': 'Navigate speed must be positive, %s passed' % req.speed}
|
||||||
|
elif req.speed == 0:
|
||||||
|
req.speed = DEFAULT_SPEED
|
||||||
|
|
||||||
if isinstance(req, (srv.NavigateRequest, srv.NavigateGlobalRequest)) and \
|
if isinstance(req, (srv.NavigateRequest, srv.NavigateGlobalRequest)) and \
|
||||||
(pose is None or rospy.get_rostime() - pose.header.stamp > LOCAL_POSITION_TIMEOUT):
|
(pose is None or rospy.get_rostime() - pose.header.stamp > LOCAL_POSITION_TIMEOUT):
|
||||||
@@ -279,14 +298,19 @@ def handle(req):
|
|||||||
return {'message': 'Both yaw and yaw_rate cannot be NaN'}
|
return {'message': 'Both yaw and yaw_rate cannot be NaN'}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with handle_lock:
|
# check frame_id existance
|
||||||
stamp = rospy.get_rostime()
|
# (for non-blocking setpoint's publishing in get_publisher_and_message)
|
||||||
current_req = req
|
stamp = rospy.get_rostime()
|
||||||
current_pub, current_msg = get_publisher_and_message(req, stamp, False)
|
if hasattr(req, 'frame_id'):
|
||||||
rospy.loginfo('Topic: %s, message: %s', current_pub.name, current_msg)
|
tf_buffer.lookup_transform(req.frame_id or LOCAL_FRAME, LOCAL_FRAME, stamp, TRANSFORM_TIMEOUT)
|
||||||
|
|
||||||
current_msg.header.stamp = stamp
|
with handle_lock:
|
||||||
current_pub.publish(current_msg)
|
current_req = req
|
||||||
|
current_pub, current_msg = get_publisher_and_message(req, stamp, False)
|
||||||
|
rospy.loginfo('Topic: %s, message: %s', current_pub.name, current_msg)
|
||||||
|
|
||||||
|
current_msg.header.stamp = stamp
|
||||||
|
current_pub.publish(current_msg)
|
||||||
|
|
||||||
if req.auto_arm:
|
if req.auto_arm:
|
||||||
offboard_and_arm()
|
offboard_and_arm()
|
||||||
@@ -364,24 +388,31 @@ def get_telemetry(req):
|
|||||||
frame_id = req.frame_id or LOCAL_FRAME
|
frame_id = req.frame_id or LOCAL_FRAME
|
||||||
stamp = rospy.get_rostime()
|
stamp = rospy.get_rostime()
|
||||||
|
|
||||||
if pose:
|
transform_timeout = rospy.Duration(0.4)
|
||||||
p = tf_buffer.transform(pose, frame_id, TRANSFORM_TIMEOUT)
|
try:
|
||||||
res['x'] = p.pose.position.x
|
if pose:
|
||||||
res['y'] = p.pose.position.y
|
p = tf_buffer.transform(pose, frame_id, transform_timeout)
|
||||||
res['z'] = p.pose.position.z
|
res['x'] = p.pose.position.x
|
||||||
|
res['y'] = p.pose.position.y
|
||||||
|
res['z'] = p.pose.position.z
|
||||||
|
|
||||||
# Calculate roll pitch and yaw as Tait-Bryan angles, order z-y-x
|
# Calculate roll pitch and yaw as Tait-Bryan angles, order z-y-x
|
||||||
res['yaw'], res['pitch'], res['roll'] = euler_from_orientation(p.pose.orientation, axes='rzyx')
|
res['yaw'], res['pitch'], res['roll'] = euler_from_orientation(p.pose.orientation, axes='rzyx')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
if velocity:
|
if velocity:
|
||||||
v = Vector3Stamped()
|
try:
|
||||||
v.header.stamp = velocity.header.stamp
|
v = Vector3Stamped()
|
||||||
v.header.frame_id = velocity.header.frame_id
|
v.header.stamp = velocity.header.stamp
|
||||||
v.vector = velocity.twist.linear
|
v.header.frame_id = velocity.header.frame_id
|
||||||
linear = tf_buffer.transform(v, frame_id, TRANSFORM_TIMEOUT)
|
v.vector = velocity.twist.linear
|
||||||
res['vx'] = linear.vector.x
|
linear = tf_buffer.transform(v, frame_id, transform_timeout)
|
||||||
res['vy'] = linear.vector.y
|
res['vx'] = linear.vector.x
|
||||||
res['vz'] = linear.vector.z
|
res['vy'] = linear.vector.y
|
||||||
|
res['vz'] = linear.vector.z
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
res['yaw_rate'] = velocity.twist.angular.z
|
res['yaw_rate'] = velocity.twist.angular.z
|
||||||
res['pitch_rate'] = velocity.twist.angular.y
|
res['pitch_rate'] = velocity.twist.angular.y
|
||||||
@@ -428,21 +459,21 @@ def start_loop():
|
|||||||
current_pub, current_msg = get_publisher_and_message(current_req, stamp, True,
|
current_pub, current_msg = get_publisher_and_message(current_req, stamp, True,
|
||||||
getattr(current_req, 'update_frame', False))
|
getattr(current_req, 'update_frame', False))
|
||||||
|
|
||||||
current_msg.header.stamp = stamp
|
|
||||||
current_pub.publish(current_msg)
|
|
||||||
|
|
||||||
# For monitoring
|
|
||||||
if isinstance(current_msg, PositionTarget):
|
|
||||||
p = PoseStamped()
|
|
||||||
p.header.frame_id = LOCAL_FRAME
|
|
||||||
p.header.stamp = stamp
|
|
||||||
p.pose.position = current_msg.position
|
|
||||||
p.pose.orientation = orientation_from_euler(0, 0, current_msg.yaw + math.pi / 2)
|
|
||||||
target_pub.publish(p)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
rospy.logwarn_throttle(10, str(e))
|
rospy.logwarn_throttle(10, str(e))
|
||||||
|
|
||||||
|
current_msg.header.stamp = stamp
|
||||||
|
current_pub.publish(current_msg)
|
||||||
|
|
||||||
|
# For monitoring
|
||||||
|
if isinstance(current_msg, PositionTarget):
|
||||||
|
p = PoseStamped()
|
||||||
|
p.header.frame_id = LOCAL_FRAME
|
||||||
|
p.header.stamp = stamp
|
||||||
|
p.pose.position = current_msg.position
|
||||||
|
p.pose.orientation = orientation_from_euler(0, 0, current_msg.yaw)
|
||||||
|
target_pub.publish(p)
|
||||||
|
|
||||||
r.sleep()
|
r.sleep()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
36
clever/src/utils.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
// TODO: merge with util.h
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <ros/ros.h>
|
||||||
|
#include <geometry_msgs/Vector3.h>
|
||||||
|
#include <geometry_msgs/Point.h>
|
||||||
|
|
||||||
|
// Read required param or shutdown the node
|
||||||
|
template<typename T>
|
||||||
|
static void param(ros::NodeHandle nh, const std::string& param_name, T& param_val)
|
||||||
|
{
|
||||||
|
if (!nh.getParam(param_name, param_val)) {
|
||||||
|
ROS_FATAL("Required param %s is not defined", param_name);
|
||||||
|
ros::shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double hypot(double x, double y, double z)
|
||||||
|
{
|
||||||
|
return std::sqrt(x*x + y*y + z*z);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void vectorToPoint(const geometry_msgs::Vector3& vector, geometry_msgs::Point& point)
|
||||||
|
{
|
||||||
|
point.x = vector.x;
|
||||||
|
point.y = vector.y;
|
||||||
|
point.z = vector.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void pointToVector(const geometry_msgs::Point& point, geometry_msgs::Vector3& vector)
|
||||||
|
{
|
||||||
|
vector.x = point.x;
|
||||||
|
vector.y = point.y;
|
||||||
|
vector.z = point.z;
|
||||||
|
}
|
||||||