Skip to content

Commit b1a2b84

Browse files
authored
teleop tag_id fix (#165)
1 parent f62933b commit b1a2b84

File tree

6 files changed

+25
-35
lines changed

6 files changed

+25
-35
lines changed

teleoperation/basestation_gui/backend/models_pydantic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class BasicWaypointList(BaseModel):
1212

1313
class AutonWaypoint(BaseModel):
1414
name: str
15-
id: int = -1
15+
tag_id: int = -1
1616
type: int = 0
1717
lat: float = 0.0
1818
lon: float = 0.0

teleoperation/basestation_gui/backend/routes/waypoints.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ def get_auton_waypoints():
6262
results = []
6363
for w in waypoints:
6464
wd = dict(w)
65-
wd['db_id'] = wd['id']
66-
wd['id'] = wd.pop('tag_id')
65+
wd['db_id'] = wd.pop('id')
6766
wd['lat'] = wd.pop('latitude')
6867
wd['lon'] = wd.pop('longitude')
6968
wd['enable_costmap'] = bool(wd['enable_costmap'])
@@ -93,12 +92,12 @@ def save_auton_waypoints(data: AutonWaypointList):
9392
UPDATE auton_waypoints
9493
SET name=?, tag_id=?, type=?, latitude=?, longitude=?, enable_costmap=?
9594
WHERE id=?
96-
''', (w.name, w.id, w.type, w.lat, w.lon, w.enable_costmap, w.db_id))
95+
''', (w.name, w.tag_id, w.type, w.lat, w.lon, w.enable_costmap, w.db_id))
9796
elif w.deletable:
9897
conn.execute('''
9998
INSERT INTO auton_waypoints (name, tag_id, type, latitude, longitude, enable_costmap, deletable)
10099
VALUES (?, ?, ?, ?, ?, ?, ?)
101-
''', (w.name, w.id, w.type, w.lat, w.lon, w.enable_costmap, w.deletable))
100+
''', (w.name, w.tag_id, w.type, w.lat, w.lon, w.enable_costmap, w.deletable))
102101

103102
conn.commit()
104103
return {'status': 'success'}
@@ -138,6 +137,7 @@ def get_current_auton_course():
138137
results = []
139138
for w in course:
140139
wd = dict(w)
140+
del wd['id']
141141
wd['lat'] = wd.pop('latitude')
142142
wd['lon'] = wd.pop('longitude')
143143
wd['enable_costmap'] = bool(wd['enable_costmap'])
@@ -163,7 +163,7 @@ def save_current_auton_course(data: AutonWaypointList):
163163
VALUES (?, ?, ?, ?, ?, ?, ?)
164164
''', (
165165
w.name,
166-
w.id,
166+
w.tag_id,
167167
w.type,
168168
w.lat,
169169
w.lon,

teleoperation/basestation_gui/frontend/src/components/AutonWaypointEditor.vue

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<div class="waypoint-wrapper overflow-y-scroll flex-grow-1">
1212
<WaypointStore
1313
v-for="(waypoint, index) in waypoints"
14-
:key="waypoint.id || index"
14+
:key="waypoint.tag_id || index"
1515
:waypoint="waypoint"
1616
:index="index"
1717
@add="addToRoute"
@@ -92,7 +92,7 @@
9292
v-if="modalWypt.type == 1"
9393
class="form-control"
9494
id="waypointid"
95-
v-model="modalWypt.id"
95+
v-model="modalWypt.tag_id"
9696
type="number"
9797
max="249"
9898
min="0"
@@ -175,15 +175,16 @@ export default defineComponent({
175175
modal: null as Modal | null,
176176
modalWypt: {
177177
name: '',
178-
id: -1,
178+
tag_id: -1,
179179
type: 0,
180180
lat: 0,
181181
lon: 0,
182182
enable_costmap: true,
183183
},
184184
185185
allCostmapToggle: true,
186-
nextAvailableTagId: 8,
186+
saveWaypointsTimer: null as ReturnType<typeof setTimeout> | null,
187+
saveRouteTimer: null as ReturnType<typeof setTimeout> | null,
187188
}
188189
},
189190
@@ -229,7 +230,10 @@ export default defineComponent({
229230
// Update map visualization
230231
const mapPoints = newRoute.map(waypoint => ({
231232
latLng: L.latLng(waypoint.lat, waypoint.lon),
232-
name: waypoint.name
233+
name: waypoint.name,
234+
tag_id: waypoint.tag_id,
235+
type: waypoint.type,
236+
enable_costmap: waypoint.enable_costmap
233237
}))
234238
this.autonomyStore.setRoute(mapPoints)
235239
@@ -256,12 +260,6 @@ export default defineComponent({
256260
const autonData = await waypointsAPI.getAuton()
257261
if (autonData.status === 'success') {
258262
this.waypoints = autonData.waypoints || []
259-
260-
// Calculate next available tag ID from existing waypoints
261-
const maxTagId = this.waypoints.reduce((max, wp) => {
262-
return wp.id > max ? wp.id : max
263-
}, 7)
264-
this.nextAvailableTagId = maxTagId + 1
265263
}
266264
267265
// Fetch Active Route
@@ -272,7 +270,7 @@ export default defineComponent({
272270
// Mark items in route as "in_route" in the store list for visual feedback
273271
this.waypoints.forEach(wp => {
274272
wp.in_route = this.currentRoute.some(
275-
r => r.name === wp.name && r.id === wp.id && r.type === wp.type
273+
r => r.name === wp.name && r.tag_id === wp.tag_id && r.type === wp.type
276274
)
277275
})
278276
}
@@ -308,12 +306,12 @@ export default defineComponent({
308306
// Update visual feedback in store
309307
// Check if this type of waypoint still exists in the route elsewhere
310308
const stillInRoute = this.currentRoute.some(
311-
r => r.name === waypoint.name && r.id === waypoint.id && r.type === waypoint.type
309+
r => r.name === waypoint.name && r.tag_id === waypoint.tag_id && r.type === waypoint.type
312310
)
313311
314312
if (!stillInRoute) {
315313
const storeIndex = this.waypoints.findIndex(
316-
w => w.name === waypoint.name && w.id === waypoint.id && w.type === waypoint.type
314+
w => w.name === waypoint.name && w.tag_id === waypoint.tag_id && w.type === waypoint.type
317315
)
318316
if (storeIndex !== -1) {
319317
const storeWaypoint = this.waypoints[storeIndex]
@@ -341,19 +339,11 @@ export default defineComponent({
341339
this.modalWypt.lat = this.clickPoint.lat
342340
this.modalWypt.lon = this.clickPoint.lon
343341
344-
// Assign next available tag ID if this is not a Post type (type 1 allows user to set tag_id)
345-
if (this.modalWypt.type !== 1) {
346-
this.modalWypt.id = this.nextAvailableTagId
347-
this.nextAvailableTagId++
348-
}
349-
350-
// Add to store (default deletable=true)
351342
this.waypoints.push({ ...this.modalWypt, enable_costmap: true })
352343
353-
// Reset modal
354344
this.modalWypt = {
355345
name: '',
356-
id: -1,
346+
tag_id: -1,
357347
type: 0,
358348
lat: 0,
359349
lon: 0,
@@ -395,7 +385,7 @@ export default defineComponent({
395385
? this.currentRoute.map((waypoint: AutonWaypoint) => ({
396386
latitude_degrees: waypoint.lat,
397387
longitude_degrees: waypoint.lon,
398-
tag_id: waypoint.id,
388+
tag_id: waypoint.tag_id,
399389
type: waypoint.type,
400390
enable_costmap: waypoint.enable_costmap,
401391
}))

teleoperation/basestation_gui/frontend/src/components/AutonWaypointItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="waypoints p-2">
33
<div class="waypoint-header mb-1">
44
<h5 class="mb-0">{{ waypoint.name }}</h5>
5-
<small class="text-muted">ID: {{ waypoint.id }}</small>
5+
<small class="text-muted">ID: {{ waypoint.tag_id }}</small>
66
</div>
77

88
<div class="coordinates mb-1">

teleoperation/basestation_gui/frontend/src/components/AutonWaypointStore.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
<div class="waypoints p-2 mb-2">
33
<div class="waypoint-header mb-1">
44
<h5 class="mb-0">{{ waypoint.name }}</h5>
5-
<small class="text-muted">ID: {{ waypoint.id }}</small>
5+
<small class="text-muted">TAG ID: {{ waypoint.tag_id }}</small>
66
</div>
77
<div>
88
<div class="input-group mb-1">
99
<input
1010
class="form-control"
11-
v-model.number="localLat" :id="'lat-' + waypoint.id"
11+
v-model.number="localLat" :id="'lat-' + waypoint.tag_id"
1212
/>
1313
<span class="input-group-text">ºN</span>
1414
</div>
1515
<div class="input-group mb-1">
1616
<input
1717
class="form-control"
18-
v-model.number="localLon" :id="'lon-' + waypoint.id"
18+
v-model.number="localLon" :id="'lon-' + waypoint.tag_id"
1919
/>
2020
<span class="input-group-text">ºW</span>
2121
</div>

teleoperation/basestation_gui/frontend/src/types/waypoints.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { LatLng } from 'leaflet'
66
*/
77
export interface AutonWaypoint {
88
name: string
9-
id: number
9+
tag_id: number
1010
type: number
1111
lat: number
1212
lon: number

0 commit comments

Comments
 (0)