Implement block programming (using Blockly) (#272)
* Clover Blockly: add first blocks set * Adjust Blockly settings * Fix get_position output type * Add screenshot * Rename readme.md to README.md * Resize screenshot * Add package.xml * Little change * Fixes * Add python_compressed to blockly * Implement some of the Clover blocks in Python * Make Python indentation 4 spaces * Fixes to Python blocks implementation * Implement set_velocity block in Python * Implement wait_arrival block in Python * Fix indentation in Python implementation of blocks * Fix * Fix land_wait template * Set reserved words in Python * Change default frame_id to aruco_map in get_position block * Fix * Move blocks definitions to blocks.js * Get rid of missing favicon error * Simplify navigate * Rearrange layout, add tabs * Generate Python code * Small style change * -console.log * Code style * Use modules * Move modules to the header * Correct order for ROS definitions + generating "backend" code * Fix rangefinder_distance block * simple_offboard: commands to change only yaw and yaw rate * Implement set_yaw block * Start working on Blockly documentation * Implement print block with a topic * Unneeded code * Little fixes * Fix indentation * Fixes * Fix wait_arival, get_distance * Implement running Blockly programs, implement prompt block, fixes * Add land button * Little change * Fix reserved words + little fixes * +x for main.py * Simplify run button * Auto-save and load workspace * Make land button work * Handle exceptions * Minor change * Add help URL for blocks * Fix * Implement arrived block * Mark blockly and highlight.js as linguist-vendored * Add forgotten CMakeLists.txt * Add wait checkbox to set_yaw block * Disable run button when disconnected * Add message and service files * Add some comments * Add tooltip to some blocks * Implement GPIO blocks * Don’t latch print message to prevent duplication * Prevent duplication prompts * Add ROS init code to backend code anyways * Make GPIO blocks color a constant * Minor fix * More correctly update blocks on input value changes * Minor fixes * Remove unneeded readonly attribute * Add marker ID shadow blocks to toolbox * Add lacking reserved words * Fix frame id generation for complex marker id expressions * Consider frame_id in set_yaw block * Shorten ros module import * Implement stop service * Disable and enable run button correctly * Don’t print KeyboardInterrupt exceptions * Put notifications to notifications element * Add 'running' mark * Disable signal in backend python code * Sleep a little bit to let rospy initialize publishers * Remove accidental code * Make ROS namespace and private namespace constants * editorconfig-lint: don’t check Blockly code * Use private namespace constant in Python generator * Implement ~running topic to display current program status more robustly * Make navigate tolerance and sleep time constants * Make set_leds and and set_effect services proxies persistent * Replace a number with constant * Limit ~block topic publishing rate Otherwise messages get queued making the frontend to freeze * Improve internal documentation * Append 'map' to frames list * Return degrees in get_attitude block * Move getting yaw in a separate block * Improve block tooltips * Add some more files to editorconfig-lint excludes * Add get_yaw block to toolbox * Implement get_time block * Implement ~store and ~load services for storing user programs * Set auto_arm only in take_off block * Minor CSS fixes * Make 'Python' tab textarea-like * Implement saving and loading programs * Adjust styles * Retrieve only .xml files in load service * Forgotten code * Documentation on store and load services * Add some examples * Add blocks programming arg to launch file * Update docs * Add package’s dependencies * Add dependency * Add title to select * Fix syntax * Minor fix in docs * Add forgotten roslib.js * Run user program in the same process * Use print function for print block in Python 2 * Add variables example * Fix url * Add functions example * Fix set_servo block * Fix gpio_read block * Update blocks screenshot * Update docs * Update docs * Fix set_effect block * Minor fix in example * Add setpoint block, remove set_velocity from toolbox * Remove unused modules * Unused variable * Add English article skeleton * Clarify backend node link error * Remove unused variable * Update documentation * Fix link to documentation * Add Blockly logo * Update English article * Add Blocks programming link to the main page * Minor change * Add catkin_install_python to CMakeLists.txt * Make navigate tolerance and sleep time configurable * Add minor todo * Add blockly examples directory to editorconfig-lint excludes * Rename main node to clover_blocks * Add a warning to the old blocks programming article * Fix editorconfig-lint exclude
209
docs/assets/blocks/blockly.svg
Normal file
@@ -0,0 +1,209 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="104.11897mm"
|
||||
height="87.369049mm"
|
||||
viewBox="0 0 104.11897 87.369049"
|
||||
version="1.1"
|
||||
id="svg1512"
|
||||
inkscape:version="0.92.2pre0 (973e216, 2017-07-25)"
|
||||
sodipodi:docname="logo_vertical.svg"
|
||||
inkscape:export-filename="/usr/local/google/home/epastern/Documents/Blockly Logos/Square/logo_standard.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96">
|
||||
<defs
|
||||
id="defs1506">
|
||||
<clipPath
|
||||
id="clipPath5790"
|
||||
clipPathUnits="userSpaceOnUse">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5788"
|
||||
d="M 0,35 H 126 V 0 H 0 Z" />
|
||||
</clipPath>
|
||||
<clipPath
|
||||
id="clipPath5802"
|
||||
clipPathUnits="userSpaceOnUse">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5800"
|
||||
d="M 0,35 H 126 V 0 H 0 Z" />
|
||||
</clipPath>
|
||||
<clipPath
|
||||
id="clipPath5812"
|
||||
clipPathUnits="userSpaceOnUse">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5810"
|
||||
d="M -1.52588e-4,192 H 192 V -1.83105e-4 H -1.52588e-4 Z" />
|
||||
</clipPath>
|
||||
<clipPath
|
||||
id="clipPath5820"
|
||||
clipPathUnits="userSpaceOnUse">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5818"
|
||||
d="M -1.52588e-4,192 H 192 V -1.83105e-4 H -1.52588e-4 Z" />
|
||||
</clipPath>
|
||||
<clipPath
|
||||
id="clipPath5824"
|
||||
clipPathUnits="userSpaceOnUse">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5822"
|
||||
d="M 0,192 H 192 V 0 H 0 Z" />
|
||||
</clipPath>
|
||||
<clipPath
|
||||
id="clipPath5828"
|
||||
clipPathUnits="userSpaceOnUse">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5826"
|
||||
d="M 0,192 H 192 V 0 H 0 Z" />
|
||||
</clipPath>
|
||||
<clipPath
|
||||
id="clipPath5832"
|
||||
clipPathUnits="userSpaceOnUse">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5830"
|
||||
d="M 0,192 H 192 V 0 H 0 Z" />
|
||||
</clipPath>
|
||||
<linearGradient
|
||||
id="linearGradient-1"
|
||||
y2="0.92900556"
|
||||
x2="1.0082812"
|
||||
y1="0.17021771"
|
||||
x1="-0.034921873">
|
||||
<stop
|
||||
id="stop6067"
|
||||
offset="0%"
|
||||
stop-opacity="0.1"
|
||||
stop-color="#FFFFFF" />
|
||||
<stop
|
||||
id="stop6069"
|
||||
offset="14%"
|
||||
stop-opacity="0.08"
|
||||
stop-color="#FFFFFF" />
|
||||
<stop
|
||||
id="stop6071"
|
||||
offset="61%"
|
||||
stop-opacity="0.02"
|
||||
stop-color="#FFFFFF" />
|
||||
<stop
|
||||
id="stop6073"
|
||||
offset="100%"
|
||||
stop-opacity="0"
|
||||
stop-color="#FFFFFF" />
|
||||
</linearGradient>
|
||||
<path
|
||||
id="path-2"
|
||||
d="M 82.97724,29.300104 C 82.790583,28.201973 82.006921,27.299698 80.945743,26.961124 79.884564,26.62255 78.723152,26.904241 77.935,27.691354 L 62.465677,43.197917 50.303229,20.042344 C 49.78815,19.063276 48.772957,18.45025 47.666667,18.45025 c -1.106291,0 -2.121484,0.613026 -2.636563,1.592094 L 38.379115,32.703802 21.695781,1.5864062 C 21.090714,0.45617231 19.83044,-0.16023716 18.566804,0.05600004 17.303168,0.27223724 16.319565,1.2726256 16.12474,2.5397396 L 0,105.76042 43.123438,129.93635 c 2.707936,1.51195 6.006125,1.51195 8.714062,0 l 43.495833,-24.17593 z"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path-4"
|
||||
d="m 106.68711,35.274174 c -0.186,-1.097652 -0.96693,-1.999535 -2.02439,-2.337961 -1.05747,-0.338426 -2.21482,-0.05686 -3.00022,0.729912 L 86.247266,49.165925 74.127344,26.020451 C 73.614066,25.04181 72.602423,24.429052 71.5,24.429052 c -1.102423,0 -2.114066,0.612758 -2.627344,1.591399 L 62.244922,38.676387 45.619922,7.5725628 C 45.01697,6.4428218 43.761103,5.8266812 42.501885,6.0428241 41.242667,6.258967 40.262504,7.2589191 40.068359,8.5254804 L 24,111.70114 66.972656,135.86653 c 2.698469,1.51129 5.985125,1.51129 8.683594,0 L 119,111.70114 Z"
|
||||
inkscape:connector-curvature="0" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.4"
|
||||
inkscape:cx="174.07912"
|
||||
inkscape:cy="254.2021"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:measure-start="215.162,827.567"
|
||||
inkscape:measure-end="164.907,827.567"
|
||||
fit-margin-top="10"
|
||||
fit-margin-right="10"
|
||||
fit-margin-bottom="10"
|
||||
fit-margin-left="10"
|
||||
inkscape:window-width="1619"
|
||||
inkscape:window-height="1119"
|
||||
inkscape:window-x="654"
|
||||
inkscape:window-y="124"
|
||||
inkscape:window-maximized="0" />
|
||||
<metadata
|
||||
id="metadata1509">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(20.298455,-51.769323)">
|
||||
<g
|
||||
id="g6939"
|
||||
transform="translate(5.3026997)"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96">
|
||||
<path
|
||||
sodipodi:nodetypes="ccccccccssccc"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#4285f4;stroke-width:0.26458332"
|
||||
d="m 12.604934,61.770873 c -1.774567,-0.0015 -3.2136701,1.43764 -3.2122066,3.212207 v 27.706838 c -0.00146,1.774568 1.4376396,3.213669 3.2122066,3.212205 h 1.25057 c 0.616698,2.31294 2.710855,3.922673 5.104598,3.923792 2.392205,-0.003 4.484163,-1.612336 5.100464,-3.923792 h 1.281058 4.160987 c 1.169002,0 2.116666,-0.947663 2.116666,-2.116666 V 63.88754 l -2.116666,-2.116667 z"
|
||||
id="path906" />
|
||||
<path
|
||||
style="fill:#c8d1db;stroke-width:0.26458332"
|
||||
d="m 28.444794,61.769323 c -0.0028,4.683852 -0.0021,9.366881 -0.0021,14.053406 l -4.400251,-2.48667 c -0.634301,-0.357915 -1.419291,0.09954 -1.420585,0.827856 V 84.91158 c 0.0013,0.728311 0.786285,1.18577 1.420585,0.827855 l 4.400248,-2.487186 v 9.946164 0.587044 2.116666 h 2.116667 0.377238 9.539468 c 1.683266,-6.8e-5 3.047807,-1.364609 3.047876,-3.047875 V 64.808414 c -0.0057,-1.679229 -1.368601,-3.037482 -3.04784,-3.037541 z"
|
||||
id="path908"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccccccccccccccc" />
|
||||
</g>
|
||||
<g
|
||||
aria-label="Blockly"
|
||||
style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
|
||||
id="text5967">
|
||||
<path
|
||||
d="m -10.298455,123.04237 v -20.20711 h 7.3095554 q 2.37066664,0 4.0922221,1.58045 1.7497778,1.55222 1.7497778,3.92289 0,1.43933 -0.762,2.54 -0.7337778,1.10066 -1.9755555,1.66511 v 0.11289 q 1.4957777,0.508 2.4553333,1.74977 0.9595555,1.24178 0.9595555,2.87867 0,2.48356 -1.8344444,4.12044 -1.80622217,1.63689 -4.2897777,1.63689 z m 2.5964445,-11.54288 h 4.7131109 q 1.4675556,0 2.34244442,-0.95956 0.90311109,-0.98778 0.90311109,-2.14489 0,-1.15711 -0.87488887,-2.11667 -0.84666664,-0.95955 -2.25777774,-0.95955 h -4.8259998 z m 0,9.05933 h 5.2211109 q 1.49577777,0 2.42711107,-1.04422 0.93133331,-1.04423 0.93133331,-2.286 0,-1.24178 -0.95955553,-2.25778 -0.95955555,-1.04422 -2.51177775,-1.04422 h -5.108222 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:28.22222137px;font-family:'Product Sans';-inkscape-font-specification:'Product Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#5f6368;fill-opacity:1;stroke-width:0.26458332"
|
||||
id="path9798" />
|
||||
<path
|
||||
d="M 8.6033786,123.04237 H 6.0069342 v -20.20711 h 2.5964444 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:28.22222137px;font-family:'Product Sans';-inkscape-font-specification:'Product Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#5f6368;fill-opacity:1;stroke-width:0.26458332"
|
||||
id="path9800" />
|
||||
<path
|
||||
d="m 12.787764,110.8786 q 2.003778,-2.11667 5.108222,-2.11667 3.104444,0 5.108222,2.11667 2.003778,2.08844 2.003778,5.24933 0,3.16089 -2.003778,5.27755 -2.003778,2.08845 -5.108222,2.08845 -3.104444,0 -5.108222,-2.08845 -2.003778,-2.11666 -2.003778,-5.27755 0,-3.16089 2.003778,-5.24933 z m 1.919111,8.89 q 1.354667,1.35466 3.189111,1.35466 1.834444,0 3.160889,-1.35466 1.354666,-1.38289 1.354666,-3.64067 0,-2.25778 -1.354666,-3.61244 -1.326445,-1.38289 -3.160889,-1.38289 -1.834444,0 -3.189111,1.38289 -1.326445,1.35466 -1.326445,3.61244 0,2.25778 1.326445,3.64067 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:28.22222137px;font-family:'Product Sans';-inkscape-font-specification:'Product Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#5f6368;fill-opacity:1;stroke-width:0.26458332"
|
||||
id="path9802" />
|
||||
<path
|
||||
d="m 33.715864,123.49393 q -3.104445,0 -5.108223,-2.08845 -2.003777,-2.11666 -2.003777,-5.27755 0,-3.16089 2.003777,-5.24933 2.003778,-2.11667 5.108223,-2.11667 2.314222,0 3.838222,1.12889 1.524,1.12889 2.229555,2.85044 l -2.370666,0.98778 q -1.072445,-2.59644 -3.866445,-2.59644 -1.721555,0 -3.048,1.41111 -1.298222,1.41111 -1.298222,3.58422 0,2.17311 1.298222,3.58422 1.326445,1.41111 3.048,1.41111 2.906889,0 4.007556,-2.59644 l 2.314222,0.98778 q -0.705556,1.69333 -2.286,2.85044 -1.552222,1.12889 -3.866444,1.12889 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:28.22222137px;font-family:'Product Sans';-inkscape-font-specification:'Product Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#5f6368;fill-opacity:1;stroke-width:0.26458332"
|
||||
id="path9804" />
|
||||
<path
|
||||
d="m 44.707976,102.83526 v 12.446 l 5.983111,-6.06777 h 3.330222 v 0.11288 l -5.390445,5.39045 5.644445,8.21266 v 0.11289 h -3.132667 l -4.346222,-6.51933 -2.088444,2.08844 v 4.43089 h -2.596445 v -20.20711 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:28.22222137px;font-family:'Product Sans';-inkscape-font-specification:'Product Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#5f6368;fill-opacity:1;stroke-width:0.26458332"
|
||||
id="path9806" />
|
||||
<path
|
||||
d="m 58.322996,123.04237 h -2.596444 v -20.20711 h 2.596444 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:28.22222137px;font-family:'Product Sans';-inkscape-font-specification:'Product Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#5f6368;fill-opacity:1;stroke-width:0.26458332"
|
||||
id="path9808" />
|
||||
<path
|
||||
d="m 65.156299,129.13837 h -2.681111 l 3.217333,-6.97089 -5.700889,-12.95399 h 2.822222 l 4.120445,9.93422 h 0.05644 l 4.007555,-9.93422 h 2.822223 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:28.22222137px;font-family:'Product Sans';-inkscape-font-specification:'Product Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#5f6368;fill-opacity:1;stroke-width:0.26458332"
|
||||
id="path9810" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 12 KiB |
BIN
docs/assets/blocks/blocks.png
Normal file
|
After Width: | Height: | Size: 254 KiB |
BIN
docs/assets/blocks/get-position.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
docs/assets/blocks/land.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
docs/assets/blocks/navigate.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
docs/assets/blocks/random-color.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
docs/assets/blocks/save.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
docs/assets/blocks/set-effect.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
docs/assets/blocks/take-off.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
docs/assets/blocks/wait-arrival.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
docs/assets/blocks/wait.png
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
@@ -48,6 +48,7 @@
|
||||
* [Using rviz and rqt](rviz.md)
|
||||
* [Software autorun](autolaunch.md)
|
||||
* [Using JavaScript](javascript.md)
|
||||
* [Blocks programmin](blocks.md)
|
||||
* [ROS](ros.md)
|
||||
* [MAVROS](mavros.md)
|
||||
* Simulation
|
||||
|
||||
110
docs/en/blocks.md
Normal file
@@ -0,0 +1,110 @@
|
||||
# Blocks programming for Clover
|
||||
|
||||
<img src="../assets/blocks/blockly.svg" width=200 align="right">
|
||||
|
||||
Visual blocks programming feature has been added to the [RPi image](image.md), starting with the version **0.21**. Blocks programming is implemented using [Google Blockly](https://developers.google.com/blockly) platform. Blocks programming integration can lower the entry barrier to a minimum.
|
||||
|
||||
## Configuration
|
||||
|
||||
For correct work of the blocks programming, `blocks` argument in the Clover launch-file (`~/catkin_ws/src/clover/clover/launch/clover.launch`) [should be equal to](cli.md#editing) `true`:
|
||||
|
||||
```xml
|
||||
<arg name="blocks" default="true"/>
|
||||
```
|
||||
|
||||
## Running
|
||||
|
||||
To run Clover's blocks programming interface, [connect to Clover's Wi-Fi](wifi.md) and go to web-page http://192.168.11.1:8080/clover_blocks/ or click the link *Blocks programming* at the [main page](wifi.md#web-interface).
|
||||
|
||||
The page looks as follows:
|
||||
|
||||
<img src="../assets/blocks/blocks.png" width=600>
|
||||
|
||||
Assemble your program using blocks in the menu at the left and then click *Run* button for running. You can also view generated Python-code, switching to *Python* tab.
|
||||
|
||||
The *Stop* button stops the program. Clicking *Land* button also stops the program and lands the drone.
|
||||
|
||||
## Storing and loading
|
||||
|
||||
<img src="../assets/blocks/save.png" width=300 align=right>
|
||||
|
||||
To store the program, open the menu at the top right, select *Save* item and input your program's name. The name should contain only Latin characters, hyphen, underline and dot characters. All your stored programs are available at the same menu.
|
||||
|
||||
Your programs are stored as XML-files in the `/catkin_ws/src/clover/clover_blocks/programs/` directory of the SD-card.
|
||||
|
||||
> **Note** Note also example programs, available at the same menu.
|
||||
|
||||
## Blocks
|
||||
|
||||
The set of blocks is somewhat similar to the set of ROS-services of [Clover's autonomous flights API](simple_offboard.md). This section contains descriptions of some of them.
|
||||
|
||||
Clover's blocks are separated into 4 categories:
|
||||
|
||||
* <span style="padding:2px;color:white;background:#9d5ca6">Flight</span> – autonomous flight related commands.
|
||||
* <span style="padding:2px;color:white;background:#ff9b00">State</span> – blocks for obtaining the drone state parameters.
|
||||
* <span style="padding:2px;color:white;background:#01d754">LED</span> – blocks for controlling [LED strip](leds.md).
|
||||
* <span style="padding:2px;color:white;background:#5b97cc">GPIO</span> – blocks for working with [GPIO pins](gpio.md).
|
||||
|
||||
The rest of categories contains standard Blockly's blocks.
|
||||
|
||||
### take_off
|
||||
|
||||
<img src="../assets/blocks/take-off.png" srcset="../assets/blocks/take-off.png 2x">
|
||||
|
||||
Take off to specified altitude in meters. The altitude may be an arbitrary block, that returns a number.
|
||||
|
||||
The `wait` flag specifies, if the drone should wait until take off is complete, before executing the next block.
|
||||
|
||||
### navigate
|
||||
|
||||
<img src="../assets/blocks/navigate.png" srcset="../assets/blocks/navigate.png 2x">
|
||||
|
||||
Navigate to specified point. Coordinates are specified in meters.
|
||||
|
||||
The `wait` flag specifies, if the drone should wait until navigation is complete, before executing the next block.
|
||||
|
||||
#### *Relative to* field {#relative_to}
|
||||
|
||||
This block allows to specify the [coordinate frame](frames.md) of the target point:
|
||||
|
||||
* *body* – coordinates, relative to the drone: *forward*, *left*, *up*.
|
||||
* *markers map* – coordinates, relative to the [map of ArUco-markers](aruco_map.md).
|
||||
* *marker* – coordinates, relative to an [ArUco-marker](aruco_marker.md); marker's ID input fields appears.
|
||||
* *last navigate target* – coordinates, relative to the last specified navigate point.
|
||||
* *map* – drone's local coordinate system, linked with the point of its initialization.
|
||||
|
||||
### land
|
||||
|
||||
<img src="../assets/blocks/land.png" srcset="../assets/blocks/land.png 2x">
|
||||
|
||||
Land the drone.
|
||||
|
||||
The `wait` flag specifies, if the drone should wait until landing is complete, before executing the next block.
|
||||
|
||||
### wait
|
||||
|
||||
<img src="../assets/blocks/wait.png" srcset="../assets/blocks/wait.png 2x">
|
||||
|
||||
Wait specified time period in seconds. The time period may be an arbitrary block, that returns a number.
|
||||
|
||||
### wait_arrival
|
||||
|
||||
<img src="../assets/blocks/wait-arrival.png" srcset="../assets/blocks/wait-arrival.png 2x">
|
||||
|
||||
Wait, until the drone reaches [navigate](#navigate)-block's target point.
|
||||
|
||||
### get_position
|
||||
|
||||
<img src="../assets/blocks/get-position.png" srcset="../assets/blocks/get-position.png 2x">
|
||||
|
||||
The block returns current position, velocity or yaw angle of the drone relative to the specified [coordinate frame](#relative_to).
|
||||
|
||||
### set_effect
|
||||
|
||||
<img src="../assets/blocks/set-effect.png" srcset="../assets/blocks/set-effect.png 2x">
|
||||
|
||||
The block allows to set animations to LED strip, similarly to [`set_effect`](leds.md#set_effect) ROS-service.
|
||||
|
||||
Example of using the block with a random color (colors-related blocks are located in *Colour* category):
|
||||
|
||||
<img src="../assets/blocks/random-color.png" srcset="../assets/blocks/random-color.png 2x">
|
||||
@@ -49,6 +49,7 @@
|
||||
* [Визуализация с помощью rviz](rviz.md)
|
||||
* [Автозапуск ПО](autolaunch.md)
|
||||
* [Использование JavaScript](javascript.md)
|
||||
* [Блочное программирование](blocks.md)
|
||||
* [ROS](ros.md)
|
||||
* [MAVROS](mavros.md)
|
||||
* Симулятор
|
||||
|
||||
110
docs/ru/blocks.md
Normal file
@@ -0,0 +1,110 @@
|
||||
# Блочное программирование Клевера
|
||||
|
||||
<img src="../assets/blocks/blockly.svg" width=200 align="right">
|
||||
|
||||
Возможность блочного визуального программирования автономных полетов Клевера добавлена в [образ для RPi](image.md), начиная с версии **0.21**. Реализация блочного программирования основана на [Google Blockly](https://developers.google.com/blockly). Интеграция Blockly в Клевер позволяет понизить входной порог в программирование автономных полетов до минимального уровня.
|
||||
|
||||
## Конфигурация
|
||||
|
||||
Для корректной работы работы блочного программирования аргумент `blocks` в launch-файле Клевера (`~/catkin_ws/src/clover/clover/launch/clover.launch`) [должен быть в значении](cli.md#editing) `true`:
|
||||
|
||||
```xml
|
||||
<arg name="blocks" default="true"/>
|
||||
```
|
||||
|
||||
## Запуск
|
||||
|
||||
Для того, чтобы открыть интерфейс блочного программирования в Клевере, [подключитесь к Клеверу по Wi-Fi](wifi.md) и перейдите на страницу http://192.168.11.1:8080/clover_blocks/ либо нажмите ссылку *Blocks programming* на [основной веб-странице Клевера](wifi.md#веб-интерфейс).
|
||||
|
||||
Интерфейс выглядит следующим образом:
|
||||
|
||||
<img src="../assets/blocks/blocks.png" width=600>
|
||||
|
||||
Соберите необходимую программу из блоков в меню слева а затем нажмите кнопку *Run* для ее запуска. Также вы можете просмотреть сгенерированный код на языке Python, переключившись во вкладку *Python*.
|
||||
|
||||
Кнопка *Stop* позволяет остановить программу. Нажатие кнопки *Land* также останавливает программу и сажает дрон.
|
||||
|
||||
## Сохранение и загрузка
|
||||
|
||||
<img src="../assets/blocks/save.png" width=300 align=right>
|
||||
|
||||
Для сохранения программы откройте меню справа сверху, выберите пункт меню *Save* и введите название программы. Название программы может содержать только латинские буквы, дефис, подчеркивание и точку. Все ранее сохраненные программы будут доступны в этом же меню.
|
||||
|
||||
На карте памяти сохраненные XML-файлы программ хранятся в каталоге `/catkin_ws/src/clover/clover_blocks/programs/`.
|
||||
|
||||
В этом же меню доступны примеры программ (подкаталог `examples`).
|
||||
|
||||
## Блоки
|
||||
|
||||
Набор блоков приблизительно аналогичен набору ROS-сервисов [API автономных полетов Клевера](simple_offboard.md). В этом разделе приведено описание некоторых из них.
|
||||
|
||||
Блоки Клевера поделены на 4 категории:
|
||||
|
||||
* <span style="padding:2px;color:white;background:#9d5ca6">Flight</span> – команды, имеющие отношение к полету.
|
||||
* <span style="padding:2px;color:white;background:#ff9b00">State</span> – блоки, позволяющие получить те или иные параметры текущего состояния коптера.
|
||||
* <span style="padding:2px;color:white;background:#01d754">LED</span> – блоки для управления [LED-лентой](leds.md).
|
||||
* <span style="padding:2px;color:white;background:#5b97cc">GPIO</span> – блоки для работы с [GPIO-пинами](gpio.md).
|
||||
|
||||
В остальных категориях находятся стандартные блоки Google Blockly.
|
||||
|
||||
### take_off
|
||||
|
||||
<img src="../assets/blocks/take-off.png" srcset="../assets/blocks/take-off.png 2x">
|
||||
|
||||
Взлететь на указанную высоту в метрах. Высота может быть произвольным блоком, возвращающим числовое значение.
|
||||
|
||||
Флаг `wait` определяет, должен ли дрон ожидать окончания взлета перед выполнением следующего блока.
|
||||
|
||||
### navigate
|
||||
|
||||
<img src="../assets/blocks/navigate.png" srcset="../assets/blocks/navigate.png 2x">
|
||||
|
||||
Прилететь в заданную точку. Координаты точки задаются в метрах.
|
||||
|
||||
Флаг `wait` определяет, должен ли дрон ожидать завершения полета в точку перед выполнением следующего блока.
|
||||
|
||||
#### Поле *relative to* {#relative_to}
|
||||
|
||||
В блоке может быть выбрана [система координат](frames.md), в которой задана целевая точка:
|
||||
|
||||
* *body* – координаты относительно коптера: вперед (*forward*), влево (*left*), вверх (*up*).
|
||||
* *markers map* – система координат, связанная с [картой ArUco-маркеров](aruco_map.md).
|
||||
* *marker* – система координта, связанная с [ArUco-маркером](aruco_marker.md); появляется поле для ввода ID маркеа.
|
||||
* *last navigate target* – координаты относительно последней заданной точки для навигации.
|
||||
* *map* – локальная система координат коптера, связана с местом его инициализации.
|
||||
|
||||
### land
|
||||
|
||||
<img src="../assets/blocks/land.png" srcset="../assets/blocks/land.png 2x">
|
||||
|
||||
Произвести посадку.
|
||||
|
||||
Флаг `wait` определяет, должен ли дрон ожидать окончания посадки перед выполнением следующего блока.
|
||||
|
||||
### wait
|
||||
|
||||
<img src="../assets/blocks/wait.png" srcset="../assets/blocks/wait.png 2x">
|
||||
|
||||
Ожидать заданное время в секундах. Время ожидания может быть произвольным блоком, возвращающим числовое значение.
|
||||
|
||||
### wait_arrival
|
||||
|
||||
<img src="../assets/blocks/wait-arrival.png" srcset="../assets/blocks/wait-arrival.png 2x">
|
||||
|
||||
Ожидать, пока дрон долетит до целевой точки (заданной в [navigate](#navigate)-блоке).
|
||||
|
||||
### get_position
|
||||
|
||||
<img src="../assets/blocks/get-position.png" srcset="../assets/blocks/get-position.png 2x">
|
||||
|
||||
Блок позволяет получить позицию, скорость и угол по рысканью дрона в заданной [системе координат](#relative_to).
|
||||
|
||||
### set_effect
|
||||
|
||||
<img src="../assets/blocks/set-effect.png" srcset="../assets/blocks/set-effect.png 2x">
|
||||
|
||||
Блок позволяет устанавливать различные анимации на LED-ленту аналогично [ROS-сервису `set_effect`](leds.md#set_effect).
|
||||
|
||||
Пример использования блока для установки случайного цвета (блоки, связанные с цветами находятся в категории *Colour*):
|
||||
|
||||
<img src="../assets/blocks/random-color.png" srcset="../assets/blocks/random-color.png 2x">
|
||||
@@ -1,5 +1,7 @@
|
||||
# Блочное программирование Клевера
|
||||
|
||||
> **Warning** В этой статье описана неофициальная реализация блочного программирования. [Официальная поддержка](blocks.md) появилась в образе Клевера версии **0.21**.
|
||||
|
||||
<img src="../assets/clever_blocks.jpg">
|
||||
|
||||
В этой статье я опишу процесс скачивания, установки и запуска блочного конструктора программ для квадрокоптера Клевер.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
> **Caution** Обратите внимание, что светодиодную ленту нужно питать от стабильного источника энергии. Если вы подключите питание напрямую к Raspberry, то это создаст слишком большую нагрузку на ваш микрокомпьютер. Для снятия нагрузки с Raspberry можно подключить питание к преобразователю BEC.
|
||||
|
||||
## Высокоуровневое управление лентой
|
||||
## Высокоуровневое управление лентой {#set_effect}
|
||||
|
||||
1. Для работы с лентой подключите ее к питанию +5v – 5v, земле GND – GND и сигнальному порту DIN – GPIO21. Обратитесь [к инструкции по сборке](assemble_4_2.md#установка-led-ленты) для подробностей.
|
||||
2. Включите поддержку LED-ленты в файле `~/catkin_ws/src/clever/clever/launch/clever.launch`:
|
||||
|
||||