-
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.
[missioncontrol][addbasestationstates] Tied input from the UI element…
… to the store and set up ROS topic publishing.
- Loading branch information
Quashnock
committed
Dec 22, 2024
1 parent
39dfb79
commit 503b6bf
Showing
2 changed files
with
28 additions
and
27 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 |
---|---|---|
@@ -1,16 +1,20 @@ | ||
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'); | ||
function setOperationMode(status: OperationState) { | ||
operationState.value = status; | ||
alert(`Mode Changed: ${status}`); | ||
|
||
// Sets the operation state to the specified state and sends out a message on the ros topic to change the state. | ||
function setOperationState(state: OperationState) { | ||
operationState.value = state; | ||
operationStatePublisher.publish({data: operationState.value}); | ||
} | ||
|
||
// Return all state, getters and functions | ||
return {operationState, setOperationMode}; | ||
return {operationState, setOperationState}; | ||
}); |