-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Michel Hidalgo <[email protected]>
- Loading branch information
1 parent
f0da3c9
commit f1f7ae9
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright (c) 2024 Boston Dynamics AI Institute LLC. See LICENSE file for more info. | ||
|
||
import grpc | ||
from bosdyn.api.power_pb2 import ( | ||
FanPowerCommandFeedbackRequest, | ||
FanPowerCommandFeedbackResponse, | ||
FanPowerCommandRequest, | ||
FanPowerCommandResponse, | ||
PowerCommandFeedbackRequest, | ||
PowerCommandFeedbackResponse, | ||
PowerCommandRequest, | ||
PowerCommandResponse, | ||
PowerCommandStatus, | ||
) | ||
from bosdyn.api.power_service_pb2_grpc import PowerServiceServicer | ||
from bosdyn.api.robot_state_pb2 import PowerState | ||
|
||
from spot_wrapper.testing.mocks.robot_state import MockRobotStateService | ||
|
||
|
||
class MockPowerService(PowerServiceServicer, MockRobotStateService): | ||
"""A mock Spot power service.""" | ||
|
||
def PowerCommand(self, request: PowerCommandRequest, context: grpc.ServicerContext) -> PowerCommandResponse: | ||
response = PowerCommandResponse() | ||
if request.request == PowerCommandRequest.Request.REQUEST_ON_MOTORS: | ||
self.robot_state.power_state.motor_power_state = PowerState.MotorPowerState.MOTOR_POWER_STATE_ON | ||
response.status = PowerCommandStatus.STATUS_SUCCESS | ||
response.power_command_id = 1 | ||
elif request.request == PowerCommandRequest.Request.REQUEST_OFF_MOTORS: | ||
self.robot_state.power_state.motor_power_state = PowerState.MotorPowerState.MOTOR_POWER_STATE_OFF | ||
response.status = PowerCommandStatus.STATUS_SUCCESS | ||
response.power_command_id = 1 | ||
else: | ||
response.status = PowerCommandStatus.STATUS_INTERNAL_ERROR | ||
return response | ||
|
||
def PowerCommandFeedback( | ||
self, request: PowerCommandFeedbackRequest, context: grpc.ServicerContext | ||
) -> PowerCommandFeedbackResponse: | ||
response = PowerCommandFeedbackResponse() | ||
response.status = PowerCommandStatus.STATUS_SUCCESS | ||
response.power_command_id = request.power_command_id | ||
return response | ||
|
||
def FanPowerCommand( | ||
self, request: FanPowerCommandRequest, context: grpc.ServicerContext | ||
) -> FanPowerCommandResponse: | ||
response = FanPowerCommandResponse() | ||
response.status = FanPowerCommandResponse.Status.STATUS_OK | ||
response.command_id = 2 | ||
return response | ||
|
||
def FanPowerCommandFeedback( | ||
self, request: FanPowerCommandFeedbackRequest, context: grpc.ServicerContext | ||
) -> FanPowerCommandFeedbackResponse: | ||
response = FanPowerCommandFeedbackResponse() | ||
response.status = FanPowerCommandFeedbackResponse.Status.STATUS_COMPLETE | ||
return response |