Skip to content

Commit

Permalink
Pos extra (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnN193 authored May 28, 2024
1 parent ee4ea28 commit bf57db5
Show file tree
Hide file tree
Showing 16 changed files with 381 additions and 392 deletions.
15 changes: 3 additions & 12 deletions cartofacade/capi.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ type Position struct {
Imag float64
Jmag float64
Kmag float64

ComponentReference string
}

// LidarConfig represents the lidar configuration
Expand All @@ -93,10 +91,9 @@ const (

// CartoConfig contains config values from app
type CartoConfig struct {
Camera string
MovementSensor string
ComponentReference string
LidarConfig LidarConfig
Camera string
MovementSensor string
LidarConfig LidarConfig

EnableMapping bool
ExistingMap string
Expand Down Expand Up @@ -358,8 +355,6 @@ func getTestPositionResponse() C.viam_carto_get_position_response {

gpr.real = C.double(1100)

gpr.component_reference = goStringToBstring("C++ component reference")

return gpr
}

Expand Down Expand Up @@ -440,8 +435,6 @@ func toPositionResponse(value C.viam_carto_get_position_response) Position {
Imag: float64(value.imag),
Jmag: float64(value.jmag),
Kmag: float64(value.kmag),

ComponentReference: bstringToGoString(value.component_reference),
}
}

Expand Down Expand Up @@ -523,8 +516,6 @@ func toError(status C.int) error {
return errors.New("VIAM_CARTO_SLAM_MODE_INVALID")
case C.VIAM_CARTO_LIDAR_CONFIG_INVALID:
return errors.New("VIAM_CARTO_LIDAR_CONFIG_INVALID")
case C.VIAM_CARTO_COMPONENT_REFERENCE_INVALID:
return errors.New("VIAM_CARTO_COMPONENT_REFERENCE_INVALID")
case C.VIAM_CARTO_LUA_CONFIG_NOT_FOUND:
return errors.New("VIAM_CARTO_LUA_CONFIG_NOT_FOUND")
case C.VIAM_CARTO_INTERNAL_STATE_FILE_SYSTEM_ERROR:
Expand Down
6 changes: 1 addition & 5 deletions cartofacade/capi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func TestPositionResponse(t *testing.T) {
gpr := getTestPositionResponse()
t.Run("position response properly converted between C and go", func(t *testing.T) {
holder := toPositionResponse(gpr)
test.That(t, holder.ComponentReference, test.ShouldEqual, "C++ component reference")

test.That(t, holder.X, test.ShouldEqual, 100)
test.That(t, holder.Y, test.ShouldEqual, 200)
Expand Down Expand Up @@ -215,7 +214,7 @@ func TestCGoAPIWithoutMovementSensor(t *testing.T) {
cfgBad := GetBadTestConfig()
vc, err = NewCarto(cfgBad, algoCfg, &pvcl)
// initialize viam_carto incorrectly
test.That(t, err, test.ShouldResemble, errors.New("VIAM_CARTO_COMPONENT_REFERENCE_INVALID"))
test.That(t, err, test.ShouldResemble, errors.New("VIAM_CARTO_LIDAR_CONFIG_INVALID"))
test.That(t, vc, test.ShouldNotBeNil)

algoCfg = GetTestAlgoConfig(false)
Expand Down Expand Up @@ -342,7 +341,6 @@ func TestCGoAPIWithoutMovementSensor(t *testing.T) {
// test position zeroed
position, err = vc.position()
test.That(t, err, test.ShouldBeNil)
test.That(t, position.ComponentReference, test.ShouldEqual, "my-lidar")
positionIsZero(t, position)

// test pointCloudMap now returns a non empty result
Expand All @@ -369,7 +367,6 @@ func TestCGoAPIWithoutMovementSensor(t *testing.T) {
// test position, is no longer zeroed
position, err = vc.position()
test.That(t, err, test.ShouldBeNil)
test.That(t, position.ComponentReference, test.ShouldEqual, "my-lidar")
test.That(t, position.X, test.ShouldNotEqual, 0)
test.That(t, position.Y, test.ShouldNotEqual, 0)
test.That(t, position.Z, test.ShouldEqual, 0)
Expand Down Expand Up @@ -604,7 +601,6 @@ func TestCGoAPIWithMovementSensor(t *testing.T) {
// test position is not zeroed
position, err = vc.position()
test.That(t, err, test.ShouldBeNil)
test.That(t, position.ComponentReference, test.ShouldEqual, "my-lidar")
test.That(t, r3.Vector{X: position.X, Y: position.Y, Z: position.Z}, test.ShouldNotResemble, r3.Vector{X: 0, Y: 0, Z: 0})

// test pointCloudMap returns a non empty result
Expand Down
11 changes: 5 additions & 6 deletions cartofacade/testhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package cartofacade
// GetTestConfig gets a sample config for testing purposes.
func GetTestConfig(cameraName, movementSensorName, filename string, enableMapping bool) CartoConfig {
return CartoConfig{
Camera: cameraName,
MovementSensor: movementSensorName,
ComponentReference: "component",
LidarConfig: TwoD,
EnableMapping: enableMapping,
ExistingMap: filename,
Camera: cameraName,
MovementSensor: movementSensorName,
LidarConfig: TwoD,
EnableMapping: enableMapping,
ExistingMap: filename,
}
}

Expand Down
42 changes: 40 additions & 2 deletions etc/golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ linters:
- contextcheck
- cyclop
- deadcode
- depguard
- exhaustivestruct
- exhaustruct
- forcetypeassert
- funlen
- gocognit
- gocritic
- godox
- goerr113
- gochecknoglobals
Expand All @@ -36,6 +36,7 @@ linters:
- maligned
- makezero
- musttag
- nakedret
- nestif
- nlreturn
- nosnakecase
Expand All @@ -60,8 +61,12 @@ linters-settings:
- standard
- default
- prefix(github.com/viamrobotics/viam-cartographer)
gocritic:
enabled-tags:
disabled-checks:
- dupSubExpr
gofumpt:
lang-version: "1.19"
lang-version: "1.21"
extra-rules: true
gosec:
excludes:
Expand All @@ -71,6 +76,39 @@ linters-settings:
disable:
- fieldalignment
- shadow
- composites
revive:
# Unfortunately configuring a single rules disables all other rules, even
# if we set `enable-all: true`
#
# To get around this, we include default rules:
# https://github.com/mgechev/revive/blob/master/defaults.toml
rules:
- name: blank-imports
- name: context-as-argument
disabled: false
arguments:
- allowTypesBefore: "testing.TB,*testing.T,*testing.B,*testing.F"
- name: context-keys-type
- name: dot-imports
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
- name: increment-decrement
- name: indent-error-flow
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
- name: unexported-return
- name: unreachable-code
- name: var-declaration
- name: var-naming
lll:
line-length: 140
issues:
Expand Down
Loading

0 comments on commit bf57db5

Please sign in to comment.