Skip to content

Commit

Permalink
added comms to top
Browse files Browse the repository at this point in the history
  • Loading branch information
neuenfeldttj committed Apr 5, 2024
1 parent 0db30cf commit 327c26b
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 45 deletions.
37 changes: 23 additions & 14 deletions src/teleoperation/backend/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
Spectral,
ScienceThermistors,
HeaterData,
NetworkBandwidth
)
from mrover.srv import EnableAuton, AdjustMotor, ChangeCameras, CapturePanorama
from sensor_msgs.msg import NavSatFix, Temperature, RelativeHumidity, Image
Expand Down Expand Up @@ -64,6 +65,20 @@ class GUIConsumer(JsonWebsocketConsumer):
def connect(self):
self.accept()
try:
# ROS Parameters
self.mappings = rospy.get_param("teleop/joystick_mappings")
self.drive_config = rospy.get_param("teleop/drive_controls")
self.max_wheel_speed = rospy.get_param("rover/max_speed")
self.wheel_radius = rospy.get_param("wheel/radius")
self.max_angular_speed = self.max_wheel_speed / self.wheel_radius
self.ra_config = rospy.get_param("teleop/ra_controls")
self.ik_names = rospy.get_param("teleop/ik_multipliers")
self.RA_NAMES = rospy.get_param("teleop/ra_names")
self.brushless_motors = rospy.get_param("brushless_motors/controllers")
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")

# Publishers
self.twist_pub = rospy.Publisher("/cmd_vel", Twist, queue_size=1)
self.led_pub = rospy.Publisher("/auton_led_cmd", String, queue_size=1)
Expand Down Expand Up @@ -104,6 +119,7 @@ def connect(self):
)
self.science_spectral = rospy.Subscriber("/science_spectral", Spectral, self.science_spectral_callback)
self.cmd_vel = rospy.Subscriber("/cmd_vel", Twist, self.cmd_vel_callback)
self.network_bandwidth = rospy.Subscriber("/network_bandwidth", NetworkBandwidth, self.network_bandwidth_callback)

# Services
self.laser_service = rospy.ServiceProxy("enable_arm_laser", SetBool)
Expand All @@ -116,20 +132,6 @@ def connect(self):
self.capture_panorama_srv = rospy.ServiceProxy("capture_panorama", CapturePanorama)
self.heater_auto_shutoff_srv = rospy.ServiceProxy("science_change_heater_auto_shutoff_state", SetBool)

# ROS Parameters
self.mappings = rospy.get_param("teleop/joystick_mappings")
self.drive_config = rospy.get_param("teleop/drive_controls")
self.max_wheel_speed = rospy.get_param("rover/max_speed")
self.wheel_radius = rospy.get_param("wheel/radius")
self.max_angular_speed = self.max_wheel_speed / self.wheel_radius
self.ra_config = rospy.get_param("teleop/ra_controls")
self.ik_names = rospy.get_param("teleop/ik_multipliers")
self.RA_NAMES = rospy.get_param("teleop/ra_names")
self.brushless_motors = rospy.get_param("brushless_motors/controllers")
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.tf_buffer = tf2_ros.Buffer()
self.tf_listener = tf2_ros.TransformListener(self.tf_buffer)
self.flight_thread = threading.Thread(target=self.flight_attitude_listener)
Expand Down Expand Up @@ -610,6 +612,13 @@ def cmd_vel_callback(self, msg):
)
)

def network_bandwidth_callback(self, msg):
self.send(
text_data=json.dumps(
{"type": "network_bandwidth", "tx": msg.tx, "rx": msg.rx}
)
)

