Skip to content

Commit

Permalink
Merge branch 'main' into actions
Browse files Browse the repository at this point in the history
  • Loading branch information
christianvluu committed Nov 19, 2023
2 parents 23f1d63 + d17be40 commit 85a621f
Show file tree
Hide file tree
Showing 24 changed files with 1,052 additions and 148 deletions.
65 changes: 65 additions & 0 deletions .github/pull_request_template
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!--
For Work In Progress Pull Requests, please use the Draft PR feature,
see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further details.

For a timely review/response, please avoid force-pushing additional
commits if your PR already received reviews or comments.

Before submitting a Pull Request, please ensure you've done the following:
- 📖 Read the Forem Contributing Guide: https://developers.forem.com/contributing-guide/forem#create-a-pull-request
- 📖 Read the Forem Code of Conduct: https://github.com/forem/forem/blob/main/CODE_OF_CONDUCT.md
- 👷‍♀️ Create small PRs. In most cases this will be possible.
- ✅ Provide tests for your changes.
- 📝 Use descriptive commit messages.
- 📗 Update any related documentation and include any relevant screenshots.

NOTE: Pull Requests from forked repositories will need to be reviewed by
a Forem Team member before any CI builds will run. Once your PR is approved
with a `/ci` reply to the PR, it will be allowed to run subsequent builds without
manual approval.
-->

## What type of PR is this? (check all applicable)

- [ ] Refactor
- [ ] Feature
- [ ] Bug Fix
- [ ] Optimization
- [ ] Documentation Update

## Description
_Describe the CHANGES, the REASONING, and BENEFITS of this PR._

## Related Tickets & Documents

