diff options
author | Suchinton <suchinton.2001@gmail.com> | 2024-07-01 00:10:54 +0530 |
---|---|---|
committer | Suchinton <suchinton.2001@gmail.com> | 2024-07-15 07:52:42 +0530 |
commit | b0844193f37f477c9e7e509e0b4eaf221886192b (patch) | |
tree | a125cc5d3d90db067eb65399b1c4d812a0f0a4b1 /Widgets | |
parent | 25d451d87046a1cfbf7ac3cd47c2303fd29a22c5 (diff) |
Add Python Script to Convert CARLA data into CAN messagessalmon_18.90.0salmon/18.90.018.90.0
V1:
- Add carla_to_CAN.py script to convert CARLA data into CAN messages
- Add README and requirements.txt
V2:
- Add script to record and playback messages from can interface
- Fix mappings to agl-vcar.dbc file
V3:
- Fix playback feature for record_playback.py
- Update requirements.txt
- Update README to explain setup and usage of Scripts with CARLA
V4:
- Add file playback feature to Demo Control Panel
- Remove dependency on numpy to calculate vehicle speed, use math lib instead
- record_playback.py can now be imported and also be used in standalone mode
- Fix: Now data is sent to CAN interface only when it is updated
- Fix: Delay is now based on previous timestamp and not the starting timestamp
- Fix: Send correct Gear messages, compatible with the agl-vcar signals
Bug-AGL: SPEC-5161
Change-Id: I18a14e8e6ac4d24e6ed8774402fb93a36dec274e
Signed-off-by: Suchinton <suchinton.2001@gmail.com>
Diffstat (limited to 'Widgets')
-rw-r--r-- | Widgets/ICPage.py | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/Widgets/ICPage.py b/Widgets/ICPage.py index f2e41a7..213e74c 100644 --- a/Widgets/ICPage.py +++ b/Widgets/ICPage.py @@ -11,6 +11,7 @@ from PyQt6.QtWidgets import QApplication from PyQt6.QtGui import QIcon, QPixmap, QPainter from PyQt6.QtCore import QObject, pyqtSignal from PyQt6.QtWidgets import QWidget +import threading current_dir = os.path.dirname(os.path.abspath(__file__)) @@ -23,8 +24,10 @@ Form, Base = uic.loadUiType(os.path.join(current_dir, "../ui/IC.ui")) # ======================================== +import extras.config as config from extras.KuksaClient import KuksaClient from extras.VehicleSimulator import VehicleSimulator +from Scripts.record_playback import CAN_playback import res_rc from Widgets.animatedToggle import AnimatedToggle @@ -263,24 +266,34 @@ class ICWidget(Base, Form): self.acceleration_timer.start(100) def handle_Script_toggle(self): - if self.Script_toggle.isChecked(): - self.Speed_slider.setEnabled(False) - self.RPM_slider.setEnabled(False) - self.accelerationBtn.setEnabled(False) - for button in self.driveGroupBtns.buttons(): - button.setEnabled(False) - self.set_Vehicle_RPM(1000) - self.set_Vehicle_Speed(0) - self.simulator_running = True - self.simulator.start() + if config.file_playback_enabled(): + can_tool = CAN_playback() + if self.Script_toggle.isChecked(): + can_tool_thread = threading.Thread( + target=can_tool.playback_messages) + can_tool_thread.start() + else: + can_tool.stop() + else: - self.simulator.stop() - self.simulator_running = False - self.Speed_slider.setEnabled(True) - self.RPM_slider.setEnabled(True) - self.accelerationBtn.setEnabled(True) - for button in self.driveGroupBtns.buttons(): - button.setEnabled(True) + if self.Script_toggle.isChecked(): + self.Speed_slider.setEnabled(False) + self.RPM_slider.setEnabled(False) + self.accelerationBtn.setEnabled(False) + for button in self.driveGroupBtns.buttons(): + button.setEnabled(False) + self.set_Vehicle_RPM(1000) + self.set_Vehicle_Speed(0) + self.simulator_running = True + self.simulator.start() + else: + self.simulator.stop() + self.simulator_running = False + self.Speed_slider.setEnabled(True) + self.RPM_slider.setEnabled(True) + self.accelerationBtn.setEnabled(True) + for button in self.driveGroupBtns.buttons(): + button.setEnabled(True) def updateSpeedAndEngineRpm(self, action, acceleration=(60/5)): if action == "Accelerate": |