Run main.py, making sure that qagent.py is importing getPlayableActions and getStateMatrix from the file you want.
To add something to the repository, first clone the repo with
git clone git@github.com:AriMirsky/Q-Learning.git
. Then, navigate to the
repository with cd Q-Learning
. Create a new branch with
git checkout -b <feature name>
where <feature name>
is the name of what you
are adding, without the <>. Then, write the feature. Lastly, go to
https://github.com/AriMirsky/Q-Learning/pulls
and create a pull request to
merge your branch into main.
-
If not already installed, install Homebrew, a package manager for MacOS and Linux
-
Install Docker
brew install --cask docker
-
Open the newly installed Docker Desktop application
- You should be able to find it in the application folder
- Otherwise, use Spotlight search (⌘ + space) and search for "Docker"
-
Select "Use recommended settings"
-
Skip remaining steps if possible
- See Docker install documentation (ask Ari)
- See Docker install documentation (untested)
-
Set your working directory to the top level of the Q-learning repository
-
Running commands:
docker-compose run --rm nav [COMMANDS]
- This command will create an image and container (if necessary) and execute the given commands
- The
--rm
option deletes the container that was created to run the commands on exit - Example:
docker-compose run --rm nav python src/qlearning/main.py
will run main.py 🙂
-
Create an alias in your
.bashrc
(or whatever shell you are using) to avoid getting carpal tunnelalias nav='docker-compose run nav --rm'
A quick way to do this if you are using Bash
echo "alias nav='docker-compose run --rm nav'" >> ~/.bashrc
Or Zsh (default on MacOS)
echo "alias nav='docker-compose run --rm nav'" >> ~/.zshrc
-
The working directory of the navigation image (defined in
Dockerfile-navigation
) is set to/usr/app
, which is bound as a volume to the entire Q-learning repository stored locally on the host (this way code changes do not require new image build, seedocker-compose.yml
)If you are working primarily in a specific module, it can be helpful to set your working directory to something else, e.g.
docker-compose run --rm --workdir /usr/app/src/state_pred/ nav python bike_sim.py
Note: you may need to rebuild your image to include the new X11 forwarding code in the Dockerfile. Talk to Dalton if you need help with this.
-
Install XQuartz via Homebrew
brew install --cask xquartz
-
Logout and login of your Mac to activate XQuartz as default X11 server
-
Open XQuartz
open -a XQuartz
-
Go to Security Settings (Menu Bar -> XQuartz -> Settings -> Security Settings) and ensure that "Allow connections from network clients" is on
-
Restart your laptop (FIXME: this step may not be necessary?)
-
Allow X11 forwarding from localhost via xhost
xhost + localhost
Important: this must be run in the xterm window opened by default by XQuartz every time XQuartz is started
-
Add the following option whenever you run
docker-compose run
:--env DISPLAY=host.docker.internal:0
Example:
docker-compose run --rm --env DISPLAY=host.docker.internal:0 nav python src/state_pred/bike_sim.py
First, add the following to .bashrc
or equivalent:
if command -v xhost &> /dev/null then
xhost +localhost
fi
This will add the localhost to xhost when an xterm window is opened. Now, for the magic alias:
alias qlearn="open -a Xquartz ; docker-compose run --rm --env DISPLAY=host.docker.internal:0"
This alias can now be used as: qlearn [service] [commands]
. For example:
qlearn nav python src/state_pred/bike_sim.py
.
Note: this command may fail on the first or second try while Xquartz is still opening TODO: can this be improved?
In theory this should be easier as most distros already use Xwindows, but I know for a fact that the steps differ compared to Mac.
May have to bind this volume:
--volume="$HOME/.Xauthority:/root/.Xauthority:rw"
May have to set
--net=host
or
--add-host=host.docker.internal:host-gateway
May have to bind x11 socket:
--volume /tmp/.X11-unix:/tmp/.X11-unix
May have to set DISPLAY to
--env DISPLAY=unix$DISPLAY
or --env DISPLAY=$DISPLAY
I'm not sure. Stack Overflow has a sea of possibilities.
May the odds be ever in your favor...
No clue.
To run the ROS container, use
docker-compose run --rm ros
The container is currently set to run talker_listener.launch.py
(a demo) by
default.