Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-4829 arm32 build #2790

Closed
wants to merge 114 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
5e226e9
try in qemu
abe-winter Aug 15, 2023
68c7ccb
break out installation
abe-winter Aug 15, 2023
75e0d4c
don't depend on 2 above
abe-winter Aug 15, 2023
6b60670
xz-utils
abe-winter Aug 15, 2023
66d67e6
do build
abe-winter Aug 15, 2023
a83987c
build interactively
abe-winter Aug 16, 2023
6891482
add tflite build flag
abe-winter Aug 16, 2023
c935ae7
try building 32 bit on buildjet
abe-winter Aug 16, 2023
980ee58
package write permission
abe-winter Aug 16, 2023
692c153
32-bit armv7 working in emulator with no_pigpio flag
Aug 16, 2023
732e0cd
add file for verifying 32-bit
Aug 16, 2023
f5cea48
try running build
abe-winter Aug 16, 2023
b11f091
ghcr login
abe-winter Aug 16, 2023
1c1031d
try without platform arg
abe-winter Aug 16, 2023
e834d77
more compact dockerfile with single user
Aug 16, 2023
56a64d0
try manual docker --platform build
abe-winter Aug 16, 2023
e1408d4
fix bind mount too short
abe-winter Aug 16, 2023
310ea32
try build cache, try $PWD
abe-winter Aug 16, 2023
306b07b
try suppressing porcelain warning
abe-winter Aug 16, 2023
f6b6d75
safe directory v2
abe-winter Aug 16, 2023
b585668
armv7 upload (upload needs to be restricted to main branch before merge)
abe-winter Aug 16, 2023
b854cc7
use default name
abe-winter Aug 16, 2023
e59a913
actually use default name
abe-winter Aug 16, 2023
3ef4ae9
destination is always a folder apparently
abe-winter Aug 16, 2023
a2cd8af
rename artifact
abe-winter Aug 16, 2023
c6ae496
mv out of folder
abe-winter Aug 16, 2023
9773171
only upload latest in main branch
abe-winter Aug 16, 2023
ba83c4b
Merge branch 'main' into arm32-build
abe-winter Aug 16, 2023
97265ec
include linter recs
abe-winter Aug 16, 2023
2223c25
run tests in 32-bit
abe-winter Aug 16, 2023
f4d9db7
correct test command for arm
abe-winter Aug 16, 2023
8697e1b
build flags in test
abe-winter Aug 16, 2023
38dcec5
merge, rm qemu
abe-winter Aug 17, 2023
d1be329
try running natively
abe-winter Aug 17, 2023
af4a537
test splitter
abe-winter Aug 17, 2023
964c87a
try setting --platform
abe-winter Aug 17, 2023
971b956
work around rate limit
abe-winter Aug 17, 2023
00dd665
try correct platform string
abe-winter Aug 17, 2023
ce8f317
don't override platform in build
abe-winter Aug 17, 2023
bbf5226
retry with run platform string
abe-winter Aug 17, 2023
1068efa
actual correct platform string
abe-winter Aug 17, 2023
5fd6175
restore working qemu, add test matrix
abe-winter Aug 17, 2023
ede8747
don't use new py syntax, pass correct flags
abe-winter Aug 17, 2023
9cc003c
improve hanging bin edge case
abe-winter Aug 17, 2023
bd8add3
escape quotes
abe-winter Aug 17, 2023
50865ae
don't crash on empty, give goflags to 'go list'
abe-winter Aug 17, 2023
bb35054
try forcing cgo
abe-winter Aug 17, 2023
8e6875e
don't parallelize, fail-empty, go version
abe-winter Aug 17, 2023
7e970c0
go:build in .h and .c to handle 1.19 edge case
abe-winter Aug 17, 2023
bb8b997
full parallel, check=True, don't use GOFLAGS name
abe-winter Aug 17, 2023
792c249
reorder byte in struct
abe-winter Aug 17, 2023
69f2dc4
more build flags
abe-winter Aug 17, 2023
093bb4a
run all packages in single command
abe-winter Aug 18, 2023
eed357b
join package names
abe-winter Aug 18, 2023
023bcaa
32 bit lint
abe-winter Aug 23, 2023
4eee745
lint in test step
abe-winter Aug 24, 2023
7f70fc7
unskip test-lint job
abe-winter Aug 24, 2023
4ebc935
lint without matrix, in docker
abe-winter Aug 24, 2023
bce9cac
lint command just for atomicalign
abe-winter Aug 28, 2023
6a05461
use normal debian:bullseye (with --platform linux/arm/v7)
abe-winter Aug 28, 2023
4e1672e
fix average.go, staticcheck passing on main codebase in 32-bit env
abe-winter Aug 28, 2023
2725539
use new lint command
abe-winter Aug 28, 2023
6639563
linter: just run staticcheck
abe-winter Aug 28, 2023
9d33d47
add apt packages
abe-winter Aug 28, 2023
284dabf
vendorlint analyzer working
abe-winter Aug 28, 2023
6c8f40e
--no-config to override vendors with own configs
abe-winter Aug 28, 2023
2fcd919
fail vendorlint if issues after filter
abe-winter Aug 28, 2023
b67228b
vendorlint in CI
abe-winter Aug 28, 2023
89391eb
larger builder to solve lint timeout
abe-winter Aug 28, 2023
5b4c961
longer timeout, revert runner change
abe-winter Aug 28, 2023
145dd2a
install linter
abe-winter Aug 28, 2023
377ab58
vendorlint from within make, pass linter path
abe-winter Aug 28, 2023
3aeed32
abs path for linter so cwd= doesn't break it
abe-winter Aug 29, 2023
5055cc5
don't rely on PWD in CI
abe-winter Aug 29, 2023
2e728ee
actually run both steps in 'all' case
abe-winter Aug 29, 2023
298773a
Merge branch 'main' into arm32-build
abe-winter Sep 3, 2023
2085c63
target newest gostream for clean 32-bit lint
abe-winter Sep 3, 2023
27f8b44
parallelism in vendorlint (set to 1 for now)
abe-winter Sep 3, 2023
2f12646
pass down GO_TAGS as -tags in BuildTempModule, flag out some tflite
abe-winter Sep 3, 2023
6476760
pigpio + tflite tags in board + camera
abe-winter Sep 3, 2023
4860eea
factor out local_robot tests relying on tflite, flag
abe-winter Sep 3, 2023
178be70
fix overflow in derivative_test on 32-bit
abe-winter Sep 4, 2023
9770865
move .rpmMonitorCalls to fix unaligned panic, change maxint64 -> maxi…
abe-winter Sep 4, 2023
ceb4343
pass down GO_TAGS in remoteserver test
abe-winter Sep 4, 2023
60f60f3
fix overflow in GetGrayAvg
abe-winter Sep 4, 2023
68aea5c
point at fixed goutils
abe-winter Sep 4, 2023
7fe599a
re-enable 32-bit tests
abe-winter Sep 4, 2023
ff7350a
chown to fix buildvcs crash in subprocess builds
abe-winter Sep 4, 2023
884bf56
without sudo
abe-winter Sep 4, 2023
d2a52a7
quote dollar sign
abe-winter Sep 4, 2023
8cdfadc
backticks to get username in sh -c
abe-winter Sep 4, 2023
1f609e2
hardcode username in container
abe-winter Sep 4, 2023
809e712
run whoami
abe-winter Sep 4, 2023
ab16a5f
try goflags
abe-winter Sep 4, 2023
b8eb020
pass GOFLAGS into run container
abe-winter Sep 4, 2023
25f748d
fix docker params
abe-winter Sep 4, 2023
400b6b3
restore commented indices
abe-winter Sep 4, 2023
bcaf04f
remove GO_TAGS override, use GOFLAGS var
abe-winter Sep 4, 2023
d38b09b
splitter-placement.json because pointcloud has be in same block as th…
abe-winter Sep 4, 2023
b112bf0
restore lint step
abe-winter Sep 4, 2023
580049a
build needs lint
abe-winter Sep 4, 2023
53acc87
rm dangling imports in local robot tflite
abe-winter Sep 6, 2023
8aad23c
linter fixes
abe-winter Sep 6, 2023
6115e3f
Merge branch 'main' into arm32-build
abe-winter Sep 6, 2023
35830a8
add back docker step
abe-winter Sep 6, 2023
e579526
remove unused MORE_GO_TAGS added in this branch
abe-winter Sep 6, 2023
1358c95
try using setup.sh in base image
abe-winter Sep 6, 2023
bd1f265
vendorlint: throw EnvironmentError if args.root is missing. rm unused…
abe-winter Sep 7, 2023
1916e0c
splitter: move placement rules from json to py, document
abe-winter Sep 7, 2023
98851a4
review: explicitly output to default vendorlint.json
abe-winter Sep 7, 2023
ed3c302
remove removed flag --placement
abe-winter Sep 7, 2023
82a90b3
make vendorlint conditional on changed go.sum
abe-winter Sep 7, 2023
16c76fa
add make command test-go-split
abe-winter Sep 7, 2023
045cbfd
use docker readonly login to work around rate limits
abe-winter Sep 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bin/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these things generated by our make commands that a user/github action is expected to have created now? Or were these artifacts of your personal workflow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: this was already blocked in our .gitignore -- I added to .dockerignore to make my docker builds start faster

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are in theory nice-to-haves for anyone doing local docker iterations, but are not critical and I can remove if you want

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, though I'm rather unfamiliar. I'll defer to @Otterverse if there's any concerns.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see .direnv anywhere in .gitignore, so not sure where that came from. Ignoring .git is good though, saves some code size for most builds. There's other stuff in .gitignore that could be here too... especially node_modules and .artifact I think.

