Skip to content

Commit

Permalink
RSDK-9465, RSDK-9366 - Remove robot status and sensors service (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheukt authored Dec 11, 2024
1 parent 9ec3629 commit 4caca97
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 121 deletions.
20 changes: 0 additions & 20 deletions e2e/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,6 @@ const main = async () => {
resNamesDiv.append(resNameDiv);
}
document.body.append(resNamesDiv);

const stream = machine.streamStatus(resourceNames);
const statusesDiv = document.createElement('div');
statusesDiv.dataset.testid = 'statuses';

let i = 0;
for await (const statuses of stream) {
for await (const status of statuses) {
const statusDiv = document.createElement('div');
statusDiv.textContent = status.toJsonString();
statusDiv.dataset.testid = 'status';
statusesDiv.append(statusDiv);
}

i += 1;
if (i >= 3) {
break;
}
}
document.body.append(statusesDiv);
};

main().catch(console.error); // eslint-disable-line no-console
4 changes: 0 additions & 4 deletions e2e/tests/connect-and-status.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@ test('check resource names and multiple statuses', async ({ page }) => {
await expect(resourceNames.getByText('base1')).toHaveCount(1);
await expect(resourceNames.getByText('servo1')).toHaveCount(1);
await expect(resourceNames.getByText('builtin')).toHaveCount(1);

// 3 status iterations * 3 resource names (see main.ts for loop)
const statuses = page.getByTestId('statuses').getByTestId('status');
await expect(statuses).toHaveCount(9);
});
29 changes: 0 additions & 29 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,35 +246,6 @@ export * as powerSensorApi from './gen/component/powersensor/v1/powersensor_pb';
export { SensorClient, type Sensor } from './components/sensor';
export * as sensorApi from './gen/component/sensor/v1/sensor_connect';

/**
* Raw Protobuf interfaces for a Sensors service.
*
* Generated with https://github.com/connectrpc/connect-es
*
* @example
*
* ```ts
* import { grpc } from '@improbable-eng/grpc-web';
*
* const client = {}; // replace with a connected robot client
*
* const request = new sensorsApi.GetSensorsRequest();
* request.setName('mysensors');
*
* client.sensorsService.getSensors(
* request,
* new grpc.Metadata(),
* (error, response) => {
* // do something with error or response
* }
* );
* ```
*
* @alpha
* @group Raw Protobufs
*/
export * as sensorsApi from './gen/service/sensors/v1/sensors_pb';

/**
* Raw Protobuf interfaces for a Stream.
*
Expand Down
44 changes: 1 addition & 43 deletions src/robot/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-classes-per-file */
import { Duration, type ServiceType } from '@bufbuild/protobuf';
import { type ServiceType } from '@bufbuild/protobuf';
import {
createPromiseClient,
type PromiseClient,
Expand All @@ -26,17 +26,14 @@ import { RobotService } from '../gen/robot/v1/robot_connect';
import {
DiscoveryQuery,
RestartModuleRequest,
Status,
TransformPCDRequest,
TransformPoseRequest,
} from '../gen/robot/v1/robot_pb';
import { MotionService } from '../gen/service/motion/v1/motion_connect';
import { NavigationService } from '../gen/service/navigation/v1/navigation_connect';
import { SensorsService } from '../gen/service/sensors/v1/sensors_connect';
import { SLAMService } from '../gen/service/slam/v1/slam_connect';
import { VisionService } from '../gen/service/vision/v1/vision_connect';
import { dialDirect, dialWebRTC, type DialOptions } from '../rpc';
import type { ResourceName } from '../types';
import { clientHeaders } from '../utils';
import GRPCConnectionManager from './grpc-connection-manager';
import type { Robot } from './robot';
Expand Down Expand Up @@ -140,10 +137,6 @@ export class RobotClient extends EventDispatcher implements Robot {

private visionServiceClient: PromiseClient<typeof VisionService> | undefined;

private sensorsServiceClient:
| PromiseClient<typeof SensorsService>
| undefined;

private servoServiceClient: PromiseClient<typeof ServoService> | undefined;

private slamServiceClient: PromiseClient<typeof SLAMService> | undefined;
Expand Down Expand Up @@ -366,13 +359,6 @@ export class RobotClient extends EventDispatcher implements Robot {
return this.visionServiceClient;
}

get sensorsService() {
if (!this.sensorsServiceClient) {
throw new Error(RobotClient.notConnectedYetStr);
}
return this.sensorsServiceClient;
}

get servoService() {
if (!this.servoServiceClient) {
throw new Error(RobotClient.notConnectedYetStr);
Expand Down Expand Up @@ -609,10 +595,6 @@ export class RobotClient extends EventDispatcher implements Robot {
VisionService,
clientTransport
);
this.sensorsServiceClient = createPromiseClient(
SensorsService,
clientTransport
);
this.servoServiceClient = createPromiseClient(
ServoService,
clientTransport
Expand Down Expand Up @@ -737,30 +719,6 @@ export class RobotClient extends EventDispatcher implements Robot {
return resp.resourceRpcSubtypes;
}

// STATUS

async getStatus(resourceNames: ResourceName[] = []) {
const resp = await this.robotService.getStatus({
resourceNames,
});
return resp.status;
}

async *streamStatus(
resourceNames: ResourceName[] = [],
durationMs = 500
): AsyncIterable<Status[]> {
const stream = this.robotService.streamStatus({
resourceNames,
every: new Duration({
nanos: durationMs * 1e6,
}),
});
for await (const val of stream) {
yield val.status;
}
}

// MODULES

async restartModule(moduleId?: string, moduleName?: string) {
Expand Down
25 changes: 0 additions & 25 deletions src/robot/robot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,31 +129,6 @@ export interface Robot {
*/
resourceRPCSubtypes(): Promise<proto.ResourceRPCSubtype[]>;

/**
* Get a list of all statuses requested. An empty request signifies all
* resources.
*
* @param resourceNames - The list of resources for which to receive statuses.
* @group Status
* @alpha
*/
getStatus(resourceNames?: ResourceName[]): Promise<proto.Status[]>;

/**
* Periodically receive the status of all statuses requested. An empty request
* signifies all resources.
*
* @param resourceNames - The list of resources for which to receive statuses.
* Default is [].
* @param duration - How often to send a new status. Default is 0.5 seconds.
* @group Status
* @alpha
*/
streamStatus(
resourceNames?: ResourceName[],
durationMs?: number
): AsyncIterable<proto.Status[]>;

/**
* Call a function when a connection event occurs.
*
Expand Down

0 comments on commit 4caca97

Please sign in to comment.