Skip to content

Commit

Permalink
Add windows from layout stride, submdspan, rotatable, polygonal, and …
Browse files Browse the repository at this point in the history
…save/load from image (#1)
  • Loading branch information
griswaldbrooks authored Sep 8, 2024
1 parent d101677 commit f94f3ce
Show file tree
Hide file tree
Showing 11 changed files with 801 additions and 236 deletions.
21 changes: 21 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
BasedOnStyle: Google

ColumnLimit: 100
IndentWidth: 2

DerivePointerAlignment: false
QualifierAlignment: Right
ReferenceAlignment: Pointer
SpaceAroundPointerQualifiers: Default
PointerAlignment: Left

IncludeBlocks: Regroup
IncludeCategories:
- Priority: 1
Regex: '^<rsl\/'
- Priority: 2
Regex: '^<(.+).hpp>$'
- Priority: 3
Regex: '^<(.+)>$'
...
Empty file added .codespell_words
Empty file.
71 changes: 71 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# To use:
#
# pre-commit run -a
#
# Or:
#
# pre-commit install # (runs every time you commit in git)
#
# To update this file:
#
# pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit

exclude: 'third_party/.*'
repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-added-large-files
args: ['--maxkb=1000']
- id: check-ast
- id: check-byte-order-marker
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-executables-have-shebangs
- id: pretty-format-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: fix-byte-order-marker
- id: fix-encoding-pragma
- id: forbid-new-submodules
- id: mixed-line-ending
- id: name-tests-test
- id: no-commit-to-branch
- id: requirements-txt-fixer
- id: sort-simple-yaml
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black

- repo: local
hooks:
- id: clang-format
name: clang-format
description: Format files with ClangFormat.
entry: clang-format
language: system
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
args: ['-fallback-style=none', '-i']

- repo: https://github.com/codespell-project/codespell
rev: v2.0.0
hooks:
- id: codespell
args: ['--write-changes', '--ignore-words=.codespell_words']
14 changes: 3 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,22 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Werror -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wsign-conversion)
endif()

add_library(tooly INTERFACE)
add_library(spanny::tooly ALIAS tooly)
target_include_directories(tooly INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_compile_features(tooly INTERFACE cxx_std_20)

add_executable(spanny2
src/main.cpp
)
target_link_libraries(spanny2 PRIVATE serial mdspan expected)
target_include_directories(spanny2 INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_compile_features(spanny2 INTERFACE cxx_std_20)

find_package(OpenCV REQUIRED)

add_executable(mappy
src/map.cpp
)
target_link_libraries(mappy PRIVATE serial mdspan expected)
target_link_libraries(mappy PRIVATE serial mdspan expected ${OpenCV_LIBS})
target_include_directories(mappy INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_compile_features(mappy INTERFACE cxx_std_20)

if(NOT PROJECT_IS_TOP_LEVEL)
return()
endif()

include(CTest)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ RUN --mount=type=cache,target=/var/cache/apt,id=apt \
wget \
&& rm -rf /var/lib/apt/lists/*

# Get library dependencies
# hadolint ignore=DL3008
RUN --mount=type=cache,target=/var/cache/apt,id=apt \
apt-get update -y && apt-get install -q -y --no-install-recommends \
libopencv-dev \
&& rm -rf /var/lib/apt/lists/*

FROM upstream AS development

ARG UID
Expand All @@ -31,6 +38,7 @@ RUN if [ -z "$USER" ]; then echo '\nERROR: USER not set. Run \n\n \texport USER=
RUN --mount=type=cache,target=/var/cache/apt,id=apt \
apt-get update && apt-get upgrade -y \
&& apt-get install -q -y --no-install-recommends \
clang-format \
git \
inkscape \
neovim \
Expand Down
63 changes: 60 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,68 @@ docker compose -f compose.dev.yml run development
```
Build the repository in the container
```shell
username@spanny-dev:~/ws$ cmake -S src/spanny2/ -B build
username@spanny-dev:~/ws$ cmake --build build
cmake -S src/spanny2/ -B build
cmake --build build
```

# Run
```shell
username@spanny-dev:~/ws$ ./build/spanny2
username@spanny-dev:~/ws$ ./build/mappy
```

# Orphans
```shell
docker compose -f compose.dev.yml down --remove-orphans
```

# Title
spanny 2: rise of std::mdspan
# Abstract
C++23 introduced std::mdspan, a multi-dimensional view type that expanded on the capabilities of its predecessors, std::span and std::string_view, by eliminating the restriction to view into contiguous blocks of memory. Multidimensional array-type data structures are commonly used in robotics applications such as RGB and depth images, as well as occupancy grids for navigation. While these alone present a compelling alternative to hand-rolled data structures, this talk will illustrate the flexibility of the layout and accessor policy customization points included in std::mdspan, demonstrating its potential through various examples, including helping a robot arm inventory beer bottles.
This talk will review conventional use cases of std::mdspan in robotics, such as occupancy grids and submaps for determining obstacles and collision checking with polygonal footprints, as well as handling camera images retrieved after deep learning inference. Additionally, we will discuss commanding single and dual robot arms for inventory inspection using synchronous and asynchronous strategies via the std::mdspan accessor policy and std::future.

While these toy examples may have speculative applications, they highlight the flexibility and extensibility of this new data structure for novel use cases.

# Outline
## Introduction
- Brief overview of the presentation
- Introduction to std::mdspan in C++23

## Motivations for std::mdspan
- Historical background: limitations of previous non-owning types (std::span, std::string_view)
- The need for more flexible view types in C++

## Features of std::mdspan
- Multi-dimensional view type without memory layout restrictions
- Customization points: layout and accessor policies

## Conventional Use Cases in Robotics
- Occupancy grids and cost-maps
- Submaps for navigation and localization
- Polygonal views and arbitrary layouts for collision checking
- Accessor policies interfacing with GPUs (e.g., CUDA calls)

## Beer Inspection Use Cases
- Synchronous command of a single robot arm
- Synchronous command of dual robot arms
- Asynchronous command of dual robot arms for optimized path planning

## Conclusion
- Summary of mdspan features and benefits
- Discussion of use cases in fleet management and warehouse inventory control
- Using std::mdspan to access cloud resources asynchronously
- Potential impact on robotics and other fields
- Speculation on future applications and developments

## References
mdspan proposal
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p0009r18.html

Timur Doumler talk
https://youtu.be/eD-ceG-oByA?si=FYk_cG3dNPIHiF2h

Bryce Lelback talk
https://youtu.be/aFCLmQEkPUw?si=zWybvW7JAOO33yVV

Three skew rotation
https://youtu.be/1LCEiVDHJmc?si=kjbLFjp8XldHnzO1
54 changes: 0 additions & 54 deletions include/tooly/tooly.hpp

This file was deleted.

Loading

0 comments on commit f94f3ce

Please sign in to comment.