<!--
For pull requests that relate or close an issue, please include them
below. We like to follow [Github's guidance on linking issues to pull requests](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue).

For example having the text: "closes #1234" would connect the current pull
request to issue 1234. And when we merge the pull request, Github will
automatically close the issue.
-->

- Related Issue #
- Closes #

## QA Instructions, Screenshots, Recordings

_Please replace this line with instructions on how to test your changes, a note
on the devices and browsers this has been tested on, as well as any relevant
images for UI changes._

## Added/updated tests?
_We encourage you to keep the code coverage percentage at 80% and above._

- [ ] Yes
- [ ] No, and this is why: _please replace this line with details on why tests
have not been included_
- [ ] I need help with writing tests

## [optional] Are there any post deployment tasks we need to perform?

## [optional] What gif best describes this PR or how it makes you feel?

![alt_text](gif_link)
147 changes: 95 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,84 +9,127 @@ A complete re-write of the old RoboBuggy.


---
## Installation
## Installation (for Windows)
### Install Softwares: WSL, Ubuntu, Foxglove
- Go to Microsoft Store to install "Ubuntu 20.04.6 LTS".
- Go install Foxglove https://foxglove.dev/.

### Docker
- You will need [Docker](https://docs.docker.com/get-docker/) installed.

- Once installed, the Docker image can be built as follows from the repository's root directory:

docker compose build --no-cache
docker compose --env-file .env.dev up

- Then in another terminal window, in order to access the running Docker's CLI, run:
### Set up repo in WSL
- To set up ssh key, follow this link: [Connecting to GitHub with SSH](https://docs.github.com/en/authentication/connecting-to-github-with-ssh).
- Note: Ensure that the SSH keys are generated while in the WSL terminal
- In the website above, see these two pages: [Generating a new SSH key and adding it to the ssh-agent](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) and ["Adding a new SSH key to your GitHub account"](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).

docker exec -it robobuggy2-main-1 bash
### Clone
- In your terminal type: `$ git clone https://github.com/CMU-Robotics-Club/RoboBuggy2.git`.
- The clone link above is find in github: code -> local -> Clone SSH.
- ![image](https://github.com/CMU-Robotics-Club/RoboBuggy2/assets/116482510/8ea809f7-35f9-4517-b98d-42e2e869d233)

- Now you should be presented with a bash CLI as you're used to.

### ROS
- Navigate to `/rb_ws`. This is the catkin workspace where we will be doing all our ROS stuff.
- To build the ROS workspace and source it, run:

catkin_make
source /rb_ws/devel/setup.bash # sets variables so that our package is visible to ROS commands
- To learn ROS on your own, follow the guide on https://wiki.ros.org/ROS/Tutorials. Start from the first and install Ros using a Virtual Machine.

### Alternate Shortcut
- In the main directory, just run `./setup_dev.sh` or `./setup_prod.sh` as appropriate.
- Run `exec_docker` to get into Docker environment and setup all the aliases.


---
## 3D Simulation Quickstart

Watch [this](https://youtu.be/kEL3-sF9TTE) video to get started with visualizing the simulation.

## Installation (for MacOS - M2)
### Install Softwares: Docker, Foxglove
- Go install Foxglove https://foxglove.dev/.
- You will need [Docker](https://docs.docker.com/get-docker/) installed.

### Controls
### Set up repository
- To set up ssh key, follow this link: [Connecting to GitHub with SSH](https://docs.github.com/en/authentication/connecting-to-github-with-ssh).
- Note: Ensure that the SSH keys are generated while in the WSL terminal
- In the website above, see these two pages: [Generating a new SSH key and adding it to the ssh-agent](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) and ["Adding a new SSH key to your GitHub account"](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).

Edit `rb_ws/src/buggy/scripts/controller.py`. Skeleton code for interacting with existing topics is provided.
### Clone
- In your terminal type: `$ git clone [email protected]:CMU-Robotics-Club/RoboBuggy.git`.
- The clone link above is find in github: code -> local -> Clone SSH.
- ![image](https://github.com/CMU-Robotics-Club/RoboBuggy2/assets/116482510/8ea809f7-35f9-4517-b98d-42e2e869d233)

To launch the simulation against your controls code, run the following command: `roslaunch buggy main.launch simulation:=true`.

If you get an error about not finding package `buggy`, remember to run `source /rb_ws/devel/setup.bash`.
### ROS
- Navigate to `/rb_ws`. This is the catkin workspace where we will be doing all our ROS stuff.
- To build the ROS workspace and source it, run:

catkin_make
source /rb_ws/devel/setup.bash # sets variables so that our package is visible to ROS commands
- To learn ROS on your own, follow the guide on https://wiki.ros.org/ROS/Tutorials. Start from the first and install Ros using a Virtual Machine.

---
## 2D Simulation Quickstart
Examples (from the same run):
- Foxglove playback of simulated file example: [link](https://youtu.be/dpa5oH69eJI)
- Matplotlib live simulation example: [link](https://youtu.be/6Xji-FtDQfo)

Control Example:
- Foxglove output (via sending steering + velocity commands): [link](https://youtu.be/AOsecwWmqyw)
## Open Docker
- Use `cd` to change the working directory to be `RoboBuggy2`
- Then do `./setup_dev.sh` in the main directory (RoboBuggy2) to launch the docker container.
- Then you can go in the docker container using the `docker exec -it robobuggy2-main-1 bash`.
- When you are done, type Ctrl+C and use `$exit` to exit.

## 2D Simulation
- Boot up the docker container
- Run `roslaunch buggy sim_2d_single.launch` to simulate 1 buggy
- See `rb_ws/src/buggy/launch/sim_2d_single.launch` to view all available launch options

- Run `roslaunch buggy sim_2d_2buggies.launch` to simulate 2 buggies
- <img width="612" alt="Screenshot 2023-11-13 at 3 18 30 PM" src="https://github.com/CMU-Robotics-Club/RoboBuggy2/assets/45720415/b204aa05-8792-414e-a868-6fbc0d11ab9d">

- See `rb_ws/src/buggy/launch/sim_2d_2buggies.launch` to view all available launch options
- To prevent topic name collision, a topic named `t` associated with buggy named `x` have format `x\t`. The
- names are `SC` and `Nand` in the 2 buggy simulator. In the one buggy simulator, the name can be defined as a launch arg.
- See [**Foxglove Visualization**](#foxglove-visualization) for visualizing the simulation. Beware that since topic names
- are user-defined, you will need to adjust the topic names in each panel.

### Simulator notes
Feedback:
- Longitude + Latitude for Foxglove visualization on map: `/state/pose_navsat` (sensor_msgs/NavSatFix)
- UTM coordinates (assume we're in Zone 17T): `/sim_2d/utm` (geometry_msgs/Pose - position.x = Easting meters , position.y = Northing meters, position.z = heading in degrees from East axis + is CCW)
- INS Simulation: `/nav/odom` (nsg_msgs/Odometry) (**Noise** is implemented to vary ~1cm)
Commands:
- Steering angle: `/buggy/steering` in degrees (std_msgs/Float64)
- Velocity: `/buggy/velocity` in m/s (std_msgs/Float64)


## Foxglove Visualization
- Foxglove is used to visualize both the simulator and the actual buggy's movements.
- First, you need to import the layout definition into Foxglove. On the top bar, click Layout, then "Import from file".
- ![image](https://github.com/CMU-Robotics-Club/RoboBuggy2/assets/116482510/2aa04083-46b3-42a5-bcc1-99cf7ccdb3d2)
- Go to RoboBuggy2 and choose the file [telematics layout](telematics_layout.json)
- To visualize the simulator, launch the simulator and then launch Foxglove and select "Open Connection" on startup.
- Use this address `ws://localhost:8765` for Foxglove Websocket
- Open Foxglove, choose the third option "start link".
- ![image](https://github.com/CMU-Robotics-Club/RoboBuggy2/assets/116482510/66965d34-502b-4130-976e-1419c0ac5f69)

## X11 Setup
Instructions:
- Install the appropriate X11 server on your computer for your respective operating systems (Xming for Windows, XQuartz for Mac, etc.).
- Mac: In XQuartz settings, ensure that the "Allow connections from network clients" under "Security" is checked.
- Windows: Make sure that you're using WSL 2 Ubuntu and NOT command prompt.
- While in a bash shell with the X11 server running, run `xhost +local:docker`.
- Boot up the docker container using the "Alternate Shortcut" above.
- Run `xeyes` while INSIDE the Docker container to test X11 forwarding. If this works, we're good.
- Run `roslaunch buggy sim_2d.launch controller:=CONTROLLER_TYPE` for the simulator.

### Using the Simulator
Feedback:
- Longitude + Latitude for Foxglove visualization on map: `/state/pose_navsat` (sensor_msgs/NavSatFix)
- UTM coordinates (assume we're in Zone 17T): `/sim_2d/utm` (geometry_msgs/Pose - position.x = Easting meters , position.y = Northing meters, position.z = heading in degrees from East axis + is CCW)
- INS Simulation: `/nav/odom` (nsg_msgs/Odometry) (**Noise** is implemented to vary ~1cm)

Commands:
- Steering angle: `/buggy/steering` in degrees (std_msgs/Float64)
- Velocity: `/buggy/velocity` in m/s (std_msgs/Float64)

---

## Development

TODO:
- pusher.py: apply simulated pushing force if buggy is in certain areas
- steering_mux.py: Decide where to listen for steering inputs given a state
- dead-mans (lock right(?))
- Teleop (Input from foxglove teleop panel)
- Controls (auton)
- instrument_*.py
- INS,
### Connecting to and Launching the RoboBuggy
When launching the buggy:
- Connect to the Wi-Fi named ShortCircuit.
- In the command line window:
SSH to the computer on ShortCircuit and go to folder
`$ ssh [email protected]`
Then `$ cd RoboBuggy2`
- Setup the docker
`$ ./setup_prod.sh`
- Go to docker container
`$ docker_exec`
- Open foxglove and do local connection to “ws://192.168.1.217/8765”
- Roslauch in docker container by `$ roslaunch buggy main.launch`
(wait until no longer prints “waiting for covariance to be better”)

When shutting down the buggy:
- Stop roslauch
`$ ^C (Ctrl+C)`
- Leave the docker container
`$ exit`
- Shutdown the ShortCircuit computer
`$ sudo shutdown now`
20 changes: 10 additions & 10 deletions python-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
trimesh
pyembree
numpy>=1.20.0
pandas
pymap3d
matplotlib
utm
scipy
osqp
numba
matplotlib==3.1.2
numba==0.58.0
numpy<1.21.0
osqp==0.6.3
pandas==2.0.3
pyembree==0.2.11
pymap3d==3.0.1
scipy==1.10.1
trimesh==3.23.5
utm==0.7.0
Binary file added rb_ws/src/buggy/assets/cost_grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 85a621f

Please sign in to comment.