-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from TrickfireRobotics/missioncontrol-addbases…
…tationstates Missioncontrol addbasestationstates
- Loading branch information
Showing
2 changed files
with
181 additions
and
66 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,25 @@ | ||
import { defineStore } from 'pinia'; | ||
import { createPublisher } from '@/lib/roslibUtils/createPublisher'; | ||
import { ref } from 'vue'; | ||
|
||
export type OperationState = 'disabled' | 'teleoperation' | 'autonomous'; | ||
|
||
export const useOperationStateStore = defineStore('operationType', () => { | ||
const operationStatePublisher = createPublisher({ | ||
topicName: '/setOperationState', | ||
topicType: 'std_msgs/String', | ||
}); | ||
const operationState = ref<OperationState>('disabled'); | ||
|
||
/** | ||
* This function sets the operation state to the specified state and sends out a message on the ros topic to change the state. | ||
* @param state - the new operation state to set the driver to. | ||
*/ | ||
function setOperationState(state: OperationState) { | ||
operationState.value = state; | ||
operationStatePublisher.publish({ data: operationState.value }); | ||
} | ||
|
||
// Return all state, getters and functions | ||
return { operationState, setOperationState }; | ||
}); |