Skip to content

Commit

Permalink
Migrate to connect-es (#4417)
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniels authored Oct 7, 2024
1 parent 2d83228 commit 036ed32
Show file tree
Hide file tree
Showing 53 changed files with 732 additions and 1,137 deletions.
103 changes: 38 additions & 65 deletions web/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions web/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,16 @@
},
"peerDependencies": {
"@floating-ui/dom": "^1.5.3",
"@improbable-eng/grpc-web": ">=0.15",
"@viamrobotics/prime": ">=0.5",
"@viamrobotics/rpc": ">=0.2",
"@viamrobotics/sdk": "0.25.0",
"google-protobuf": ">=3",
"maplibre-gl": ">=4",
"tailwindcss": ">=3.3",
"three": ">=0.167"
},
"devDependencies": {
"@improbable-eng/grpc-web": "0.15.0",
"@mdi/js": "7.2.96",
"@sveltejs/vite-plugin-svelte": "^2.4.4",
"@threlte/core": "^7.3.1",
"@threlte/extras": "^8.11.5",
"@types/google-protobuf": "3.15.6",
"@types/lodash-es": "^4.17.12",
"@types/three": "0.167.2",
"@typescript-eslint/eslint-plugin": "^6.9.0",
Expand All @@ -59,8 +53,7 @@
"@viamrobotics/prime": "0.5.9",
"@viamrobotics/prime-blocks": "^0.1.3",
"@viamrobotics/prime-core": "^0.0.87",
"@viamrobotics/rpc": "0.2.3",
"@viamrobotics/sdk": "0.25.0",
"@viamrobotics/sdk": "0.26.0",
"@viamrobotics/three": "^0.0.3",
"@viamrobotics/typescript-config": "^0.1.0",
"cypress": "12.17.3",
Expand All @@ -70,7 +63,6 @@
"eslint-plugin-svelte": "^2.34.0",
"eslint-plugin-tailwindcss": "3.13.0",
"eslint-plugin-unicorn": "48.0.1",
"google-protobuf": "3.21.2",
"jshashes": "1.0.8",
"lodash-es": "^4.17.21",
"maplibre-gl": "^4.6.0",
Expand Down
51 changes: 0 additions & 51 deletions web/frontend/src/api/do-command.ts

This file was deleted.

97 changes: 23 additions & 74 deletions web/frontend/src/api/encoder.ts
Original file line number Diff line number Diff line change
@@ -1,87 +1,36 @@
import { type Client, encoderApi } from '@viamrobotics/sdk';
import { rcLogConditionally } from '@/lib/log';
import {
EncoderClient,
EncoderPositionType,
type Client,
} from '@viamrobotics/sdk';

export const getProperties = async (robotClient: Client, name: string) => {
const request = new encoderApi.GetPropertiesRequest();
request.setName(name);

rcLogConditionally(request);

const response = await new Promise<encoderApi.GetPropertiesResponse | null>(
(resolve, reject) => {
robotClient.encoderService.getProperties(request, (error, res) => {
if (error) {
reject(error);
} else {
resolve(res);
}
});
}
);

return response?.toObject();
const client = new EncoderClient(robotClient, name, {
requestLogger: rcLogConditionally,
});
return client.getProperties();
};

export const getPosition = async (robotClient: Client, name: string) => {
const request = new encoderApi.GetPositionRequest();
request.setName(name);

rcLogConditionally(request);

const response = await new Promise<encoderApi.GetPositionResponse | null>(
(resolve, reject) => {
robotClient.encoderService.getPosition(request, (error, res) => {
if (error) {
reject(error);
} else {
resolve(res);
}
});
}
);

return response?.toObject().value;
const client = new EncoderClient(robotClient, name, {
requestLogger: rcLogConditionally,
});
const resp = await client.getPosition();
return resp[0];
};

export const getPositionDegrees = async (robotClient: Client, name: string) => {
const request = new encoderApi.GetPositionRequest();
request.setName(name);
request.setPositionType(2);

rcLogConditionally(request);

const response = await new Promise<encoderApi.GetPositionResponse | null>(
(resolve, reject) => {
robotClient.encoderService.getPosition(request, (error, res) => {
if (error) {
reject(error);
} else {
resolve(res);
}
});
}
);

return response?.toObject().value;
const client = new EncoderClient(robotClient, name, {
requestLogger: rcLogConditionally,
});
const resp = await client.getPosition(EncoderPositionType.ANGLE_DEGREES);
return resp[0];
};

export const reset = async (robotClient: Client, name: string) => {
const request = new encoderApi.ResetPositionRequest();
request.setName(name);

rcLogConditionally(request);

const response = await new Promise<encoderApi.ResetPositionResponse | null>(
(resolve, reject) => {
robotClient.encoderService.resetPosition(request, (error, res) => {
if (error) {
reject(error);
} else {
resolve(res);
}
});
}
);

return response?.toObject();
const client = new EncoderClient(robotClient, name, {
requestLogger: rcLogConditionally,
});
return client.resetPosition();
};
Loading

0 comments on commit 036ed32

Please sign in to comment.