Skip to content

Commit

Permalink
Config file (#15)
Browse files Browse the repository at this point in the history
Co-authored-by: Jackack <[email protected]>
  • Loading branch information
mehulgoel873 and Jackack authored Jan 14, 2025
1 parent 07d062c commit 669ae89
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ docker-compose.yml~

# BAGS
rb_ws/bags
rb_ws/src/buggy/bags/*
rb_ws/src/buggy/bags/
*.bag
rb_ws/rosbag2/

Expand Down
34 changes: 34 additions & 0 deletions rb_ws/src/buggy/config/sim_double.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**: # Global Params
ros__parameters:
traj_name: "buggycourse_safe.json"

NAND:
NAND_sim_single:
ros__parameters:
velocity: 10
pose: "Hill1_NAND"

NAND_controller:
ros__parameters:
dist: 0.0
# traj_name: "buggycourse_safe.json"
controller: "stanley"

SC:
SC_sim_single:
ros__parameters:
velocity: 12
pose: "Hill1_SC"

SC:
SC_controller:
ros__parameters:
dist: 0.0
# traj_name: "buggycourse_safe.json"
controller: "stanley"

SC:
SC_path_planner:
ros__parameters:
traj_name: "buggycourse_safe.json"
curb_name: "buggycourse_curb.json"
10 changes: 10 additions & 0 deletions rb_ws/src/buggy/config/sim_single_sc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SC:
SC_sim_single:
ros__parameters:
velocity: 12
pose: "Hill1_SC"
SC_controller:
ros__parameters:
dist: 0.0
traj_name: "buggycourse_safe.json"
controller: "stanley"
19 changes: 7 additions & 12 deletions rb_ws/src/buggy/launch/sim_2d_double.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
<launch>

<arg name="config_file" default="src/buggy/config/sim_double.yaml"/>

<node pkg="foxglove_bridge" exec="foxglove_bridge" name="foxglove" output = "screen" namespace="SC"/>

<node pkg="buggy" exec="buggy_state_converter.py" name="NAND_state_converter" output = "screen" namespace="NAND"/>
<node pkg="buggy" exec="controller_node.py" name="NAND_controller" output = "screen" namespace="NAND">
<param name="dist" value="0.0"/>
<param name="traj_name" value="buggycourse_safe.json"/>
<param name="controller" value="stanley"/>
<param from="$(var config_file)"/>
</node>
<node pkg="buggy" exec="engine.py" name="NAND_sim_single" output = "screen" namespace="NAND">
<param name="velocity" value="8"/>
<param name="pose" value="Hill1_NAND"/>
<param from="$(var config_file)"/>
</node>

<node pkg="buggy" exec="buggy_state_converter.py" name="SC_state_converter" output = "screen" namespace="SC"/>
<node pkg="buggy" exec="controller_node.py" name="SC_controller" output = "screen" namespace="SC">
<param name="dist" value="0.0"/>
<param name="traj_name" value="buggycourse_safe.json"/>
<param name="controller" value="stanley"/>
<param from="$(var config_file)"/>
</node>
<node pkg="buggy" exec="engine.py" name="SC_sim_single" output = "screen" namespace="SC">
<param name="velocity" value="12"/>
<param name="pose" value="Hill1_SC"/>
<param from="$(var config_file)"/>
</node>
<node pkg="buggy" exec="path_planner.py" name="SC_path_planner" namespace="SC" output = "screen">
<param name="traj_name" value="buggycourse_safe.json"/>
<remap from="other/state" to="/NAND/self/state"/>
<param from="$(var config_file)"/>
</node>

</launch>
9 changes: 4 additions & 5 deletions rb_ws/src/buggy/launch/sim_2d_single.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<launch>

<arg name="config_file" default="src/buggy/config/sim_single_sc.yaml"/>

<node pkg="foxglove_bridge" exec="foxglove_bridge" name="foxglove" namespace="SC"/>

<node pkg="buggy" exec="engine.py" name="SC_sim_single" namespace="SC">
<param name="velocity" value="12"/>
<param name="pose" value="Hill1_SC"/>
<param from="$(var config_file)"/>
</node>
<node pkg="buggy" exec="buggy_state_converter.py" name="SC_state_converter" namespace="SC"/>
<node pkg="buggy" exec="controller_node.py" name="SC_controller" namespace="SC">
<param name="dist" value="0.0"/>
<param name="traj_name" value="buggycourse_safe.json"/>
<param name="controller" value="stanley"/>
<param from="$(var config_file)"/>
</node>
</launch>
1 change: 1 addition & 0 deletions rb_ws/src/buggy/scripts/buggy_state_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class BuggyStateConverter(Node):
def __init__(self):
super().__init__("buggy_state_converter")
self.get_logger().info('INITIALIZED.')

namespace = self.get_namespace()
if namespace == "/SC":
Expand Down
4 changes: 2 additions & 2 deletions rb_ws/src/buggy/scripts/controller/controller_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def __init__(self):

start_index = self.cur_traj.get_index_from_distance(start_dist)

self.declare_parameter("controller_name", "stanley")
self.declare_parameter("controller", "stanley")

controller_name = self.get_parameter("controller_name").value
controller_name = self.get_parameter("controller").value
print(controller_name.lower)
if (controller_name.lower() == "stanley"):
self.controller = StanleyController(start_index = start_index, namespace = self.get_namespace(), node=self) #IMPORT STANLEY
Expand Down
2 changes: 1 addition & 1 deletion rb_ws/src/buggy/scripts/controller/stanley_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def compute_control(self, state_msg : Odometry, trajectory : Trajectory):
float (desired steering angle)
"""
if self.current_traj_index >= trajectory.get_num_points() - 1:
self.node.get_logger.error("[Stanley]: Ran out of path to follow!")
self.node.get_logger().error("[Stanley]: Ran out of path to follow!")
raise Exception("[Stanley]: Ran out of path to follow!")

current_rospose = state_msg.pose.pose
Expand Down
1 change: 0 additions & 1 deletion rb_ws/src/buggy/scripts/serial/ros_to_bnyahaj.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ def set_steering(self, msg):
self.steer_angle = msg.data
self.fresh_steer = True


def writer_thread(self):
"""
Sends ROS Topics to bnayhaj serial, only sends a steering angle when we receive a fresh one
Expand Down

0 comments on commit 669ae89

Please sign in to comment.