Conversation
…cords. Created new hotspot table that has one-to-many relationship with temperature values. Many temp values link to one hotspot
…ion table and take the latest position for the bot of focus, storing that one position value into the hotspot table.
…he hotspot data back to server file.
… table since it should be linked to bot and hotspot in order for hotspot table to show up as a MySQL table
…ad of every 5 seconds. Simulator updates between position and temperature data
…ta when the bot's stopped (velocity = 0), position data is sent at all times
| //infer missionID from the bot if it is missing | ||
| if(data.missionID ==null){ | ||
| const missionID =await getActiveMissionIdForBot(conn, data.botID); | ||
| data.missionID =missionID ??null; // if no active mission, set to null and let it be handled by the database constraints (if necessary) or just have battery data without a mission association |
There was a problem hiding this comment.
No need for mission data for battery data or position data. Can be removed from insert method and remove missionid from init.sql for battery table and position table.
| conn = await pool.getConnection(); | ||
|
|
||
| // If missionID not provided, try to find an active mission for this bot | ||
| let missionID = data.missionID ?? null; |
There was a problem hiding this comment.
data will never contain mission id, right? the robot won't be sending mission id in the temperature message so you need to query it from the db. No point looking for data.missionId if it's never populated
| const [missionRows] = await conn.execute( | ||
| `SELECT DISTINCT m.missionID AS missionID | ||
| FROM mission m | ||
| JOIN bot_mission_assignment bma ON m.missionID = bma.missionID | ||
| WHERE bma.botID = ? AND m.timeStart IS NOT NULL AND m.timeEnd IS NULL | ||
| LIMIT 1`, | ||
| [data.botID] | ||
| ); | ||
| missionID = missionRows[0] ? missionRows[0].missionID : null; | ||
| } |
There was a problem hiding this comment.
why do you have this but also a method (getActiveMissionIdForBot) that does the same thing? You should use the method here
| data.latitude, | ||
| data.longitude, | ||
| data.altitude ?? null, | ||
| data.notes ?? null, |
There was a problem hiding this comment.
Again, there's not going to be notes in the temperature message so just insert null otherwise the code is misleading
| ardupilotmega, | ||
| } = mavlink; | ||
| const latestGPS = {}; | ||
| const tempVals = {}; |
| NOTE: data format for simulated battery data is arbitrary; i.e. the keys do not correspond to actual incoming data, because battery percentage is new and I do not yet know the format in which battery % will be sent by the bot. Once format is finalized, function processBatteryMessage() as well as the 'battery' table in DB must both be changed, and the battery simulation part of the function will break unless also changed accordingly. | ||
| */ | ||
|
|
||
| let simStarted = false; |
There was a problem hiding this comment.
why was this added? SimulateMavlinkData() is only called once on the index page so I don't see how it would ever be called again after simulation is already started? Did you encounter that as a problem?
| let botTempData = []; | ||
|
|
||
| for (let i = 0; i < NUM_SIMULATED_BOTS; i++) { | ||
| let temperatureTick = false; //start with GPS so latestGPS is populated before temp data |
| const allBatteryData = await getAllBatteryData(); | ||
| io.emit('battery:update', allBatteryData); | ||
| } | ||
| //TODO: insert hotspot data, don't worry about io.emit for now |
…ics/EMBR-Web into featureHotspotCreation
Summary
Provide a short, clear description of what this PR does and why.
Created a new MySQL table for hotspots, where one hotspot can be linked to many different temperatures. Added an insertHotspotData() function that will take data from the position table and take the latest position for the bot of focus, storing that one position value in the hotspot table. Combined the latest GPS coordinates with 10 temperature values, and sent the hotspot data back to the server file.
Related Task
Closes Create and store hotspots in db based off of incoming data from radio
Type of Change
Select all that apply:
📄 Documentation
🧪 Testing
Describe how this change was tested.
Include commands or steps used, and confirm successful results.
In init.sql, after I created the hotspot table, which has a one-to-many relationship with the botID. I tested the code, but the hotspot table would not show up, so I added: FOREIGN KEY (hotspotID) REFERENCES hotspot(hotspotID) ON DELETE CASCADE under the temperature table so that it accounted for the fact that one hotspot could have many temperature values. I also altered the storeMavlinkData(data) function in server.mjs so that the data type 'hotspot_data' was accounted for.
Image of GUI change (if applicable)
Paste an image of the GUI change.
✅ Pre-Merge Checklist
🧾 Notes (Optional)
Add any context, screenshots, or known issues reviewers should know about.