mirror of
https://github.com/CopterExpress/clover.git
synced 2026-05-27 13:39:33 +00:00
* 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
111 lines
4.8 KiB
Markdown
111 lines
4.8 KiB
Markdown
# 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">
|