From 7314b1e1800f6e4922a4101044c4cdbfb29b458b Mon Sep 17 00:00:00 2001 From: AlexR Date: Wed, 13 Nov 2024 16:12:50 -0500 Subject: [PATCH 1/2] based things off the right branch --- .gitignore | 2 + install-non-ros-deps.sh | 4 +- lunabot_bringup/launch/computer.launch | 5 +- lunabot_bringup/launch/robot.launch | 48 ++++---- lunabot_control/launch/control.launch | 8 +- lunabot_control/launch/manual_control.launch | 7 +- .../scripts/differential_drive_controller.py | 3 +- lunabot_control/scripts/effort_factory.py | 9 +- lunabot_control/scripts/manual_controller.py | 3 +- .../scripts/manual_controller_autonomy.py | 113 ------------------ 10 files changed, 41 insertions(+), 161 deletions(-) delete mode 100755 lunabot_control/scripts/manual_controller_autonomy.py diff --git a/.gitignore b/.gitignore index 21670e0e..8d8c2f82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +vcpkg + teensy_loader_cli # datasets data/ diff --git a/install-non-ros-deps.sh b/install-non-ros-deps.sh index 2da8a3cf..65c5ab74 100755 --- a/install-non-ros-deps.sh +++ b/install-non-ros-deps.sh @@ -1,6 +1,6 @@ #!/bin/bash -apt-get update # To get the latest package lists -apt-get install libusb-dev libtool dh-autoreconf libudev-dev ninja-build -y +sudo apt-get update # To get the latest package lists +sudo apt-get install libusb-dev libtool dh-autoreconf libudev-dev ninja-build -y if [ $(arch) == 'aarch64' ]; then if [ -f /etc/nv_tegra_release ]; then diff --git a/lunabot_bringup/launch/computer.launch b/lunabot_bringup/launch/computer.launch index 3fcc80a4..09351729 100644 --- a/lunabot_bringup/launch/computer.launch +++ b/lunabot_bringup/launch/computer.launch @@ -5,12 +5,11 @@ + $(arg autonomy) - - - + diff --git a/lunabot_bringup/launch/robot.launch b/lunabot_bringup/launch/robot.launch index a20b8b17..695bf16f 100644 --- a/lunabot_bringup/launch/robot.launch +++ b/lunabot_bringup/launch/robot.launch @@ -1,6 +1,5 @@ - @@ -16,35 +15,32 @@ - - - - - - - - - - - - - - + + + + + + + + + - - + - - - - + - - - - - + + + + + + + + + + + diff --git a/lunabot_control/launch/control.launch b/lunabot_control/launch/control.launch index 2d66acc5..442c7f37 100755 --- a/lunabot_control/launch/control.launch +++ b/lunabot_control/launch/control.launch @@ -1,11 +1,7 @@ - - - - - - + + diff --git a/lunabot_control/launch/manual_control.launch b/lunabot_control/launch/manual_control.launch index 3c93b0aa..fabe9a6a 100644 --- a/lunabot_control/launch/manual_control.launch +++ b/lunabot_control/launch/manual_control.launch @@ -1,11 +1,8 @@ - + - - - - + diff --git a/lunabot_control/scripts/differential_drive_controller.py b/lunabot_control/scripts/differential_drive_controller.py index dde7e023..42fa27f0 100755 --- a/lunabot_control/scripts/differential_drive_controller.py +++ b/lunabot_control/scripts/differential_drive_controller.py @@ -46,7 +46,8 @@ def __init__(self): rospy.on_shutdown(self.shutdown_hook) while not rospy.is_shutdown(): - self._loop() + if (rospy.get_param("autonomy")): + self._loop() rate.sleep() def _vel_cb(self, vel_msg): diff --git a/lunabot_control/scripts/effort_factory.py b/lunabot_control/scripts/effort_factory.py index b99d90d8..da5e0640 100755 --- a/lunabot_control/scripts/effort_factory.py +++ b/lunabot_control/scripts/effort_factory.py @@ -80,8 +80,9 @@ def stop(self): effort_factory = EffortFactory() while not rospy.is_shutdown(): - if effort_factory.robot_errors.manual_stop == False: - effort_factory.publish_effort() - else: - effort_factory.stop() + if rospy.get_param("autonomy"): + if effort_factory.robot_errors.manual_stop == False: + effort_factory.publish_effort() + else: + effort_factory.stop() effort_factory.rate.sleep() diff --git a/lunabot_control/scripts/manual_controller.py b/lunabot_control/scripts/manual_controller.py index 5c06d151..af520438 100755 --- a/lunabot_control/scripts/manual_controller.py +++ b/lunabot_control/scripts/manual_controller.py @@ -240,5 +240,6 @@ def stop(self): rate = rospy.Rate(20) while not rospy.is_shutdown(): - man_ctrl.loop() + if !rospy.get_param("autonomy"): + man_ctrl.loop() rate.sleep() diff --git a/lunabot_control/scripts/manual_controller_autonomy.py b/lunabot_control/scripts/manual_controller_autonomy.py deleted file mode 100755 index 1ef5ab4c..00000000 --- a/lunabot_control/scripts/manual_controller_autonomy.py +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env python3 -import rospy - -from sensor_msgs.msg import Joy -from lunabot_msgs.msg import RobotEffort, RobotErrors - -from enum import Enum -import numpy as np - -""" -.buttons (1 is pressed, 0 not) -0 A -1 B -2 X -3 Y -4 LB -5 RB -6 back (view button) -7 start -8 power -9 button stick left -10 button stick right - -.axes -0 left stick l/r (left = 1.0, right = -1.0) -1 left stick u/d (up = 1.0, down = -1.0) -2 Left Trigger (Not pressed = 1.0, Fully depressed = -1.0) -3 right stick l/r (left = 1.0, right = -1.0) -4 right stick u/d (up = 1.0, down = -1.0) -5 Right Trigger (Not pressed = 1.0, Fully depressed = -1.0) -6 dpad (arrows) l/r (left = 1.0, right = -1.0) -7 dpad (arrows) u/d (up = 1.0, down = -1.0) -""" -class Buttons(Enum): - A = 0 - B = 1 - X = 2 - Y = 3 - LB = 4 - RB = 5 - BACK = 6 - START = 7 - POWER = 8 - L_STICK = 9 - R_STICK = 10 - -class Axes(Enum): - L_STICK_HORIZONTAL = 0 - L_STICK_VERTICAL = 1 - LEFT_TRIGGER = 2 - R_STICK_HORIZONTAL = 3 - R_STICK_VERTICAL = 4 - RIGHT_TRIGGER = 5 - DPAD_HORIZONTAL = 6 - DPAD_VERTICAL = 7 - - -class ManualController: - """ - Manual Controller For Autonomy - Current behavior is to not publish anything until the start button is pressed. - When the start button is pressed, act as a complete stop. - """ - - def __init__(self): - self.joy_subscriber = rospy.Subscriber("joy", Joy, self.joy_callback) - self.effort_publisher = rospy.Publisher("effort", RobotEffort, queue_size=1, latch=True) - self.effort_msg = RobotEffort() - - self.error_msg = RobotErrors() - self.error_subscriber = rospy.Subscriber("errors", RobotErrors, self.error_callback) - self.error_pub = rospy.Publisher("errors", RobotErrors, queue_size=1, latch=True) - - def error_callback(self, error_msg: RobotErrors): - self.error_msg = error_msg - - def publish_manual_stop(self): - self.error_msg.manual_stop = True - self.error_pub.publish(self.error_msg) - - def unpublish_manual_stop(self): - self.error_msg.manual_stop = False - self.error_pub.publish(self.error_msg) - - def joy_callback(self, joy): - # Start button: Stop the robot (Pause) - if joy.buttons[Buttons.START.value] == 1: - self.stop() - self.publish_manual_stop() - rospy.loginfo("Manual Control: Stopped") - - else: - self.unpublish_manual_stop() - - def stop(self): - self.effort_msg.left_drive = 0 - self.effort_msg.right_drive = 0 - self.effort_msg.excavate = 0 - self.effort_msg.lin_act = 0 - self.effort_msg.deposit = 0 - - self._exc_latch_val = 0 - self._exc_latch = True - - self.effort_publisher.publish(self.effort_msg) - - -if __name__ == "__main__": - rospy.init_node("manual_controller_node") - - man_ctrl = ManualController() - - rospy.spin() From e36047bb56c3bbe863e2730f9ea414045765b3a9 Mon Sep 17 00:00:00 2001 From: Lunabotics Computer Date: Fri, 15 Nov 2024 21:59:58 -0500 Subject: [PATCH 2/2] fixed syntax error --- lunabot_control/scripts/manual_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lunabot_control/scripts/manual_controller.py b/lunabot_control/scripts/manual_controller.py index af520438..4c7a71be 100755 --- a/lunabot_control/scripts/manual_controller.py +++ b/lunabot_control/scripts/manual_controller.py @@ -240,6 +240,6 @@ def stop(self): rate = rospy.Rate(20) while not rospy.is_shutdown(): - if !rospy.get_param("autonomy"): + if not rospy.get_param("autonomy"): man_ctrl.loop() rate.sleep()