Skip to content

Latest commit

 

History

History
62 lines (52 loc) · 2.38 KB

README.md

File metadata and controls

62 lines (52 loc) · 2.38 KB

async-kartoffel

An asynchronous abstraction layer for kartoffels by Patryk27

How to use

See binaries in src directory. To build and copy to clipboard, use e.g. (linux and wayland)

cargo build --release --bins
base64 target/riscv64-kartoffel-bot/release/tutorial-stab | wl-copy`

For other systems, check the build script in the default starter pack.

Work in progress 🚧

Possible improvements:

  • tests for binaries
  • logging
  • inventory
  • timer queue, better wakers
  • benchmarks and optimization

Features

  • Concurrent execution is useful for managing multiple tasks (like navigation and immediate reactions to new information) at once. To use the async functions, an executor must be used, e.g. the embassy_executor. The API can also be used in a blocking paradigm.
  • Moving the bot, stabbing, scanning etc. mutate global state. This is represented by encapsulating these functions in singletons. They can be aquired exactly once using Bot::take(). This way you can be sure that if you keep a reference to motor, and checked motor.is_ready(), the motor stays ready.
  • If you tried to use Motor/Arm/... and they were not ready, an Err is returned.
  • In the default firmware, radar scan can be overwritten by new scans. In this API, this is no longer possible, which is enforced by preventing any new scans as long as not all radar scans have been dropped. It might be necessary to manually call mem::drop in certain scenarios.
  • Bound checking radar scan
  • Instant and Duration tyes for timers
  • Tile, Direction, Distance types
  • Unit Tests
  • Interruptable and cooperative Map and Navigation in async-algorithm crate, to ensure low latency reactions to other bots.

Tests

The unstable custom_test_frameworks is used for test. The build command is e.g. (linux and wayland)

cargo build --release --tests --all
base64 target/riscv64-kartoffel-bot/release/deps/async_kartoffel-e58abfc84af62516 | wl-copy

Hash (e58a...) may need to be adapted.

Add the following lines

#![feature(custom_test_frameworks)]
#![reexport_test_harness_main = "test_main"]
#![test_runner(test_kartoffel::runner)]

add the top of your library to enable tests. Might not work for binaries though.