Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera Names to Integration #693

Open
wants to merge 6 commits into
base: integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion config/teleop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,24 @@ teleop:
ik_multipliers:
x: 0.1
y: 0.1
z: 0.1
z: 0.1

cameras:
- name: "ZED"
port: 0
- name: "Long Range Camera"
port: 1
- name: "Mast Gimbal Camera"
port: 2
- name: "Suspension Camera"
port: 3
- name: "ISH Camera 1"
port: 4
- name: "ISH Camera 2"
port: 5
- name: "ISH Camera 3"
port: 6
- name: "SA Camera 1"
port: 7
- name: "SA Camera 2"
port: 8
8 changes: 8 additions & 0 deletions src/teleoperation/backend/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def connect(self):
self.brushed_motors = rospy.get_param("brushed_motors/controllers")
self.xbox_mappings = rospy.get_param("teleop/xbox_mappings")
self.sa_config = rospy.get_param("teleop/sa_controls")
self.camera_info = rospy.get_param("teleop/cameras")

# Publishers
self.twist_pub = rospy.Publisher("/cmd_vel", Twist, queue_size=1)
Expand Down Expand Up @@ -193,6 +194,8 @@ def receive(self, text_data):
self.mast_gimbal(message)
elif message["type"] == "max_streams":
self.send_res_streams()
elif message["type"] == "camera_info":
self.send_camera_info()
elif message["type"] == "sendCameras":
self.change_cameras(message)
elif message["type"] == "takePanorama":
Expand Down Expand Up @@ -683,6 +686,11 @@ def send_res_streams(self):
self.send(text_data=json.dumps({"type": "max_resolution", "res": res}))
self.send(text_data=json.dumps({"type": "max_streams", "streams": streams}))

def send_camera_info(self):
names = [x["name"] for x in self.camera_info]
ports = [x["port"] for x in self.camera_info]
self.send(text_data=json.dumps({"type": "camera_info", "names": names, "ports": ports}))

def capture_panorama(self) -> None:
try:
response = self.capture_panorama_srv()
Expand Down
Binary file modified src/teleoperation/db.sqlite3
Binary file not shown.
6 changes: 5 additions & 1 deletion src/teleoperation/frontend/src/components/CameraDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="grid-container">
<div v-for="i in 4" :key="i" :class="'feed' + i">
<div v-if="i <= numStreams">
<CameraFeed :mission="mission" :id="getID(i)" :name="names[getID(i)]"></CameraFeed>
<CameraFeed :mission="mission" :id="ports[getID(i)]" :name="names[getID(i)]"></CameraFeed>
</div>
</div>
</div>
Expand All @@ -23,6 +23,10 @@ export default defineComponent({
type: Array,
required: true
},
ports: {
type: Array,
required: true
},
streamOrder: {
//array of camera indices to stream. -1 indicates not used
type: Array,
Expand Down
4 changes: 3 additions & 1 deletion src/teleoperation/frontend/src/components/CameraFeed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import {defineComponent} from 'vue'
import {mapActions} from 'vuex'
import Checkbox from './Checkbox.vue'
import CameraSelection from './CameraSelection.vue'

export default defineComponent({
props: {
Expand All @@ -28,7 +29,8 @@ export default defineComponent({
}
},
components: {
Checkbox
Checkbox,
CameraSelection
},

data() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default {
names: {
type: Array,
required: true
}
},
},
data() {
return {
Expand Down
42 changes: 11 additions & 31 deletions src/teleoperation/frontend/src/components/Cameras.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
<template>
<div class="wrap row">
<div class="col">
<div class="row justify-content-md-left">
<div class="form-group col-md-4">
<label for="Camera Name">Camera name</label>
<input
v-model="cameraName"
type="message"
class="form-control"
id="CameraName"
placeholder="Enter Camera Name"
/>
<small id="cameraDescrip" class="form-text text-muted"></small>
</div>
<div class="form-group col-md-4">
<label for="Camera ID">Camera ID</label>
<input
v-model="cameraIdx"
type="number"
min="0"
max="8"
class="form-control"
id="CameraIdx"
placeholder="Camera ID"
/>
</div>
<button class="btn btn-primary custom-btn" @click="addCameraName()">Change Name</button>
</div>
<div class="cameraselection">
<div class="cameraselection">
<CameraSelection
:cams-enabled="camsEnabled"
:names="names"
Expand All @@ -44,7 +18,7 @@
</button>
</div>
</div>
<CameraDisplay :streamOrder="streamOrder" :mission="mission" :names="names"></CameraDisplay>
<CameraDisplay :streamOrder="streamOrder" :mission="mission" :names="names" :ports="ports" :qualities="qualities"></CameraDisplay>
</div>
</template>

Expand All @@ -68,12 +42,13 @@ export default {
mission: {
type: String, // {'sa', 'ik', 'other'}
required: true
}
},
},
data() {
return {
camsEnabled: reactive(new Array(9).fill(false)),
names: reactive(Array.from({ length: 9 }, (_, i) => 'Camera: ' + i)),
names: reactive([]),
ports: reactive([]),
cameraIdx: 0,
cameraName: '',
capacity: 4,
Expand All @@ -86,6 +61,10 @@ export default {
if (msg.type == 'max_streams') {
this.streamOrder = new Array(msg.streams).fill(-1)
}
if (msg.type == 'camera_info') {
this.names = msg.names
this.ports = msg.ports
}
},
capacity: function (newCap, oldCap) {
if (newCap < oldCap) {
Expand All @@ -105,7 +84,8 @@ export default {

created: function () {
window.setTimeout(() => {
this.sendMessage({ type: 'max_streams' })
this.sendMessage({ type: 'max_streams' }),
this.sendMessage({ type: 'camera_info' })
}, 250)
},

Expand Down