Skip to content

Commit

Permalink
add driver code
Browse files Browse the repository at this point in the history
  • Loading branch information
martha-johnston committed Nov 7, 2024
1 parent 6604870 commit 29c7701
Show file tree
Hide file tree
Showing 13 changed files with 606 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .canon.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file provides project-level configuration for the canon dev environment utility. https://github.com/viamrobotics/canon
MODULE:
wit-motion:
default: true
image_amd64: ghcr.io/viamrobotics/rdk-devenv:amd64-cache
image_arm64: ghcr.io/viamrobotics/rdk-devenv:arm64-cache
Expand All @@ -9,7 +9,7 @@ MODULE:
group: testbot
persistent: true

MODULE-antique:
wit-motion-antique:
image_amd64: ghcr.io/viamrobotics/antique2:amd64-cache
image_arm64: ghcr.io/viamrobotics/antique2:arm64-cache
minimum_date: 2023-10-26T20:00:00.0Z
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ jobs:
script: |
let prNumber = context.payload.pull_request && context.payload.pull_request.number;
try {
await github.rest.issues.removeLabel({owner: "viam-modules", repo: "MODULE", issue_number: prNumber, name: "safe to test"});
await github.rest.issues.removeLabel({owner: "viam-modules", repo: "wit-motion", issue_number: prNumber, name: "safe to test"});
} catch (err) {
core.info(`Non-fatal error ${err}, while trying to remove 'safe to test' label.`);
}
let orgResp = await github.rest.orgs.checkMembershipForUser({org: "viam-modules", username: context.payload.sender.login});
if (orgResp.status === 204) {
// order of labeling events must be preserved, so two seperate calls
await github.rest.issues.addLabels({owner: "viam-modules", repo: "MODULE", issue_number: prNumber, labels: ["safe to test"]});
await github.rest.issues.addLabels({owner: "viam-modules", repo: "wit-motion", issue_number: prNumber, labels: ["safe to test"]});
return true;
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pullrequest-trusted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ on:
jobs:
test:
if: (github.event.label.name == 'safe to test' || github.event.label.name == 'appimage')
uses: viam-modules/MODULE/.github/workflows/test.yml@main
uses: viam-modules/wit-motion/.github/workflows/test.yml@main
secrets:
MONGODB_TEST_OUTPUT_URI: ${{ secrets.MONGODB_TEST_OUTPUT_URI }}
DOCKER_PUBLIC_READONLY_PAT: ${{ secrets.DOCKER_PUBLIC_READONLY_PAT }}

license_finder:
uses: viam-modules/MODULE/.github/workflows/license_finder.yml@main
uses: viam-modules/wit-motion/.github/workflows/license_finder.yml@main
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ jobs:
- name: Build and package
run: |
canon --profile MODULE
canon --profile wit-motion
TARGET_OS=${{ matrix.platform }} TARGET_ARCH=${{ matrix.arch }} make module
- name: Upload MODULE module to registry
- name: Upload wit-motion module to registry
uses: viamrobotics/upload-module@main
with:
meta-path: meta.json
Expand Down
Empty file removed MODEL/MODEL.go
Empty file.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ endif

module: build
rm -f $(BIN_OUTPUT_PATH)/module.tar.gz
tar czf $(BIN_OUTPUT_PATH)/module.tar.gz $(BIN_OUTPUT_PATH)/MODULE meta.json
tar czf $(BIN_OUTPUT_PATH)/module.tar.gz $(BIN_OUTPUT_PATH)/wit-motion meta.json

build: build-go

build-go:
rm -f $(BIN_OUTPUT_PATH)/MODULE
go build -tags no_cgo,osusergo,netgo -ldflags="-extldflags=-static $(COMMON_LDFLAGS)" -o $(BIN_OUTPUT_PATH)/MODULE main.go
rm -f $(BIN_OUTPUT_PATH)/wit-motion
go build -tags no_cgo,osusergo,netgo -ldflags="-extldflags=-static $(COMMON_LDFLAGS)" -o $(BIN_OUTPUT_PATH)/wit-motion main.go

tool-install:
GOBIN=`pwd`/$(TOOL_BIN) go install \
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# [`MODULE` module](https://github.com/viam-modules/MODULE)
# [`wit-motion` module](https://github.com/viam-modules/wit-motion)

This [MODULE module](https://app.viam.com/module/viam/MODULE) implements a MODULE [MODEL COMPONENT](<LINK TO HARDWARE>), used for <DESCRIPTION> using the [`rdk:component:COMPONENT` API](https://docs.viam.com/appendix/apis/components/COMPONENT/).
This [wit-motion module](https://app.viam.com/module/viam/wit-motion) implements a wit-motion [imu-wit movement_sensor](<LINK TO HARDWARE>), used for <DESCRIPTION> using the [`rdk:component:movement_sensor` API](https://docs.viam.com/appendix/apis/components/movement_sensor/).

> [!NOTE]
> Before configuring your COMPONENT, you must [create a machine](https://docs.viam.com/cloud/machines/#add-a-new-machine).
> Before configuring your movement_sensor, you must [create a machine](https://docs.viam.com/cloud/machines/#add-a-new-machine).
## Configure your MODEL COMPONENT
## Configure your imu-wit movement_sensor

Navigate to the [**CONFIGURE** tab](https://docs.viam.com/configure/) of your [machine](https://docs.viam.com/fleet/machines/) in the [Viam app](https://app.viam.com/).
[Add COMPONENT / MODULE:MODEL to your machine](https://docs.viam.com/configure/#components).
[Add movement_sensor / wit-motion:imu-wit to your machine](https://docs.viam.com/configure/#components).

On the new component panel, copy and paste the following attribute template into your COMPONENT's attributes field:
On the new component panel, copy and paste the following attribute template into your movement_sensor's attributes field:

```json
{
Expand All @@ -20,22 +20,22 @@ On the new component panel, copy and paste the following attribute template into

### Attributes

The following attributes are available for `viam:MODULE:MODEL` COMPONENTs:
The following attributes are available for `viam:wit-motion:imu-wit` movement_sensors:

<EXAMPLE !!>
| Attribute | Type | Required? | Description |
| --------- | ---- | --------- | ---------- |
| `i2c_bus` | string | **Required** | The index of the I<sup>2</sup>C bus on the board that the COMPONENT is wired to. |
| `i2c_address` | string | Optional | Default: `0x77`. The [I<sup>2</sup>C device address](https://learn.adafruit.com/i2c-addresses/overview) of the COMPONENT. |
| `i2c_bus` | string | **Required** | The index of the I<sup>2</sup>C bus on the board that the movement_sensor is wired to. |
| `i2c_address` | string | Optional | Default: `0x77`. The [I<sup>2</sup>C device address](https://learn.adafruit.com/i2c-addresses/overview) of the movement_sensor. |

## Example configuration

### `viam:MODULE:MODEL`
### `viam:wit-motion:imu-wit`
```json
{
"name": "<your-MODULE-MODEL-COMPONENT-name>",
"model": "viam:MODULE:MODEL",
"type": "COMPONENT",
"name": "<your-wit-motion-imu-wit-movement_sensor-name>",
"model": "viam:wit-motion:imu-wit",
"type": "movement_sensor",
"namespace": "rdk",
"attributes": {
},
Expand All @@ -44,6 +44,6 @@ The following attributes are available for `viam:MODULE:MODEL` COMPONENTs:
```

### Next Steps
- To test your COMPONENT, expand the **TEST** section of its configuration pane or go to the [**CONTROL** tab](https://docs.viam.com/fleet/control/).
- To write code against your COMPONENT, use one of the [available SDKs](https://docs.viam.com/sdks/).
- To view examples using a COMPONENT component, explore [these tutorials](https://docs.viam.com/tutorials/).
- To test your movement_sensor, expand the **TEST** section of its configuration pane or go to the [**CONTROL** tab](https://docs.viam.com/fleet/control/).
- To write code against your movement_sensor, use one of the [available SDKs](https://docs.viam.com/sdks/).
- To view examples using a movement_sensor component, explore [these tutorials](https://docs.viam.com/tutorials/).
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module MODULE
module wit-motion

go 1.23.0

Expand All @@ -7,7 +7,11 @@ require (
github.com/axw/gocov v1.1.0
github.com/edaniels/golinters v0.0.5-0.20220906153528-641155550742
github.com/fullstorydev/grpcurl v1.8.6
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551
github.com/golangci/golangci-lint v1.61.0
github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4
github.com/kellydunn/golang-geo v0.7.0
github.com/pkg/errors v0.9.1
github.com/rhysd/actionlint v1.6.24
go.viam.com/rdk v0.48.2
go.viam.com/utils v0.1.110
Expand Down Expand Up @@ -44,6 +48,7 @@ require (
github.com/alingse/asasalint v0.0.11 // indirect
github.com/ashanbrown/forbidigo v1.6.0 // indirect
github.com/ashanbrown/makezero v1.1.1 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bep/debounce v1.2.1 // indirect
github.com/bkielbasa/cyclop v1.2.1 // indirect
Expand Down Expand Up @@ -111,7 +116,6 @@ require (
github.com/gofrs/flock v0.12.1 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
Expand Down Expand Up @@ -150,7 +154,6 @@ require (
github.com/jjti/go-spancheck v0.6.2 // indirect
github.com/julz/importas v0.1.0 // indirect
github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect
github.com/kellydunn/golang-geo v0.7.0 // indirect
github.com/kisielk/errcheck v1.7.0 // indirect
github.com/kkHAIKE/contextcheck v1.1.5 // indirect
github.com/klauspost/compress v1.16.5 // indirect
Expand Down Expand Up @@ -208,7 +211,6 @@ require (
github.com/pion/stun v0.6.1 // indirect
github.com/pion/transport/v2 v2.2.10 // indirect
github.com/pion/turn/v2 v2.1.6 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.6.0 // indirect
Expand Down
Loading

0 comments on commit 29c7701

Please sign in to comment.