Skip to content
Merged
117 changes: 16 additions & 101 deletions src/services/motion/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ import {
MoveRequest,
StopPlanRequest,
} from '../../gen/service/motion/v1/motion_pb';
import {
GeoGeometry,
GeoPoint,
Pose,
PoseInFrame,
ResourceName,
} from '../../types';
import { GeoGeometry, GeoPoint, Pose, PoseInFrame } from '../../types';
import { MotionClient } from './client';
import {
Constraints,
Expand Down Expand Up @@ -53,18 +47,8 @@ describe('moveOnGlobe', () => {
const expectedDestination = new GeoPoint({ latitude: 1, longitude: 2 });
const expectedObstaclesList: ObstacleDetector[] = [];
const expectedHeading = undefined;
const expectedComponentName = new ResourceName({
namespace: 'viam',
type: 'component',
subtype: 'base',
name: 'myBase',
});
const expectedMovementSensorName = new ResourceName({
namespace: 'viam',
type: 'component',
subtype: 'movementsensor',
name: 'myMovementsensor',
});
const expectedComponentName = 'myBase';
const expectedMovementSensorName = 'myMovementsensor';
const expectedMotionConfiguration = undefined;
const expectedExtra = {};

Expand All @@ -89,22 +73,8 @@ describe('moveOnGlobe', () => {
await expect(
motion.moveOnGlobe(
{ latitude: 1, longitude: 2 },
{
namespace: 'viam',
type: 'component',
subtype: 'base',
name: 'myBase',
remotePath: [],
localName: '',
},
{
namespace: 'viam',
type: 'component',
subtype: 'movementsensor',
name: 'myMovementsensor',
remotePath: [],
localName: '',
}
'myBase',
'myMovementsensor'
)
).resolves.toStrictEqual(testExecutionId);

Expand Down Expand Up @@ -179,33 +149,13 @@ describe('moveOnGlobe', () => {
}),
];
const expectedHeading = 60;
const expectedComponentName = new ResourceName({
namespace: 'viam',
type: 'component',
subtype: 'base',
name: 'myBase',
});
const expectedMovementSensorName = new ResourceName({
namespace: 'viam',
type: 'component',
subtype: 'movementsensor',
name: 'myMovementsensor',
});
const expectedComponentName = 'myBase';
const expectedMovementSensorName = 'myMovementsensor';
const expectedMotionConfiguration = new MotionConfiguration({
obstacleDetectors: [
{
visionService: {
namespace: 'viam',
type: 'service',
subtype: 'vision',
name: 'myVisionService',
},
camera: {
namespace: 'viam',
type: 'component',
subtype: 'camera',
name: 'myCamera',
},
visionService: 'myVisionService',
camera: 'myCamera',
},
],
positionPollingFrequencyHz: 20,
Expand Down Expand Up @@ -267,12 +217,7 @@ describe('moveOnGlobe', () => {

describe('move', () => {
it('sends a move request with pseudolinear constraints', async () => {
const expectedComponentName = new ResourceName({
namespace: 'viam',
type: 'component',
subtype: 'base',
name: 'myBase',
});
const expectedComponentName = 'myBase';
const expectedDestination = new PoseInFrame({
referenceFrame: 'world',
pose: new Pose({
Expand Down Expand Up @@ -325,12 +270,7 @@ describe('move', () => {

describe('stopPlan', () => {
it('return null', async () => {
const expectedComponentName = new ResourceName({
namespace: 'viam',
type: 'component',
subtype: 'base',
name: 'myBase',
});
const expectedComponentName = 'myBase';
const expectedExtra = {};

let capturedReq: StopPlanRequest | undefined;
Expand All @@ -357,12 +297,7 @@ describe('stopPlan', () => {
});

it('allows optionally specifying extra', async () => {
const expectedComponentName = new ResourceName({
namespace: 'viam',
type: 'component',
subtype: 'base',
name: 'myBase',
});
const expectedComponentName = 'myBase';
const expectedExtra = { some: 'extra' };
let capturedReq: StopPlanRequest | undefined;
const mockTransport = createRouterTransport(({ service }) => {
Expand Down Expand Up @@ -393,12 +328,7 @@ describe('getPlan', () => {
currentPlanWithStatus: {
plan: {
id: 'planId',
componentName: {
namespace: 'viam',
type: 'component',
subtype: 'base',
name: 'myBase',
},
componentName: 'myBase',
executionId: 'executionId',
steps: [
{
Expand Down Expand Up @@ -428,12 +358,7 @@ describe('getPlan', () => {
});

it('return GetPlanResponse', async () => {
const expectedComponentName = new ResourceName({
namespace: 'viam',
type: 'component',
subtype: 'base',
name: 'myBase',
});
const expectedComponentName = 'myBase';
const expectedLastPlanOnly = false;
const expectedExecutionID = undefined;
const expectedExtra = {};
Expand Down Expand Up @@ -463,12 +388,7 @@ describe('getPlan', () => {
});

it('allows optionally specifying lastPlanOnly, executionID, and extra', async () => {
const expectedComponentName = new ResourceName({
namespace: 'viam',
type: 'component',
subtype: 'base',
name: 'myBase',
});
const expectedComponentName = 'myBase';
const expectedLastPlanOnly = true;
const expectedExecutionID = 'some specific executionID';
const expectedExtra = { some: 'extra' };
Expand Down Expand Up @@ -508,12 +428,7 @@ describe('listPlanStatuses', () => {
planStatusesWithIds: [
{
planId: 'some plan id',
componentName: {
namespace: 'viam',
type: 'component',
subtype: 'base',
name: 'myBase',
},
componentName: 'myBase',
executionId: 'some execution id',
status: {
state: PlanState.STOPPED,
Expand Down
17 changes: 8 additions & 9 deletions src/services/motion/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import type {
Options,
Pose,
PoseInFrame,
ResourceName,
Transform,
WorldState,
} from '../../types';
Expand All @@ -45,7 +44,7 @@ export class MotionClient implements Motion {

async move(
destination: PoseInFrame,
componentName: ResourceName,
componentName: string,
worldState?: WorldState,
constraints?: Constraints,
extra = {},
Expand All @@ -68,8 +67,8 @@ export class MotionClient implements Motion {

async moveOnMap(
destination: Pose,
componentName: ResourceName,
slamServiceName: ResourceName,
componentName: string,
slamServiceName: string,
motionConfig?: MotionConfiguration,
obstacles?: Geometry[],
extra = {},
Expand All @@ -93,8 +92,8 @@ export class MotionClient implements Motion {

async moveOnGlobe(
destination: GeoPoint,
componentName: ResourceName,
movementSensorName: ResourceName,
componentName: string,
movementSensorName: string,
heading?: number,
obstaclesList?: GeoGeometry[],
motionConfig?: MotionConfiguration,
Expand All @@ -121,7 +120,7 @@ export class MotionClient implements Motion {
}

async stopPlan(
componentName: ResourceName,
componentName: string,
extra = {},
callOptions = this.callOptions
) {
Expand All @@ -138,7 +137,7 @@ export class MotionClient implements Motion {
}

async getPlan(
componentName: ResourceName,
componentName: string,
lastPlanOnly?: boolean,
executionId?: string,
extra = {},
Expand Down Expand Up @@ -174,7 +173,7 @@ export class MotionClient implements Motion {
}

async getPose(
componentName: ResourceName,
componentName: string,
destinationFrame: string,
supplementalTransforms: Transform[],
extra = {},
Expand Down
Loading