-
Notifications
You must be signed in to change notification settings - Fork 110
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
Conversation
@@ -1,73 +0,0 @@ | |||
import { type Client, commonApi, motionApi } from '@viamrobotics/sdk'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bye bye boilerplate 👋
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oo la la
base, | ||
destination!.x, | ||
destination!.y | ||
{ planDeviationM: 0.5 }, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I don't see the text string
MoveOnMapOptions
in the typescript SDK nor in the RC web app - 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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really appreciate you coming back to do the cleanup!
const lastPose = await slamClient.getPosition(); | ||
const destinationMM = lastPose.pose!; | ||
destinationMM.x = destination!.x * 1000; | ||
destinationMM.y = destination!.y * 1000; | ||
const base = bases[0]!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor stuff] Could we change this to be a little more defensive? In general, we should avoid using the assertion operator !
(in App we have linters against this) because it's unsafe. Maybe we could use the nullish coalescing operator ??
to provide a reasonable default? Or return and display an error?
Ticket