From 01b0e433a55483bfc31af5fe576f23abb6166f71 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 19 Mar 2024 16:40:22 -0400 Subject: [PATCH 1/9] drone waypoint on fmap --- src/teleoperation/backend/consumers.py | 7 + src/teleoperation/frontend/package.json | 1 + .../frontend/src/components/BasicRoverMap.vue | 466 ++++++++++-------- 3 files changed, 257 insertions(+), 217 deletions(-) diff --git a/src/teleoperation/backend/consumers.py b/src/teleoperation/backend/consumers.py index d18a61674..540fd79da 100644 --- a/src/teleoperation/backend/consumers.py +++ b/src/teleoperation/backend/consumers.py @@ -30,6 +30,7 @@ Position, IK, SpectralGroup, + DroneWaypoint, ) from mrover.srv import EnableAuton, AdjustMotor, ChangeCameras, CapturePanorama # , CapturePhoto from sensor_msgs.msg import NavSatFix, Temperature, RelativeHumidity, Image @@ -99,6 +100,7 @@ def connect(self): "/science_thermistors", Temperature, self.sa_thermistor_data_callback ) self.science_spectral = rospy.Subscriber("/science_spectral", SpectralGroup, self.science_spectral_callback) + self.drone_waypoint_sub = rospy.Subscriber("/drone_waypoint", DroneWaypoint, self.drone_waypoint_callback) # Services self.laser_service = rospy.ServiceProxy("enable_arm_laser", SetBool) @@ -805,6 +807,11 @@ def science_spectral_callback(self, msg): self.send(text_data=json.dumps({"type": "spectral_data", "data": data, "error": error})) + def drone_waypoint_callback(self, msg): + latitude = msg.latitude_degrees + longitude = msg.longitude_degrees + self.send(text_data=json.dumps({"type": "drone_waypoint", "latitude": latitude, "longitude": longitude})) + def download_csv(self, msg): username = os.getenv("USERNAME", "-1") diff --git a/src/teleoperation/frontend/package.json b/src/teleoperation/frontend/package.json index 98ef2ed57..71bcaffc9 100644 --- a/src/teleoperation/frontend/package.json +++ b/src/teleoperation/frontend/package.json @@ -17,6 +17,7 @@ "@vue-leaflet/vue-leaflet": "^0.10.1", "bootstrap": "^5.3.2", "bootstrap-vue": "^2.23.1", + "html2canvas": "^1.4.1", "leaflet": "^1.9.4", "quaternion-to-euler": "^0.5.0", "vue": "^3.3.4", diff --git a/src/teleoperation/frontend/src/components/BasicRoverMap.vue b/src/teleoperation/frontend/src/components/BasicRoverMap.vue index c59f54152..5dcb08b19 100644 --- a/src/teleoperation/frontend/src/components/BasicRoverMap.vue +++ b/src/teleoperation/frontend/src/components/BasicRoverMap.vue @@ -1,225 +1,257 @@ - - + + watch: { + message(msg) { + if (msg.type == 'drone_waypoint') { + this.drone_latitude_deg = msg.latitude + this.drone_longitude_deg = msg.longitude + const latLng = L.latLng(this.drone_latitude_deg, this.drone_longitude_deg) + this.roverMarker.setLatLng(latLng) + // Update the rover path + this.droneCount++ + if (this.droneCount % DRAW_FREQUENCY === 0) { + if (this.dronePath.length > MAX_ODOM_COUNT) { + this.dronePath = [...this.dronePath.slice(1), latLng] //remove oldest element + } + + this.dronePath = [...this.dronePath, latLng] + this.droneCount = 0 + } + } + }, - + odom: { + handler: function (val) { + // Trigger every time rover odom is changed + + const lat = val.latitude_deg + const lng = val.longitude_deg + const angle = val.bearing_deg + + const latLng = L.latLng(lat, lng) + + // Move to rover on first odom message + if (!this.findRover) { + this.findRover = true + this.center = latLng + } + + // Update the rover marker using bearing angle + this.roverMarker.setRotationAngle(angle) + + this.roverMarker.setLatLng(latLng) + + // Update the rover path + this.odomCount++ + if (this.odomCount % DRAW_FREQUENCY === 0) { + if (this.odomPath.length > MAX_ODOM_COUNT) { + this.odomPath = [...this.odomPath.slice(1), latLng] //remove oldest element + } + + this.odomPath = [...this.odomPath, latLng] + this.odomCount = 0 + } + }, + // Deep will watch for changes in children of an object + deep: true + }, + } + } + + + + \ No newline at end of file From 1786967980e08fddd495dd05e5e73492bb663eb9 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 19 Mar 2024 16:41:02 -0400 Subject: [PATCH 2/9] new msg --- msg/DroneWaypoint.msg | 2 ++ src/teleoperation/frontend/public/drone_icon.png | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 msg/DroneWaypoint.msg create mode 100644 src/teleoperation/frontend/public/drone_icon.png diff --git a/msg/DroneWaypoint.msg b/msg/DroneWaypoint.msg new file mode 100644 index 000000000..8f4434e70 --- /dev/null +++ b/msg/DroneWaypoint.msg @@ -0,0 +1,2 @@ +float64 latitude_degrees +float64 longitude_degrees \ No newline at end of file diff --git a/src/teleoperation/frontend/public/drone_icon.png b/src/teleoperation/frontend/public/drone_icon.png new file mode 100644 index 000000000..7576d57c8 --- /dev/null +++ b/src/teleoperation/frontend/public/drone_icon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:95daca31df110b725d2b51775c00f712f74b61aab5efe0b864fd370a95070f6f +size 27142 From fee0218830cde4847eeefc6d5dda1e08636caed6 Mon Sep 17 00:00:00 2001 From: eric Date: Sun, 24 Mar 2024 10:21:38 -0400 Subject: [PATCH 3/9] testing --- msg/DroneWaypoint.msg | 4 +-- pkg/libmanif-dev.deb | 0 src/teleoperation/backend/consumers.py | 4 +-- src/teleoperation/db.sqlite3 | Bin 139264 -> 139264 bytes .../frontend/public/drone_icon.png | 4 +-- .../frontend/src/components/BasicRoverMap.vue | 23 ++++++++++++------ 6 files changed, 22 insertions(+), 13 deletions(-) mode change 100644 => 100755 pkg/libmanif-dev.deb diff --git a/msg/DroneWaypoint.msg b/msg/DroneWaypoint.msg index 8f4434e70..76b9e4ee4 100644 --- a/msg/DroneWaypoint.msg +++ b/msg/DroneWaypoint.msg @@ -1,2 +1,2 @@ -float64 latitude_degrees -float64 longitude_degrees \ No newline at end of file +float64 latitude +float64 longitude \ No newline at end of file diff --git a/pkg/libmanif-dev.deb b/pkg/libmanif-dev.deb old mode 100644 new mode 100755 diff --git a/src/teleoperation/backend/consumers.py b/src/teleoperation/backend/consumers.py index 540fd79da..ef14d716e 100644 --- a/src/teleoperation/backend/consumers.py +++ b/src/teleoperation/backend/consumers.py @@ -808,8 +808,8 @@ def science_spectral_callback(self, msg): self.send(text_data=json.dumps({"type": "spectral_data", "data": data, "error": error})) def drone_waypoint_callback(self, msg): - latitude = msg.latitude_degrees - longitude = msg.longitude_degrees + latitude = msg.latitude + longitude = msg.longitude self.send(text_data=json.dumps({"type": "drone_waypoint", "latitude": latitude, "longitude": longitude})) def download_csv(self, msg): diff --git a/src/teleoperation/db.sqlite3 b/src/teleoperation/db.sqlite3 index b8faa90637c5ec8f9ac8e6e70a1b1965e05498d0..8c8d2dbdafecdc8e9ded94838a35090d26d8ea1a 100644 GIT binary patch delta 29 lcmZoTz|nAkV}dke&qNt#)*c2u` { this.map = this.$refs.map.leafletObject this.roverMarker = this.$refs.rover.leafletObject + this.droneMarker = this.$refs.drone.leafletObject }) }, // Event listener for setting store values to get data to waypoint Editor @@ -153,6 +158,8 @@ }, computed: { + ...mapState('websocket', ['message']), + ...mapGetters('erd', { waypointList: 'waypointList', highlightedWaypoint: 'highlightedWaypoint' @@ -160,6 +167,7 @@ // Convert to latLng object for Leaflet to use odomLatLng: function () { + console.log(this.odom.latitude_deg, this.odom.longitude_deg) return L.latLng(this.odom.latitude_deg, this.odom.longitude_deg) }, @@ -171,9 +179,9 @@ return [this.odomLatLng].concat(this.route.map((waypoint: any) => waypoint.latLng)) }, - // dronepolylinePath: function () { - // return [this.odomLatLng].concat(this.route.map((waypoint: any) => waypoint.latLng)) - // }, + dronepolylinePath: function () { + return [this.droneLatLng].concat(this.route.map((waypoint: any) => waypoint.latLng)) + }, }, props: { @@ -189,7 +197,7 @@ this.drone_latitude_deg = msg.latitude this.drone_longitude_deg = msg.longitude const latLng = L.latLng(this.drone_latitude_deg, this.drone_longitude_deg) - this.roverMarker.setLatLng(latLng) + this.droneMarker.setLatLng(latLng) // Update the rover path this.droneCount++ if (this.droneCount % DRAW_FREQUENCY === 0) { @@ -200,6 +208,7 @@ this.dronePath = [...this.dronePath, latLng] this.droneCount = 0 } + console.log(this.dronePath) } }, From eef2d17385f1a0c027da702a4b56887c68d92dca Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 26 Mar 2024 15:37:20 -0400 Subject: [PATCH 4/9] drone icon --- src/teleoperation/db.sqlite3 | Bin 139264 -> 139264 bytes .../frontend/src/components/BasicRoverMap.vue | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/teleoperation/db.sqlite3 b/src/teleoperation/db.sqlite3 index 8c8d2dbdafecdc8e9ded94838a35090d26d8ea1a..28335543068f3797e4243ba084abede243dcce0e 100644 GIT binary patch delta 25 hcmZoTz|nAkV}dl})QK|Aj8hvES`!$zCNM3K2LO662=xE} delta 25 gcmZoTz|nAkV}dke&qNt##-7H6)&$0_2}}#*0eL(K;{X5v diff --git a/src/teleoperation/frontend/src/components/BasicRoverMap.vue b/src/teleoperation/frontend/src/components/BasicRoverMap.vue index cbc2c1f0b..de53c4ed8 100644 --- a/src/teleoperation/frontend/src/components/BasicRoverMap.vue +++ b/src/teleoperation/frontend/src/components/BasicRoverMap.vue @@ -16,7 +16,7 @@ - + @@ -41,7 +41,7 @@ import L from '../leaflet-rotatedmarker.js' const MAX_ODOM_COUNT = 1000 - const DRAW_FREQUENCY = 10 + const DRAW_FREQUENCY = 1 const onlineUrl = 'http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}' const offlineUrl = 'map/{z}/{x}/{y}.png' const onlineTileOptions = { @@ -100,7 +100,7 @@ iconAnchor: [32, 32] }) this.droneIcon = L.icon({ - iconUrl: '/drone_icon.png', + iconUrl: '/drone_icon_1.png', iconSize: [64, 64], iconAnchor: [32, 32] }) From 5ba699be821d412806818ff8b0333ccf8deb6a76 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 26 Mar 2024 15:50:19 -0400 Subject: [PATCH 5/9] drone icon --- src/teleoperation/frontend/public/drone_icon_1.png | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/teleoperation/frontend/public/drone_icon_1.png diff --git a/src/teleoperation/frontend/public/drone_icon_1.png b/src/teleoperation/frontend/public/drone_icon_1.png new file mode 100644 index 000000000..50409457e --- /dev/null +++ b/src/teleoperation/frontend/public/drone_icon_1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b94c6536539aac8ae22e2ef0ecfe9b01264348dc0afb57ed4b7e417d9b93d6cf +size 18672 From a3a643309980d9a083c504673e0b2a8a35f4affd Mon Sep 17 00:00:00 2001 From: eric Date: Sun, 7 Apr 2024 10:26:23 -0400 Subject: [PATCH 6/9] odom reading state --- src/teleoperation/backend/consumers.py | 5 ++++- src/teleoperation/db.sqlite3 | Bin 139264 -> 139264 bytes .../frontend/src/components/AutonTask.vue | 4 +++- .../frontend/src/components/DMESTask.vue | 6 ++++-- .../src/components/OdometryReading.vue | 11 +++++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/teleoperation/backend/consumers.py b/src/teleoperation/backend/consumers.py index a66111343..a152677b8 100644 --- a/src/teleoperation/backend/consumers.py +++ b/src/teleoperation/backend/consumers.py @@ -607,9 +607,12 @@ def cmd_vel_callback(self, msg): self.send(text_data=json.dumps({"type": "cmd_vel", "linear_x": msg.linear.x, "angular_z": msg.angular.z})) def gps_fix_callback(self, msg): + fixed = True + if msg.status == -1: + fixed = False self.send( text_data=json.dumps( - {"type": "nav_sat_fix", "latitude": msg.latitude, "longitude": msg.longitude, "altitude": msg.altitude} + {"type": "nav_sat_fix", "latitude": msg.latitude, "longitude": msg.longitude, "altitude": msg.altitude, "status": fixed} ) ) diff --git a/src/teleoperation/db.sqlite3 b/src/teleoperation/db.sqlite3 index b8faa90637c5ec8f9ac8e6e70a1b1965e05498d0..0b06bb4f87b0d8e1bd1497bbaa19e0e2245b768e 100644 GIT binary patch delta 29 lcmZoTz|nAkV}dke+(a2?);I<|`

