Skip to content

Commit acff6fd

Browse files
committed
QTimer initialization fix.
1 parent 5c61da8 commit acff6fd

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

source_code/ros_ws_remote/src/ros_remote_gui/launch/gui.launch.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with this program. If not, see <https: www.gnu.org/licenses/>.
1818

19-
import launch
20-
import launch_ros.actions
19+
from launch_ros.actions import Node
2120
from launch.actions import RegisterEventHandler, LogInfo, EmitEvent, IncludeLaunchDescription
21+
from launch import LaunchDescription
2222
from launch.event_handlers import OnProcessExit
2323
from launch.events import Shutdown
2424
from launch.launch_description_sources import PythonLaunchDescriptionSource
@@ -27,15 +27,19 @@
2727

2828

2929
def generate_launch_description():
30-
launch_gui = launch_ros.actions.Node(package="ros_remote_gui", executable="remote_gui_node", name="remote_gui")
30+
launch_gui = Node(
31+
package="ros_remote_gui",
32+
executable="remote_gui_node"
33+
)
34+
3135
ros_remote_pui_pkg = FindPackageShare("ros_remote_pui")
3236
launch_pui_drivers = IncludeLaunchDescription(
3337
PythonLaunchDescriptionSource(
3438
PathJoinSubstitution([ros_remote_pui_pkg, "launch", "pui.launch.py"])
3539
)
3640
)
3741

38-
return launch.LaunchDescription([
42+
return LaunchDescription([
3943
launch_pui_drivers,
4044
launch_gui,
4145
RegisterEventHandler(

source_code/ros_ws_remote/src/ros_remote_gui/ros_remote_gui/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030

3131
def main():
3232
from ros_remote_gui.ros_main import ros_executor_thread, is_ros_node_initialized, get_ros_node
33+
from ros_remote_pui.remote_state import init_remote_state
3334
get_main_window().init_ui_handlers()
35+
init_remote_state()
3436

3537
# Start the ROS thread
3638
stop_ros_thread = False

source_code/ros_ws_remote/src/ros_remote_pui/ros_remote_pui/remote_state.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,8 @@ def _enable_mtr_ctrl(self, enable: bool) -> bool:
300300

301301

302302
# RemoteState instance
303-
_remote_state = RemoteState()
304-
305-
def get_remote_state() -> RemoteState:
306-
global _remote_state
303+
_remote_state: RemoteState | None = None
304+
def get_remote_state() -> RemoteState | None:
307305
return _remote_state
308306

309307

@@ -331,6 +329,14 @@ def _set_toggle_c_state(self):
331329
_remote_state.left_mid_c_sw_en = self.toggle_sw_c.is_active
332330

333331

334-
# Encoder nav handler
332+
# Initialize the remote state and RPi IO handler
335333
from ros_remote_pui.encoder_handler import EncoderNavHandler
336-
_encoder_handler = EncoderNavHandler()
334+
_io_handler: RpiIoHandler | None = None
335+
_encoder_nav_handler: EncoderNavHandler | None = None
336+
337+
def init_remote_state() -> None:
338+
global _remote_state
339+
if _remote_state is None:
340+
_remote_state = RemoteState()
341+
_io_handler = RpiIoHandler()
342+
_encoder_nav_handler = EncoderNavHandler()

0 commit comments

Comments
 (0)