Also, why ignore **/Dockerfile ?

.direnv/
.git/
**/Dockerfile
115 changes: 115 additions & 0 deletions .github/workflows/server-32bit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
on:
push:
Comment on lines +1 to +2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to be building a new docker image every single push. This needs to be a called workflow, hooked into the proper "top-level" workflows (e.g. pull-request-trusted.yml and/or main.yml)


jobs:
docker:
runs-on: buildjet-4vcpu-ubuntu-2204-arm
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- uses: docker/login-action@v2
with:
username: awinterbuildrate
password: ${{ secrets.DOCKER_PUBLIC_READONLY_PAT }}
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to be building a 32-bit image. The image currently at ghcr.io/viamrobotics/viam-server:armv7 is actually 64bit arm when I inspect it as well.

$ docker image inspect ghcr.io/viamrobotics/viam-server:armv7 | grep Arch
        "Architecture": "arm64",

with:
file: etc/packaging/32bit/Dockerfile
tags: ghcr.io/viamrobotics/viam-server:armv7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the docker image probably shouldn't be the same as our binary, but it's fine for the moment.

pull: true
push: true
cache-from: type=registry,ref=ghcr.io/viamrobotics/viam-server:buildcache
cache-to: type=registry,ref=ghcr.io/viamrobotics/viam-server:buildcache
lint:
needs: [docker]
runs-on: buildjet-4vcpu-ubuntu-2204-arm
permissions:
packages: read
steps:
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
Comment on lines +36 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe you need this when using the image (only when publishing.) The docker images should be public.

