Skip to content

Commit 3cd05ec

Browse files
duttaishan01duttaishan01
authored andcommitted
fixed drive controller switcher activation
1 parent da0426c commit 3cd05ec

9 files changed

Lines changed: 37 additions & 9 deletions

File tree

.codex

Whitespace-only changes.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ build/
22
install/
33
log/
44
.vscode/
5+
.codex
56

67
# Byte-compiled / optimized / DLL files
78
__pycache__/

src/bringup/scripts/controller_switcher.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(self):
4040
self.client_cb_group = MutuallyExclusiveCallbackGroup()
4141

4242
# Controllers to always keep active or ignore
43-
self.always_active = ["joint_state_broadcaster", "motor_status_broadcaster"]
43+
self.always_active = ["joint_state_broadcaster", "motor_status_broadcaster", "led_gpio_controller", "killswitch_gpio_controller", "laser_gpio_controller"]
4444
self.ignore_controllers = []
4545

4646
# Lock to prevent concurrent service processing
@@ -117,11 +117,14 @@ def _handle_set_controller(self, request, response):
117117
# Extract controller names and their states
118118
all_controllers = []
119119
active_controllers = []
120+
valid_always_active = []
120121
for c in list_result.controller:
121122
all_controllers.append(c.name)
122123
if c.state == 'active':
123124
active_controllers.append(c.name)
124125

126+
valid_always_active = [c for c in self.always_active if c in all_controllers]
127+
125128
self.get_logger().info(f"Available controllers: {all_controllers}")
126129
self.get_logger().info(f"Currently active: {active_controllers}")
127130

@@ -282,10 +285,10 @@ def controller_handler(controller, subsystem_controllers):
282285
if switch_result and switch_result.ok:
283286
response.success = True
284287
if requested_controllers:
285-
active_list = requested_controllers + self.always_active
288+
active_list = requested_controllers + valid_always_active
286289
response.message = f"Successfully activated controllers: {requested_controllers}. Active: {active_list}"
287290
else:
288-
response.message = f"Successfully deactivated all controllers except: {self.always_active + self.ignore_controllers}"
291+
response.message = f"Successfully deactivated all controllers except: {valid_always_active + self.ignore_controllers}"
289292
self.get_logger().info(f"Success! {response.message}")
290293
else:
291294
response.success = False

src/description/ros2_control/drive/drive.odrive.ros2_control.xacro

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@
99
<param name="can">can0</param>
1010
</hardware>
1111

12+
<!-- Doesn't exist right now -->
13+
<joint name="steer_fl_joint">
14+
<param name="node_id">0</param>
15+
<param name="gear_ratio">26</param>
16+
<command_interface name="position"/>
17+
<command_interface name="velocity"/>
18+
<state_interface name="position">
19+
<param name="initial_value">0.0</param>
20+
</state_interface>
21+
<state_interface name="velocity"/>
22+
</joint>
23+
24+
<!-- Doesn't exist right now -->
25+
<joint name="steer_fr_joint">
26+
<param name="node_id">1</param>
27+
<param name="gear_ratio">26</param>
28+
<command_interface name="position"/>
29+
<command_interface name="velocity"/>
30+
<state_interface name="position">
31+
<param name="initial_value">0.0</param>
32+
</state_interface>
33+
<state_interface name="velocity"/>
34+
</joint>
35+
1236
<joint name="steer_bl_joint">
1337
<param name="node_id">7</param>
1438
<param name="gear_ratio">26</param>

src/subsystems/arm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<li><b>athena_arm_controllers</b>: contains athena arm manual controller</li>
99
<li><b>athena_arm_description</b>: contains the full urdf file for the arm including ros2_control urdfs</li>
1010
<li><b>athena_arm_moveit</b>: contains athena arm moveit setup</li>
11-
<li><b>athena_arm_msgs</b>: contains messages used for athena mainly for logging</li>
11+
<li><b>msgs</b>: contains messages used for athena mainly for logging</li>
1212
<li><b>manual_control</b>: testing setup to control each motor on the arm with a PS4 controller. We now have a controller in the ros2_control setup that does the same thing</li>
1313
<li><b>ros_odrive</b>: contains node and ros2_control hardware interface for ODrives.</li>
1414
<li><b>smc_ros2_control</b>: contains ros2_control hardware interface for SMC motors</li>

src/subsystems/arm/arm_bringup/launch/athena_arm.jetson.launch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def generate_launch_description():
9090
)
9191

9292
controller_switcher_config = PathJoinSubstitution(
93-
[FindPackageShare("bringup"), "config", "controller_switcher.yaml"]
93+
[FindPackageShare(runtime_config_package), "config", "controller_switcher.yaml"]
9494
)
9595

9696
# -- Additional Configuration Setup --

src/subsystems/drive/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ ros2 launch drive_bringup athena_drive.launch.py mode:=base_station
7474
**Open another terminal, source the workspace, and call the service to set controllers:**
7575
```bash
7676
source install/setup.bash
77-
ros2 service call /set_controller athena_drive_msgs/srv/SetController "{controller_names: [INCLUDE CONTROLLER(S) YOU WANT WITHIN BRACKETS]}"
77+
ros2 service call /set_controller msgs/srv/SetController "{controller_names: [INCLUDE CONTROLLER(S) YOU WANT WITHIN BRACKETS]}"
7878
```
79-
Example: `ros2 service call /set_controller athena_drive_msgs/srv/SetController "{controller_names: [drive_velocity_controller]}"`
79+
Example: `ros2 service call /set_controller msgs/srv/SetController "{controller_names: [drive_velocity_controller]}"`

src/subsystems/drive/drive_bringup/launch/athena_drive.launch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def launch_setup(context, *args, **kwargs):
148148
)
149149

150150
controller_switcher_config = PathJoinSubstitution(
151-
[FindPackageShare("bringup"), "config", "controller_switcher.yaml"]
151+
[FindPackageShare(runtime_config_package), "config", "controller_switcher.yaml"]
152152
)
153153

154154
# -- Additional Configuration Setup --

src/subsystems/science/science_bringup/launch/athena_science.launch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def generate_launch_description():
145145
)
146146

147147
controller_switcher_config = PathJoinSubstitution(
148-
[FindPackageShare("bringup"), "config", "controller_switcher.yaml"]
148+
[FindPackageShare(runtime_config_package), "config", "controller_switcher.yaml"]
149149
)
150150

151151
joystick_config_file = PathJoinSubstitution(

0 commit comments

Comments
 (0)