def gps_fix_callback(self, msg):
self.send(
text_data=json.dumps(
Expand Down
11 changes: 7 additions & 4 deletions src/teleoperation/frontend/src/components/AutonTask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<div class="shadow p-3 mb-5 header">
<img class="logo" src="/mrover.png" alt="MRover" title="MRover" width="200" />
<h1>Auton Dashboard</h1>
<!-- <MCUReset class="mcu_reset"></MCUReset>
<CommReadout class="comms"></CommReadout> -->
<!-- <MCUReset class="mcu_reset"></MCUReset> -->
<NetworkBandwidth class="comms"></NetworkBandwidth>
<div class="help">
<img src="/help.png" alt="Help" title="Help" width="48" height="48" />
</div>
Expand Down Expand Up @@ -68,6 +68,7 @@ import OdometryReading from './OdometryReading.vue'
import JoystickValues from './JoystickValues.vue'
import DriveControls from './DriveControls.vue'
import MastGimbalControls from './MastGimbalControls.vue'
import NetworkBandwidth from './NetworkBandwidth.vue'
import { quaternionToMapAngle } from '../utils.js'
import { defineComponent } from 'vue'
Expand All @@ -84,7 +85,8 @@ export default defineComponent({
OdometryReading,
JoystickValues,
DriveControls,
MastGimbalControls
MastGimbalControls,
NetworkBandwidth
},
data() {
Expand Down Expand Up @@ -241,7 +243,8 @@ h2 {
}
.comms {
margin-right: 5px;
position: absolute;
right: 25%;
}
.helpscreen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,6 @@ export default {
display: flex;
align-items: center;
height: 100%;
width: 100%;
}
</style>
10 changes: 9 additions & 1 deletion src/teleoperation/frontend/src/components/DMESTask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<h1 v-if="type === 'ES'">ES GUI Dashboard</h1>
<h1 v-else>DM GUI Dashboard</h1>
<img class="logo" src="/mrover.png" alt="MRover" title="MRover" width="200" />
<NetworkBandwidth class="comms"></NetworkBandwidth>
<div class="help">
<img src="/help.png" alt="Help" title="Help" width="48" height="48" />
</div>
Expand Down Expand Up @@ -69,6 +70,7 @@ import MotorsStatusTable from './MotorsStatusTable.vue'
import OdometryReading from './OdometryReading.vue'
import DriveControls from './DriveControls.vue'
import MastGimbalControls from './MastGimbalControls.vue'
import NetworkBandwidth from './NetworkBandwidth.vue'
export default defineComponent({
components: {
Expand All @@ -82,7 +84,8 @@ export default defineComponent({
MotorsStatusTable,
OdometryReading,
DriveControls,
MastGimbalControls
MastGimbalControls,
NetworkBandwidth
},
props: {
Expand Down Expand Up @@ -252,6 +255,11 @@ export default defineComponent({
transform: translateX(-50%);
}
.comms {
position: absolute;
right: 25%;
}
.map {
grid-area: map;
}
Expand Down
16 changes: 7 additions & 9 deletions src/teleoperation/frontend/src/components/ISHTask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div class="wrapper">
<div class="shadow p-3 mb-5 header">
<h1>ISH Dashboard</h1>
<!-- <MCUReset class="mcu_reset"></MCUReset>
<CommReadout class="comms"></CommReadout> -->
<!-- <MCUReset class="mcu_reset"></MCUReset> -->
<NetworkBandwidth class="comms"></NetworkBandwidth>
<img class="logo" src="/mrover.png" alt="MRover" title="MRover" width="200" />
<div class="help">
<img src="/help.png" alt="Help" title="Help" width="48" height="48" />
Expand Down Expand Up @@ -44,13 +44,11 @@

<script lang="ts">
import SelectSite from './SelectSite.vue'
// import Raman from "./Raman.vue";
import Cache from './CacheControls.vue'
import Chlorophyll from './Chlorophyll.vue'
import AminoBenedict from './AminoBenedict.vue'
import Cameras from './Cameras.vue'
// import CommReadout from "./CommReadout.vue";
// import MCUReset from "./MCUReset.vue"
import NetworkBandwidth from './NetworkBandwidth.vue'
import { disableAutonLED } from '../utils.js'
export default {
Expand All @@ -59,9 +57,8 @@ export default {
Cache,
Chlorophyll,
AminoBenedict,
Cameras
// CommReadout,
// MCUReset,
Cameras,
NetworkBandwidth
},
data() {
return {
Expand Down Expand Up @@ -95,7 +92,8 @@ export default {
}
.comms {
margin-right: 5px;
position: absolute;
right: 25%;
}
.helpscreen {
Expand Down
37 changes: 37 additions & 0 deletions src/teleoperation/frontend/src/components/NetworkBandwidth.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<template>
<!-- <div class="wrap"> -->
<span
>TX: {{ tx.toFixed(2) }} Mbps RX:
{{ rx.toFixed(2) }} Mbps</span
>
<!-- </div> -->
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { mapState } from 'vuex'
export default defineComponent({
data() {
return {
tx: 0,
rx: 0,
}
},
computed: {
...mapState('websocket', ['message'])
},
watch: {
message(msg) {
if (msg.type == 'network_bandwidth') {
this.tx = parseFloat(msg.tx);
this.rx = parseFloat(msg.rx);
}
}
}
})
</script>
<style scoped>
</style>
24 changes: 7 additions & 17 deletions src/teleoperation/frontend/src/components/SATask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div class="wrapper">
<div class="shadow p-3 mb-5 header">
<h1>SA Dashboard</h1>
<!-- <MCUReset class="mcu_reset"></MCUReset>
<CommReadout class="comms"></CommReadout> -->
<!-- <MCUReset class="mcu_reset"></MCUReset> -->
<NetworkBandwidth class="comms"></NetworkBandwidth>
<img class="logo" src="/mrover.png" alt="MRover" title="MRover" width="200" />
<div class="help">
<img src="/help.png" alt="Help" title="Help" width="48" height="48" />
Expand Down Expand Up @@ -78,13 +78,6 @@
:topic_name="'sa_calibrate_sensor_actuator'"
/>
</div>
<!-- <MotorAdjust
:options="[
{ name: 'sa_joint_1', option: 'Joint 1' },
{ name: 'sa_joint_2', option: 'Joint 2' },
{ name: 'sa_joint_3', option: 'Joint 3' }
]"
/> -->
</div>
<div v-show="false">
<MastGimbalControls></MastGimbalControls>
Expand All @@ -107,11 +100,9 @@ import DriveMoteusStateTable from './DriveMoteusStateTable.vue'
import MotorsStatusTable from './MotorsStatusTable.vue'
import LimitSwitch from './LimitSwitch.vue'
import CalibrationCheckbox from './CalibrationCheckbox.vue'
// import CommReadout from "./CommReadout.vue";
// import MCUReset from "./MCUReset.vue";
import MotorAdjust from './MotorAdjust.vue'
import OdometryReading from './OdometryReading.vue'
import SAArmControls from './SAArmControls.vue'
import NetworkBandwidth from './NetworkBandwidth.vue'
import { disableAutonLED, quaternionToMapAngle } from '../utils.js'
import { mapState } from 'vuex'
Expand All @@ -128,11 +119,9 @@ export default {
SAArmControls,
LimitSwitch,
CalibrationCheckbox,
// CommReadout,
// MCUReset,
MotorAdjust,
OdometryReading,
MotorsStatusTable
MotorsStatusTable,
NetworkBandwidth
},
data() {
return {
Expand Down Expand Up @@ -216,7 +205,8 @@ export default {
}
.comms {
margin-right: 5px;
position: absolute;
right: 25%;
}
.helpscreen {
Expand Down

0 comments on commit 327c26b

Please sign in to comment.