From edddf01cdc5e9b1b652c9a9115b161ad11bb5f2c Mon Sep 17 00:00:00 2001 From: neuenfeldttj Date: Sat, 17 Feb 2024 19:41:04 -0500 Subject: [PATCH] motor data reading out and fixed sa part --- src/teleoperation/backend/consumers.py | 6 +- .../frontend/src/components/AutonTask.vue | 1 - .../frontend/src/components/DMESTask.vue | 20 ++++-- .../frontend/src/components/SATask.vue | 61 ++++++++----------- 4 files changed, 45 insertions(+), 43 deletions(-) diff --git a/src/teleoperation/backend/consumers.py b/src/teleoperation/backend/consumers.py index fbbd74ecf..85fc9a680 100644 --- a/src/teleoperation/backend/consumers.py +++ b/src/teleoperation/backend/consumers.py @@ -241,9 +241,9 @@ def handle_sa_arm_message(self, msg): sa_throttle_cmd.names = SA_NAMES sa_throttle_cmd.throttles = [ - self.sa_config[name]["multiplier"] * self.filter_xbox_axis(msg["axes"][info["xbox_index"]], 0.15, True) - for name, info in self.sa_config.items() - if name.startswith("sa") + self.sa_config[name]["multiplier"] * self.filter_xbox_axis(msg["axes"][self.sa_config["sa_x"]["xbox_index"]], 0.15, True), + self.sa_config[name]["multiplier"] * self.filter_xbox_axis(msg["axes"][self.sa_config["sa_y"]["xbox_index"]], 0.15, True), + self.sa_config[name]["multiplier"] * self.filter_xbox_axis(msg["axes"][self.sa_config["sa_z"]["xbox_index"]], 0.15, True), ] sa_throttle_cmd.throttles.extend( [ diff --git a/src/teleoperation/frontend/src/components/AutonTask.vue b/src/teleoperation/frontend/src/components/AutonTask.vue index 766bb761b..a75851c37 100644 --- a/src/teleoperation/frontend/src/components/AutonTask.vue +++ b/src/teleoperation/frontend/src/components/AutonTask.vue @@ -311,4 +311,3 @@ h2 { grid-area: data; } ->>>>>>> 9720704e91b679513a528bf4bb0e7521bcdaec68 diff --git a/src/teleoperation/frontend/src/components/DMESTask.vue b/src/teleoperation/frontend/src/components/DMESTask.vue index 57f4df3a0..61a49e834 100644 --- a/src/teleoperation/frontend/src/components/DMESTask.vue +++ b/src/teleoperation/frontend/src/components/DMESTask.vue @@ -69,6 +69,7 @@ import MotorsStatusTable from './MotorsStatusTable.vue' import OdometryReading from './OdometryReading.vue' import DriveControls from './DriveControls.vue' import MastGimbalControls from './MastGimbalControls.vue' +import type ArmMoteusStateTableVue from './ArmMoteusStateTable.vue' export default defineComponent({ components: { @@ -82,8 +83,8 @@ export default defineComponent({ MotorsStatusTable, OdometryReading, DriveControls, - MastGimbalControls - }, + MastGimbalControls, +}, props: { type: { @@ -113,7 +114,9 @@ export default defineComponent({ name: [] as string[], position: [] as number[], velocity: [] as number[], - effort: [] as number[] + effort: [] as number[], + state: [] as string[], + error: [] as string[] } } }, @@ -124,12 +127,19 @@ export default defineComponent({ watch: { message(msg) { - if (msg.type == 'joint_state') { + if (msg.type == 'drive_status') { this.motorData.name = msg.name this.motorData.position = msg.position this.motorData.velocity = msg.velocity this.motorData.effort = msg.effort - } + this.motorData.state = msg.state + this.motorData.error = msg.error + } else if (msg.type == 'drive_moteus') { + this.moteusDrive.name = msg.name + this.moteusDrive.state = msg.state + this.moteusDrive.error = msg.error + this.moteusDrive.limit_hit = msg.limit_hit + } 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/SATask.vue b/src/teleoperation/frontend/src/components/SATask.vue index 1088d8251..252b3b4aa 100644 --- a/src/teleoperation/frontend/src/components/SATask.vue +++ b/src/teleoperation/frontend/src/components/SATask.vue @@ -101,7 +101,6 @@ import SoilData from './SoilData.vue' import BasicWaypointEditor from './BasicWaypointEditor.vue' import DriveControls from './DriveControls.vue' import MastGimbalControls from './MastGimbalControls.vue' -// import SAArmControls from "./SAArmControls.vue"; import PDBFuse from './PDBFuse.vue' import Cameras from './Cameras.vue' import DriveMoteusStateTable from './DriveMoteusStateTable.vue' @@ -114,6 +113,7 @@ import MotorAdjust from './MotorAdjust.vue' import OdometryReading from './OdometryReading.vue' import SAArmControls from './SAArmControls.vue' import { disableAutonLED, quaternionToMapAngle } from '../utils.js' +import { mapState } from 'vuex' export default { components: { @@ -148,7 +148,9 @@ export default { name: [] as string[], position: [] as number[], velocity: [] as number[], - effort: [] as number[] + effort: [] as number[], + state: [] as string[], + error: [] as string[] }, // Moteus state table is set up to look for specific keys in moteusState so it can't be empty moteusState: { @@ -161,39 +163,30 @@ export default { } }, + computed: { + ...mapState('websocket', ['message']), + }, + + watch: { + message(msg) { + if (msg.type == 'drive_status') { + this.motorData.name = msg.name + this.motorData.position = msg.position + this.motorData.velocity = msg.velocity + this.motorData.effort = msg.effort + this.motorData.state = msg.state + this.motorData.error = msg.error + } else if (msg.type == 'drive_moteus') { + this.moteusState.name = msg.name + this.moteusState.state = msg.state + this.moteusState.error = msg.error + this.moteusState.limit_hit = msg.limit_hit + } + } + }, + created: function () { - // disableAutonLED(this.$ros); - // this.odom_sub = new ROSLIB.Topic({ - // ros: this.$ros, - // name: "/gps/fix", - // messageType: "sensor_msgs/NavSatFix" - // }); - // this.odom_sub.subscribe((msg) => { - // // Callback for latLng to be set - // this.odom.latitude_deg = msg.latitude; - // this.odom.longitude_deg = msg.longitude; - // }); - // this.tfClient = new ROSLIB.TFClient({ - // ros: this.$ros, - // fixedFrame: "odom", - // // Thresholds to trigger subscription callback - // angularThres: 0.0001, - // transThres: 0.01 - // }); - // // Subscriber for odom to base_link transform - // this.tfClient.subscribe("base_link", (tf) => { - // // Callback for IMU quaternion that describes bearing - // this.odom.bearing_deg = quaternionToMapAngle(tf.rotation); - // }); - // this.brushless_motors_sub = new ROSLIB.Topic({ - // ros: this.$ros, - // name: "drive_status", - // messageType: "mrover/MotorsStatus" - // }); - // this.brushless_motors_sub.subscribe((msg) => { - // this.motorData = msg.joint_states; - // this.moteusState = msg.moteus_states; - // }); + } }