Altitude: {{ odom.altitude.toFixed(2) }}m

+
+

Status: {{get_status}}

+
@@ -64,6 +67,14 @@ export default { }, alt_available: function () { return !isNan(this.odom.altitude) + }, + get_status: function () { + if(this.odom.status){ + return "fixed" + } + else{ + return "not fixed" + } } } } From af7e95023ddcb379d45fb6afc7b7d35a6af79289 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 9 Apr 2024 20:04:24 -0400 Subject: [PATCH 7/9] drone status --- msg/DroneWaypoint.msg | 2 - src/teleoperation/backend/consumers.py | 15 ++++--- src/teleoperation/db.sqlite3 | Bin 139264 -> 139264 bytes .../frontend/src/components/AutonTask.vue | 3 +- .../frontend/src/components/BasicRoverMap.vue | 1 - .../frontend/src/components/DMESTask.vue | 3 +- .../src/components/OdometryReading.vue | 42 ++++++++++++++++++ 7 files changed, 56 insertions(+), 10 deletions(-) delete mode 100644 msg/DroneWaypoint.msg diff --git a/msg/DroneWaypoint.msg b/msg/DroneWaypoint.msg deleted file mode 100644 index 76b9e4ee4..000000000 --- a/msg/DroneWaypoint.msg +++ /dev/null @@ -1,2 +0,0 @@ -float64 latitude -float64 longitude \ No newline at end of file diff --git a/src/teleoperation/backend/consumers.py b/src/teleoperation/backend/consumers.py index 94e2b5972..58e913fca 100644 --- a/src/teleoperation/backend/consumers.py +++ b/src/teleoperation/backend/consumers.py @@ -28,7 +28,6 @@ Velocity, Position, IK, - DroneWaypoint, Spectral, ScienceThermistors, HeaterData, @@ -100,7 +99,7 @@ def connect(self): self.ish_thermistor_data = rospy.Subscriber( "/science_thermistors", ScienceThermistors, self.ish_thermistor_data_callback ) - self.drone_waypoint_sub = rospy.Subscriber("/drone_waypoint", DroneWaypoint, self.drone_waypoint_callback) + self.drone_waypoint_sub = rospy.Subscriber("/drone_waypoint", NavSatFix, self.drone_waypoint_callback) self.ish_heater_state = rospy.Subscriber( "/science_heater_state", HeaterData, self.ish_heater_state_callback ) @@ -609,9 +608,12 @@ def cmd_vel_callback(self, msg): self.send(text_data=json.dumps({"type": "cmd_vel", "linear_x": msg.linear.x, "angular_z": msg.angular.z})) def gps_fix_callback(self, msg): + fixed = True + if msg.status == -1: + fixed = False self.send( - text_data=json.dumps( - {"type": "nav_sat_fix", "latitude": msg.latitude, "longitude": msg.longitude, "altitude": msg.altitude} + text_data=json.dumps( + {"type": "nav_sat_fix", "latitude": msg.latitude, "longitude": msg.longitude, "altitude": msg.altitude, "status": fixed} ) ) @@ -822,7 +824,10 @@ def science_spectral_callback(self, msg): def drone_waypoint_callback(self, msg): latitude = msg.latitude longitude = msg.longitude - self.send(text_data=json.dumps({"type": "drone_waypoint", "latitude": latitude, "longitude": longitude})) + fixed = True + if msg.status == -1: + fixed = False + self.send(text_data=json.dumps({"type": "drone_waypoint", "latitude": latitude, "longitude": longitude, "status": fixed})) def download_csv(self, msg): username = os.getenv("USERNAME", "-1") diff --git a/src/teleoperation/db.sqlite3 b/src/teleoperation/db.sqlite3 index 136f4cbb55682acf80e3f69c97c269f6aa088868..7973d6e055994a1852a6827c767c401726147855 100644 GIT binary patch delta 25 hcmZoTz|nAkV}dl}!ih4@j0+nRS`!$zCNM3K2LO9>2@L=M delta 25 hcmZoTz|nAkV}dl}yooZ-jPn{3S`!$zCNM3K2LO8_2?qcG diff --git a/src/teleoperation/frontend/src/components/AutonTask.vue b/src/teleoperation/frontend/src/components/AutonTask.vue index 0c36c1a89..0b6a97a9a 100644 --- a/src/teleoperation/frontend/src/components/AutonTask.vue +++ b/src/teleoperation/frontend/src/components/AutonTask.vue @@ -94,7 +94,8 @@ export default defineComponent({ latitude_deg: 42.293195, longitude_deg: -83.7096706, bearing_deg: 0, - altitude: 0 + altitude: 0, + status: false }, teleopEnabledCheck: false, diff --git a/src/teleoperation/frontend/src/components/BasicRoverMap.vue b/src/teleoperation/frontend/src/components/BasicRoverMap.vue index de53c4ed8..2eefb37cb 100644 --- a/src/teleoperation/frontend/src/components/BasicRoverMap.vue +++ b/src/teleoperation/frontend/src/components/BasicRoverMap.vue @@ -208,7 +208,6 @@ this.dronePath = [...this.dronePath, latLng] this.droneCount = 0 } - console.log(this.dronePath) } }, diff --git a/src/teleoperation/frontend/src/components/DMESTask.vue b/src/teleoperation/frontend/src/components/DMESTask.vue index 6dffa10f1..b348c14b0 100644 --- a/src/teleoperation/frontend/src/components/DMESTask.vue +++ b/src/teleoperation/frontend/src/components/DMESTask.vue @@ -99,7 +99,8 @@ export default defineComponent({ latitude_deg: 38.406025, longitude_deg: -110.7923723, bearing_deg: 0, - altitude: 0 + altitude: 0, + status: false }, moteusDrive: { diff --git a/src/teleoperation/frontend/src/components/OdometryReading.vue b/src/teleoperation/frontend/src/components/OdometryReading.vue index 08f90cc2c..c274fdda9 100644 --- a/src/teleoperation/frontend/src/components/OdometryReading.vue +++ b/src/teleoperation/frontend/src/components/OdometryReading.vue @@ -19,6 +19,12 @@

Altitude: {{ odom.altitude.toFixed(2) }}m

+
+

Odom Status: {{ get_odom_status }}

+
+
+

Drone Status: {{ get_drone_status }}

+
@@ -46,6 +52,13 @@ export default { } }, + data() { + return { + drone_latitude_deg:42.293195, + drone_longitude_deg:-83.7096706, + drone_status: false + } + }, computed: { ...mapGetters('map', { odom_format: 'odomFormat' @@ -64,9 +77,38 @@ export default { }, alt_available: function () { return !isNan(this.odom.altitude) + }, + get_odom_status: function () { + if(this.odom.status){ + return "fixed" + } + else{ + return "not fixed" + } + }, + get_drone_status: function () { + if(this.drone_status){ + return "fixed" + } + else{ + return "not fixed" + } } + }, + + + watch:{ + message(msg){ + if (msg.type == 'drone_waypoint') { + this.drone_latitude_deg = msg.latitude + this.drone_longitude_deg = msg.longitude + this.drone_status = msg.status + } + } } } + + \ No newline at end of file diff --git a/src/teleoperation/frontend/src/components/DMESTask.vue b/src/teleoperation/frontend/src/components/DMESTask.vue index b348c14b0..73a0e47df 100644 --- a/src/teleoperation/frontend/src/components/DMESTask.vue +++ b/src/teleoperation/frontend/src/components/DMESTask.vue @@ -140,6 +140,11 @@ export default defineComponent({ this.moteusDrive.state = msg.state this.moteusDrive.error = msg.error this.moteusDrive.limit_hit = msg.limit_hit + } else if (msg.type == 'nav_sat_fix') { + this.odom.latitude_deg = msg.latitude + this.odom.longitude_deg = msg.longitude + this.odom.altitude = msg.altitude + this.odom.status = msg.status } else if (msg.type == 'center_map') { this.odom.latitude_deg = msg.latitude this.odom.longitude_deg = msg.longitude diff --git a/src/teleoperation/frontend/src/components/OdometryReading.vue b/src/teleoperation/frontend/src/components/OdometryReading.vue index c274fdda9..2e2f42c63 100644 --- a/src/teleoperation/frontend/src/components/OdometryReading.vue +++ b/src/teleoperation/frontend/src/components/OdometryReading.vue @@ -37,7 +37,7 @@