Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add robostack deploy description to README. Fix timing bugs in deploy script. #20

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 56 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,36 +309,81 @@ Follow these steps to set up a Python environment for drone racing projects usin
Run the following commands to create a new environment using mamba (part of the Conda ecosystem):

```bash
mamba create -n <your-env-name> -c conda-forge -c robostack-staging ros-noetic-desktop python=3.11
mamba activate <your-env-name>
export ENV_NAME="<your-group-name>"
mamba create -n $ENV_NAME -c conda-forge -c robostack-staging ros-noetic-desktop python=3.11
mamba activate $ENV_NAME
```

Make sure your environments libraries can be found:

```bash
cd ~/.mamba/envs/$ENV_NAME/etc/conda/activate.d
echo "export LIBRARY_PATH=$LIBRARY_PATH:/home/adr/.mamba/envs/$ENV_NAME/lib" > xlibrary_path.sh
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/adr/.mamba/envs/$ENV_NAME/lib" > xldlibrary_path.sh
mamba activate $ENV_NAME
```


##### Create your own project folder
```bash
mkdir ~/repos/student_forks/$ENV_NAME
cd ~/repos/student_forks/$ENV_NAME
```

##### Install Dependencies

Navigate to the respective project directory and install dependencies:
Navigate to your project directory and install dependencies:

- Clone your fork of the lsy_drone_racing repository and install it:

```bash
cd ~/repos/lsy_drone_racing
cd ~/repos/student_forks/$ENV_NAME
git clone https://github.com/<your-github-username>/lsy_drone_racing.git
cd lsy_drone_racing
pip install -e .
```
- Clone and install the pycffirmare package:

```bash
cd ~/repos/student_forks/$ENV_NAME
git clone -b drone_racing https://github.com/utiasDSL/pycffirmware.git
cd pycffirmware
git submodule update --init --recursive
./wrapper/build_linux.sh
```

- Copy & Install the crazyswarm-import package:

```bash
cd ~/repos/pycffirmware/wrapper
./build_linux.sh
cp -r ~/repos/crazyswarm-import ~/repos/student_forks/$ENV_NAME
cd ~/repos/student_forks/$ENV_NAME/crazyswarm-import
export CSW_PYTHON=python3
cd ros_ws
rm -rf build devel
cd ..
./build.sh
```

- Copy & build the extras workspace:

```bash
cp -r ~/repos/catkin_ws ~/repos/student_forks/$ENV_NAME
cd ~/repos/student_forks/$ENV_NAME/catkin_ws
rm -rf build devel
catkin_make
```

##### Configure Environment

Set up environment scripts:

```bash
cd ~/.mamba/envs/<your-env-name>/etc/conda/activate.d
echo "source ~/repos/crazyswarm-import-py11/ros_ws/devel/setup.bash" > source-crazyswarm.sh
echo "source ~/repos/catkin_ws/devel/setup.bash --extend" > source-extras.sh
cd ~/.mamba/envs/$ENV_NAME/etc/conda/activate.d
echo "source $HOME/repos/student_forks/$ENV_NAME/crazyswarm-import/ros_ws/devel/setup.bash" > xsource-crazyswarm.sh
echo "source $HOME/repos/student_forks/$ENV_NAME/catkin_ws/devel/setup.bash --extend" > xsource-extras.sh
```

##### Finalizing Setup

Close all open terminals to ensure that no prior ROS setups interfere with your environment.

Reopen terminals and activate your environment in each terminal:
Expand All @@ -360,7 +405,7 @@ The important config files are located in the crazyswarm ROS package:
As well as the main launch file [hover_swarm.launch](https://github.com/USC-ACTLab/crazyswarm/blob/master/ros_ws/src/crazyswarm/launch/hover_swarm.launch).

#### Launch
>**Note:** The following should be run within your teams' conda environment.
>**Note:** The following should be run within your teams conda environment.

In a terminal, launch the ROS node for the crazyflies. Change the settings in _<path/to/crazyswarm-import/package>/ros_ws/src/crazyswarm/launch/crazyflies.yaml_ as necessary.
```bash
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def main(config: str = "level3.toml", controller: str | None = None):
obs = next_obs
if terminated or truncated:
break
if (dt := (time.perf_counter() - t_loop)) > (1 / config.env.freq):
if (dt := (time.perf_counter() - t_loop)) < (1 / config.env.freq):
time.sleep(1 / config.env.freq - dt)
else:
exc = dt - 1 / config.env.freq
Expand Down