Skip to content

Commit

Permalink
added env vars to docker (#17)
Browse files Browse the repository at this point in the history
Co-authored-by: Mehul Goel <[email protected]>
  • Loading branch information
TiaSinghania and mehulgoel873 authored Jan 14, 2025
1 parent 669ae89 commit 2049949
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# NOTE: this file is not being used in docker compose correctly
# SET ALL ENVIRONMENT VARIABLES IN THE YAML
GPS_PORT=/dev/null
WEBCAM_PORT=/dev/null
RLSENSE_PORT=/dev/null
TEENSY_PORT=/dev/null
FEATHER_PORT=/dev/null

3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ RUN echo 'source "/opt/ros/humble/setup.bash" --' >> ~/.bashrc && \
echo 'cd rb_ws' >> ~/.bashrc && \
echo 'colcon build --symlink-install' >> ~/.bashrc && \
echo 'source install/local_setup.bash' >> ~/.bashrc && \
echo 'chmod -R +x src/buggy/scripts/' >> ~/.bashrc
echo 'chmod -R +x src/buggy/scripts/' >> ~/.bashrc && \
echo 'source environments/docker_env.bash' >> ~/.bashrc

# add mouse to tmux
RUN echo 'set -g mouse on' >> ~/.tmux.conf
1 change: 1 addition & 0 deletions docker-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- "${FEATHER_PORT:-/dev/null}:/dev/ttyACM1"
stdin_open: true # docker run -i
tty: true # docker run -t
env_file: .env.dev
environment:
- DISPLAY=host.docker.internal:0
hostname: main
Expand Down
4 changes: 4 additions & 0 deletions rb_ws/environments/docker_env.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
export RBROOT=/rb_ws
export PYTHONPATH=$PYTHONPATH:$RBROOT/src/buggy/scripts
export TRAJPATH=$RBROOT/src/buggy/paths/
9 changes: 3 additions & 6 deletions rb_ws/src/buggy/scripts/controller/controller_node.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#!/usr/bin/env python3

import os
import threading
import sys

import numpy as np

import rclpy
from rclpy.node import Node

from std_msgs.msg import Float32, Float64, Bool
from nav_msgs.msg import Odometry
from buggy.msg import TrajectoryMsg

sys.path.append("/rb_ws/src/buggy/scripts")
from util.trajectory import Trajectory
from controller.stanley_controller import StanleyController

Expand All @@ -24,7 +21,7 @@ def __init__(self):
Creates a ROS node with a publisher that periodically sends a message
indicating whether the node is still alive.
"""
super().__init__('controller')
self.get_logger().info('INITIALIZED.')
Expand All @@ -36,7 +33,7 @@ def __init__(self):

self.declare_parameter("traj_name", "buggycourse_safe.json")
traj_name = self.get_parameter("traj_name").value
self.cur_traj = Trajectory(json_filepath="/rb_ws/src/buggy/paths/" + traj_name) #TODO: Fixed filepath, not good
self.cur_traj = Trajectory(json_filepath=os.environ["TRAJPATH"] + traj_name)

start_index = self.cur_traj.get_index_from_distance(start_dist)

Expand Down
2 changes: 0 additions & 2 deletions rb_ws/src/buggy/scripts/controller/controller_superclass.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from abc import ABC, abstractmethod
import sys

from nav_msgs.msg import Odometry


sys.path.append("/rb_ws/src/buggy/scripts")
from util.trajectory import Trajectory

class Controller(ABC):
Expand Down
2 changes: 0 additions & 2 deletions rb_ws/src/buggy/scripts/controller/stanley_controller.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import sys
import numpy as np

from sensor_msgs.msg import NavSatFix
from geometry_msgs.msg import Pose as ROSPose
from nav_msgs.msg import Odometry

sys.path.append("/rb_ws/src/buggy/scripts")
from util.trajectory import Trajectory
from controller.controller_superclass import Controller
from util.pose import Pose
Expand Down
7 changes: 3 additions & 4 deletions rb_ws/src/buggy/scripts/path_planner/path_planner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

import sys
import os
from threading import Lock

import numpy as np
Expand All @@ -12,7 +12,6 @@
from geometry_msgs.msg import Pose
from buggy.msg import TrajectoryMsg

sys.path.append("/rb_ws/src/buggy/scripts")
from util.trajectory import Trajectory

class PathPlanner(Node):
Expand Down Expand Up @@ -53,15 +52,15 @@ def __init__(self) -> None:
#Parameters
self.declare_parameter("traj_name", "buggycourse_safe.json")
traj_name = self.get_parameter("traj_name").value
self.nominal_traj = Trajectory(json_filepath="/rb_ws/src/buggy/paths/" + traj_name) #TODO: Fixed filepath, not good
self.nominal_traj = Trajectory(json_filepath=os.environ["TRAJPATH"] + traj_name)

self.declare_parameter("curb_name", "")
curb_name = self.get_parameter("curb_name").value
curb_name = None if curb_name == "" else curb_name
if curb_name is None:
self.left_curb = None
else:
self.left_curb = Trajectory(json_filepath="/rb_ws/src/buggy/paths/" + curb_name) #TODO: Fixed filepath, not good
self.left_curb = Trajectory(json_filepath=os.environ["TRAJPATH"] + curb_name)

#Publishers
self.other_buggy_xtrack_publisher = self.create_publisher(Float64, "debug/other_buggy_xtrack", 10)
Expand Down
4 changes: 0 additions & 4 deletions rb_ws/src/buggy/scripts/simulator/engine.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#! /usr/bin/env python3
import threading
import sys
import time
import rclpy
from rclpy.node import Node
Expand All @@ -10,8 +9,6 @@
from nav_msgs.msg import Odometry
import numpy as np
import utm

sys.path.append("/rb_ws/src/buggy/scripts")
from util.constants import Constants

class Simulator(Node):
Expand All @@ -21,7 +18,6 @@ def __init__(self):
super().__init__('sim_single')
self.get_logger().info('INITIALIZED.')


self.starting_poses = {
"Hill1_NAND": (Constants.UTM_EAST_ZERO + 0, Constants.UTM_NORTH_ZERO + 0, -110),
"Hill1_SC": (Constants.UTM_EAST_ZERO + 20, Constants.UTM_NORTH_ZERO + 30, -110),
Expand Down

0 comments on commit 2049949

Please sign in to comment.