- uses: actions/checkout@v3
# note: we're linting on 32-bit because atomicalign analyzer only works on 32-bit architecture
- name: lint
run: docker run --rm -v $PWD/:/rdk ghcr.io/viamrobotics/viam-server:armv7 make lint-32bit
- id: changed-files
uses: tj-actions/changed-files@v39
with:
# note: this doesn't provide perfect coverage, but it's a compromise between running all the time + never running
since_last_remote_commit: true
- name: vendorlint
if: contains(steps.changed-files.outputs.modified_files, 'go.sum')
run: docker run --rm -v $PWD/:/rdk ghcr.io/viamrobotics/viam-server:armv7 make vendorlint
test:
needs: [docker]
runs-on: buildjet-4vcpu-ubuntu-2204-arm
strategy:
fail-fast: false
matrix:
index: ['0', '1', '2', '3', '4']
permissions:
packages: read
steps:
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- name: test
run: |
docker run --rm \
-v $PWD/:/rdk \
--env GOFLAGS="-tags=no_tflite,no_pigpio -buildvcs=false" \
abe-winter marked this conversation as resolved.
Show resolved Hide resolved
--env INDEX=${{ matrix.index }} \
--env NBINS=5 \
ghcr.io/viamrobotics/viam-server:armv7 \
make test-go-split
build:
needs: [test, lint]
runs-on: buildjet-4vcpu-ubuntu-2204-arm
permissions:
packages: read
steps:
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- name: build
run: docker run --rm -v $PWD/:/rdk ghcr.io/viamrobotics/viam-server:armv7 sh -c "git config --global --add safe.directory '*' && go build -v -tags no_pigpio,no_tflite ./web/cmd/server"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unclear why you're directly calling docker run, rather than using the workflow-native "container" options to run inside the container.

