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-6631 - Change RC card to use MoveOnMap typescript SDK wrapper #3574

Closed
wants to merge 3 commits into from
Closed
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
73 changes: 0 additions & 73 deletions web/frontend/src/api/motion.ts

This file was deleted.

36 changes: 30 additions & 6 deletions web/frontend/src/components/slam/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
import { SlamMap2D } from '@viamrobotics/prime-blocks';
import { copyToClipboard } from '@/lib/copy-to-clipboard';
import { filterSubtype } from '@/lib/resource';
import { moveOnMap } from '@/api/motion';
import { notify } from '@viamrobotics/prime';
import { setAsyncInterval } from '@/lib/schedule';
import { components, services } from '@/stores/resources';
Expand Down Expand Up @@ -298,13 +297,38 @@ const toggleAxes = () => {

const handleMoveClick = async () => {
try {
// set pose in frame
const lastPose = await slamClient.getPosition();
nicksanford marked this conversation as resolved.
Show resolved Hide resolved
if (bases[0] == undefined) {
notify.danger("unable to create MoveOnMap request due to no bases existing on the robot");
return
}
const base = bases[0]!;
await moveOnMap(
$robotClient,
slamResourceName,

if (lastPose.pose == undefined) {
notify.danger("unable to create MoveOnMap request due to slam.GetPosition() method returning a null pose");
return
}
const destinationMM = lastPose.pose!;

if (lastPose.pose.x == undefined) {
notify.danger("unable to create MoveOnMap request due to slam.GetPosition() method returning a pose with null x attribute");
return
}
destinationMM.x = destination!.x * 1000;

if (lastPose.pose.y == undefined) {
notify.danger("unable to create MoveOnMap request due to slam.GetPosition() method returning a pose with null y attribute");
return
}
destinationMM.y = destination!.y * 1000;

await motionClient.moveOnMap(
destinationMM,
base,
destination!.x,
destination!.y
slamResourceName,
{ planDeviationM: 0.5 },
Copy link
Member Author

Choose a reason for hiding this comment

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

This is failing a lint error despite working in the browser:
https://github.com/viamrobotics/rdk/actions/runs/7873963113/job/21482471651?pr=3574#step:5:2176

Also, the typescript SDK sets this value in the MotionConfiguration type: https://github.com/viamrobotics/viam-typescript-sdk/blob/main/src/services/motion/types.ts#L88

Do I need to do something in the typescript SDK to placate the type checker?

@micheal-parks @ethanlook

Copy link
Member

Choose a reason for hiding this comment

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

From a quick glance it appears that those addtional props (obstacleDetectorsList, positionPollingFrequencyHz) are not marked as optional and should be? Something like:

interface MoveOnMapOptions {
  planDeviationM: number // if required
  obstacleDetectorsList?: number
  positionPollingFrequencyHz?: number
  ...
}

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. I don't see the text string MoveOnMapOptions in the typescript SDK nor in the RC web app
  2. The type in question is
import pb from '../../gen/service/motion/v1/motion_pb';
...
export type MotionConfiguration = pb.MotionConfiguration.AsObject;

https://github.com/viamrobotics/viam-typescript-sdk/blob/main/src/services/motion/types.ts#L9

That object (at least in vanilla js) knows about planDeviationM: https://github.com/viamrobotics/api/blob/main/gen/js/service/motion/v1/motion_pb.js#L1956 How do I get typescript to believe that that field is a member of the MotionConfiguration type?

{ motion_profile: 'position_only' }
);
await refreshPaths();
} catch (error) {
Expand Down
Loading