Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: viamrobotics/build-action@v1
with:
version: ${{ github.ref_name }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:

- name: Check out main branch code
if: github.event_name != 'pull_request_target'
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check out PR branch code
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ build-go:
tool-install:
GOBIN=`pwd`/$(TOOL_BIN) go install \
github.com/edaniels/golinters/cmd/combined \
github.com/golangci/golangci-lint/cmd/golangci-lint \
github.com/AlekSi/gocov-xml \
github.com/axw/gocov/gocov \
gotest.tools/gotestsum \
Expand All @@ -29,10 +28,12 @@ tool-install:
lint: lint-go
PATH=$(TOOL_BIN) actionlint

GOVERSION = $(shell grep '^go ' go.mod | head -n1 | cut -d' ' -f2)

lint-go: tool-install
go mod tidy
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
GOTOOLCHAIN=go$(GOVERSION) GOGC=50 go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8 run -v --fix --config=./etc/golangci.yaml
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

linter was upset so i just tried copying what was in rdk


test: test-go

Expand Down
24 changes: 13 additions & 11 deletions cloudslam/cloudslam.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,27 @@ func init() {
}

// Validate validates the config for cloudslam.
func (cfg *Config) Validate(path string) ([]string, error) {
func (cfg *Config) Validate(path string) ([]string, []string, error) {
// resource.NewConfigValidationFieldRequiredError(path, "i2c_bus")
if cfg.SLAMService == "" {
return []string{}, resource.NewConfigValidationFieldRequiredError(path, "slam_service")
return []string{}, []string{}, resource.NewConfigValidationFieldRequiredError(path, "slam_service")
}
if cfg.APIKey == "" {
return []string{}, resource.NewConfigValidationFieldRequiredError(path, "api_key")
return []string{}, []string{}, resource.NewConfigValidationFieldRequiredError(path, "api_key")
}
if cfg.APIKeyID == "" {
return []string{}, resource.NewConfigValidationFieldRequiredError(path, "api_key_id")
return []string{}, []string{}, resource.NewConfigValidationFieldRequiredError(path, "api_key_id")
}
if cfg.MachineID == "" {
return []string{}, resource.NewConfigValidationFieldRequiredError(path, "machine_id")
return []string{}, []string{}, resource.NewConfigValidationFieldRequiredError(path, "machine_id")
}
if cfg.LocationID == "" {
return []string{}, resource.NewConfigValidationFieldRequiredError(path, "location_id")
return []string{}, []string{}, resource.NewConfigValidationFieldRequiredError(path, "location_id")
}
if cfg.OrganizationID == "" {
return []string{}, resource.NewConfigValidationFieldRequiredError(path, "organization_id")
return []string{}, []string{}, resource.NewConfigValidationFieldRequiredError(path, "organization_id")
}
return []string{cfg.SLAMService}, nil
return []string{cfg.SLAMService}, []string{}, nil
}

func newSLAM(
Expand All @@ -144,7 +144,7 @@ func newSLAM(
if err != nil {
return nil, err
}
wrappedSLAM, err := slam.FromDependencies(deps, newConf.SLAMService)
wrappedSLAM, err := slam.FromProvider(deps, newConf.SLAMService)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -240,7 +240,8 @@ func (svc *cloudslamWrapper) initialize(mappingMode slam.MappingMode) error {
if err != nil {
return err
}
svc.activeJob.Store(&resp.SessionId)
sessionID := resp.GetSessionId()
svc.activeJob.Store(&sessionID)

svc.workers = goutils.NewBackgroundStoppableWorkers(svc.activeMappingSessionThread)
return nil
Expand Down Expand Up @@ -270,7 +271,8 @@ func (svc *cloudslamWrapper) activeMappingSessionThread(ctx context.Context) {
currPose := spatialmath.NewPoseFromProtobuf(resp.GetPose())

svc.lastPose.Store(&currPose)
svc.lastPointCloudURL.Store(&resp.MapUrl)
mapURL := resp.GetMapUrl()
svc.lastPointCloudURL.Store(&mapURL)
}
}

Expand Down
7 changes: 5 additions & 2 deletions cloudslam/thumbnail.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"math"
"path/filepath"
"strings"

"github.com/golang/geo/r3"
"github.com/montanaflynn/stats"
Expand Down Expand Up @@ -98,13 +99,15 @@ func (svc *cloudslamWrapper) uploadJpeg(
return "", errors.Wrap(err, "received error response while syncing thumbnail")
}

return res.GetFileId(), nil
// BinaryDataId is "org_id/location_id/file_id"; extract just the file_id for the thumbnail URL.
parts := strings.Split(res.GetBinaryDataId(), "/")
return parts[len(parts)-1], nil
}

// pcdToJpeg converts a pointcloud data into a jpeg image.
func pcdToJpeg(pcd []byte) (*bytes.Buffer, error) {
ppRM := NewParallelProjectionOntoXYWithRobotMarker(nil)
pc, err := pointcloud.ReadPCD(bytes.NewBuffer(pcd))
pc, err := pointcloud.ReadPCD(bytes.NewBuffer(pcd), "")
if err != nil {
return nil, errors.Wrapf(err, "converting pcd to pointcloud")
}
Expand Down
2 changes: 0 additions & 2 deletions etc/golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ service:
run:
deadline: 900s
modules-download-mode: readonly
skip-dirs-use-default: false
tests: true
linters:
enable-all: true
Expand Down Expand Up @@ -64,7 +63,6 @@ linters-settings:
- default
- prefix(cloudslam-module)
gofumpt:
lang-version: "1.21"
extra-rules: true
govet:
enable-all: true
Expand Down
Loading
Loading