- name: show arch
run: file server
- uses: actions/upload-artifact@v3
with:
path: server
upload:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a seperate job? Why not just upload in the job where you created the artifact?

needs: [build]
if: github.ref_name == 'main'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
- name: rename
run: mv artifact/server viam-server-latest-armv7l
- name: Authorize GCP Upload
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: upload
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: viam-server-latest-armv7l
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is a distributable binary. There's a whole process to do a (mostly) statically linked binary and/or appimages. This appears to just be raw binary, and with the current docker image, a 64-bit one at that.

destination: 'packages.viam.com/apps/viam-server/'
parent: false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,5 @@ google-credentials.json

# frontend built artifacts are not committed (they are generated during appimage github workflow step)
web/runtime-shared/static

vendorlint.json
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ lint-go: tool-install
export pkgs="`go list -f '{{.Dir}}' ./... | grep -v /proto/`" && echo "$$pkgs" | xargs go vet -vettool=$(TOOL_BIN)/combined
GOGC=50 $(TOOL_BIN)/golangci-lint run -v --fix --config=./etc/.golangci.yaml

lint-32bit: tool-install
$(TOOL_BIN)/golangci-lint run -v --build-tags no_tflite,no_pigpio --tests=false --disable-all --enable staticcheck --timeout 30m

vendorlint: tool-install
go mod vendor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an expensive (bandwidth/time) operation. It also leaves the vendor directory permanently which breaks future builds for regular use. To be specific, make server throws errors about missing opus.h after I run this target.

# parallelism is 1 for now because golangci-lint detects parallel runs and complains
etc/vendorlint.py all --linter $(abspath $(TOOL_BIN)/golangci-lint) --parallel 1 --out vendorlint.json

lint-web: check-web
npm run lint --prefix web/frontend

Expand All @@ -74,6 +82,10 @@ test-no-race: test-go-no-race test-web
test-go: tool-install
PATH=$(PATH_WITH_TOOLS) ./etc/test.sh race

test-go-split:
# run one shard of the test suite using splitter.py
go list -json ./... | etc/splitter.py $(INDEX) --nbins $(NBINS) --command "go test" --fail-empty

test-go-no-race: tool-install
PATH=$(PATH_WITH_TOOLS) ./etc/test.sh

Expand Down
2 changes: 1 addition & 1 deletion components/board/pi/impl/board.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux && (arm64 || arm)
//go:build linux && (arm64 || arm) && !no_pigpio

// Package piimpl contains the implementation of a supported Raspberry Pi board.
package piimpl
Expand Down
2 changes: 1 addition & 1 deletion components/board/pi/impl/board_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux && (arm64 || arm)
//go:build linux && (arm64 || arm) && !no_pigpio

package piimpl

Expand Down
2 changes: 1 addition & 1 deletion components/board/pi/impl/external_hardware_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux && (arm64 || arm)
//go:build linux && (arm64 || arm) && !no_pigpio

package piimpl

Expand Down
2 changes: 1 addition & 1 deletion components/board/pi/impl/i2c.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux && (arm64 || arm)
//go:build linux && (arm64 || arm) && !no_pigpio

package piimpl

Expand Down
1 change: 1 addition & 0 deletions components/board/pi/impl/pi.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !no_pigpio
#include <pigpio.h>

extern void pigpioInterruptCallback(int gpio, int level, uint32_t tick);
Expand Down
1 change: 1 addition & 0 deletions components/board/pi/impl/pi.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !no_pigpio
#pragma once

// interruptCallback calls through to the go linked interrupt callback.
Expand Down
2 changes: 1 addition & 1 deletion components/board/pi/impl/servo.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux && (arm64 || arm)
//go:build linux && (arm64 || arm) && !no_pigpio

package piimpl

Expand Down
2 changes: 1 addition & 1 deletion components/board/pi/impl/utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux && (arm64 || arm)
//go:build linux && (arm64 || arm) && !no_pigpio

package piimpl

Expand Down
2 changes: 1 addition & 1 deletion components/board/pi/impl/verify_main_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux && (arm64 || arm)
//go:build linux && (arm64 || arm) && !no_pigpio

package piimpl

Expand Down
2 changes: 1 addition & 1 deletion components/board/pi/pi_notsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !(linux && (arm64 || arm))
//go:build !(linux && (arm64 || arm) && !no_pigpio)

package pi

Expand Down
2 changes: 1 addition & 1 deletion components/board/pi/pi_supported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux && (arm64 || arm)
//go:build linux && (arm64 || arm) && !no_pigpio

package pi

Expand Down
2 changes: 2 additions & 0 deletions components/camera/transformpipeline/classifier_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !no_tflite

package transformpipeline

import (
Expand Down
2 changes: 2 additions & 0 deletions components/camera/transformpipeline/detector_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !no_tflite

package transformpipeline

import (
Expand Down
4 changes: 1 addition & 3 deletions components/encoder/incremental/incremental_encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ func init() {
// Encoder keeps track of a motor position using a rotary incremental encoder.
type Encoder struct {
resource.Named

positionType encoder.PositionType
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For posterity:

I'm guessing the problem here is that sync.Mutex needs to be on some byte-boundary (4? 8?). And this is to shuffle the ordering such that we satisfy that requirement.

I think this is going to be a common sharp edge for rdk developers. It's a reasonable practice to place mutexes near the variables they are intending to protect and (in Go at least) not worry about runtime constraints for correctness.

So in lieu of having some "gofmt-like" program that can rewrite our structures to be 32-bit mutex compliant, we need to start leaving more documentation around our sync.Mutex variables about why they are placed where they are. Maybe in the future we'll fall into a convention that can avoid some of the documentation.

A concrete ask:

  • Leave a comment here saying: `"sync" and "atomic" primitives must be 4-byte aligned for 32-bit builds."
  • Move activeBackgroundWorkers below this mutex. Mostly so we can write one comment that applies to all the important parts. And so we start leaving good examples that people can crib off of.

I'll leave a comment on the other locations changed in this PR so you don't have to hope you caught all of the ones I'm seeing. But please do not audit the entire code-base to make these changes. I just want to get the ball rolling on communicating this subtle requirement to the broader set of developers at viam.

Offline discussion:
The problem isn't with mutexes but rather atomic accesses to the position, pRaw and pState variables. E.g: here. Consider just changing them to atomic.Int64


mu sync.Mutex
A, B board.DigitalInterrupt
// The position is pRaw with the least significant bit chopped off.
Expand All @@ -53,6 +50,7 @@ type Encoder struct {
cancelCtx context.Context
cancelFunc func()
activeBackgroundWorkers sync.WaitGroup
positionType encoder.PositionType
}

// Pins describes the configuration of Pins for a quadrature encoder.
Expand Down
12 changes: 6 additions & 6 deletions components/motor/gpio/motor_encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func newEncodedMotor(

// EncodedMotor is a motor that utilizes an encoder to track its position.
type EncodedMotor struct {
rpmMonitorCalls int64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offline discussion: consider changing this to atomic.Int64.

resource.Named
resource.AlwaysRebuild

Expand All @@ -195,12 +196,11 @@ type EncodedMotor struct {
flip int64 // defaults to 1, becomes -1 if the motor config has a true DirectionFLip bool
ticksPerRotation int64

rpmMonitorCalls int64
logger golog.Logger
cancelCtx context.Context
cancel func()
loop *control.Loop
opMgr *operation.SingleOperationManager
logger golog.Logger
cancelCtx context.Context
cancel func()
loop *control.Loop
opMgr *operation.SingleOperationManager
}

// EncodedMotorState is the core, non-statistical state for the motor.
Expand Down
23 changes: 12 additions & 11 deletions control/derivative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ func TestDerivativeConfig(t *testing.T) {
}

func TestDerivativeNext(t *testing.T) {
const iter int = 3000
const iter int64 = 3000
abe-winter marked this conversation as resolved.
Show resolved Hide resolved
const tenMs = 10 * int64(time.Millisecond)
logger := golog.NewTestLogger(t)
ctx := context.Background()
cfg := BlockConfig{
Expand All @@ -92,22 +93,22 @@ func TestDerivativeNext(t *testing.T) {
d := b.(*derivative)
test.That(t, err, test.ShouldBeNil)
var sin []float64
for i := 0; i < iter; i++ {
sin = append(sin, math.Sin((time.Duration(10 * i * int(time.Millisecond)).Seconds())))
for i := int64(0); i < iter; i++ {
sin = append(sin, math.Sin(time.Duration(i*tenMs).Seconds()))
}
sig := &Signal{
name: "A",
signal: make([]float64, 1),
time: make([]int, 1),
dimension: 1,
}
for i := 0; i < iter; i++ {
for i := int64(0); i < iter; i++ {
sig.SetSignalValueAt(0, sin[i])
out, ok := d.Next(ctx, []*Signal{sig}, (10 * time.Millisecond))
test.That(t, ok, test.ShouldBeTrue)
if i > 5 {
test.That(t, out[0].GetSignalValueAt(0), test.ShouldAlmostEqual,
-math.Sin((time.Duration(10 * i * int(time.Millisecond)).Seconds())), 0.01)
-math.Sin((time.Duration(i * tenMs).Seconds())), 0.01)
}
}
cfg = BlockConfig{
Expand All @@ -120,13 +121,13 @@ func TestDerivativeNext(t *testing.T) {
}
err = d.UpdateConfig(ctx, cfg)
test.That(t, err, test.ShouldBeNil)
for i := 0; i < iter; i++ {
for i := int64(0); i < iter; i++ {
sig.SetSignalValueAt(0, sin[i])
out, ok := d.Next(ctx, []*Signal{sig}, (10 * time.Millisecond))
test.That(t, ok, test.ShouldBeTrue)
if i > 5 {
test.That(t, out[0].GetSignalValueAt(0), test.ShouldAlmostEqual,
math.Cos((time.Duration(10 * i * int(time.Millisecond)).Seconds())), 0.01)
math.Cos((time.Duration(i * tenMs).Seconds())), 0.01)
}
}
cfg = BlockConfig{
Expand All @@ -140,16 +141,16 @@ func TestDerivativeNext(t *testing.T) {
err = d.UpdateConfig(ctx, cfg)
test.That(t, err, test.ShouldBeNil)
sin = nil
for i := 0; i < iter; i++ {
sin = append(sin, math.Sin(2*math.Pi*(time.Duration(10*i*int(time.Millisecond)).Seconds())))
for i := int64(0); i < iter; i++ {
sin = append(sin, math.Sin(2*math.Pi*(time.Duration(i*tenMs).Seconds())))
}
for i := 0; i < iter; i++ {
for i := int64(0); i < iter; i++ {
sig.SetSignalValueAt(0, sin[i])
out, ok := d.Next(ctx, []*Signal{sig}, 10*time.Millisecond)
test.That(t, ok, test.ShouldBeTrue)
if i > 5 {
test.That(t, out[0].GetSignalValueAt(0), test.ShouldAlmostEqual,
2*math.Pi*math.Cos(2*math.Pi*(time.Duration(10*i*int(time.Millisecond)).Seconds())), 0.01)
2*math.Pi*math.Cos(2*math.Pi*(time.Duration(i*tenMs).Seconds())), 0.01)
}
}
}
12 changes: 12 additions & 0 deletions etc/packaging/32bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM debian:bullseye

RUN apt-get update && apt-get install sudo
RUN adduser --disabled-password runner
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN adduser runner sudo
USER runner
WORKDIR /build
COPY etc/setup.sh .
RUN ./setup.sh
RUN sudo apt-get install -qqy wget xz-utils file vim pkg-config
WORKDIR /rdk
Loading
Loading