GrayKS3248 / condynsate

Simulation and visualization of dynamic systems.
MIT License
2 stars 0 forks source link
animation control-systems dynamical-systems education matplotlib meshcat pybullet simulation visualization

condynsate

Table of Contents

Introduction

condynsate is a dynamic system simulation and visualization tool built with PyBullet and MeshCat. It automatically simulates multiple objects and their interactions as described by .urdf, .stl, and .obj files and can render real time visualizations in a web browser.

This tool was built by Grayson Schaer during the 2023 Fall semester at the University of Illinois at Urbana-Champaign under the Grainger College of Engineering 2023-24 Strategic Instructional Innovations Program: Computational Tools for Dynamics and Control grant.

Condynsate provides real-time simulation and visualization of articulated bodies with nonlinear dynamics in Python. It was optimized for education and promotes easy in-class demonstrations and lab demos without physical equipment. Further, it encourages students to activate motor neurons, and simulates play during the learning process --both of which are beneficial to the processes of memory and learning.

Windows Usage

Windows Command Line Basics

How to open an Anaconda Prompt in Windows

When we say "open an Anaconda Prompt," what we mean is to start the Anaconda Prompt (Miniconda3) application. Here is one way to do that:

Note that this application will only exist after you follow the instructions to 1 Install Miniconda for Windows.

How to run a command in Windows

When we say "run a command," what we mean is to type something into the window of an Anaconda Prompt and press enter. See this beginners guide to Windows Commands.

How to change the working directory in Windows

All the files on your computer are organized in folders, which are commonly referred to as "directories." When you are working on the command line, you are working in one of these directories. Commands you run can find files in that directory, but cannot (by default) find files in other directories.

When we say "change the working directory," we mean exactly that --- telling an Anaconda Prompt the directory in which you want to work.

To do this, we run the command

cd path\to\directory

where "path\to\directory" is replaced by the location of the directory in which you want to work. One easy way way to find this location (i.e., the "path" to your directory) is by dragging its folder from the File Explorer into your Anaconda Prompt window (see documentation on Quickly Copy Files Paths to Your Command Prompt via Drag and Drop. In particular, I would first type "cd " (note the single trailing space):

C:\Users\jakek>cd 

Then, I would drag a folder into the powershell window and press enter. For instance, suppose I had created a folder called ae353 somewhere on my computer and dragged it in, then pressed enter --- I would see something like this:

C:\Users\jakek>cd C:\Users\jakek\OneDrive\Documents\ae353
C:\Users\jakek\OneDrive\Documents\ae353>

See documentation on Find and Open Files using Windows Command Prompt for a way to search for the directory location of files on your computer.

Windows Installation

1 Install Miniconda for Windows

If you do not have Miniconda already installed, download the most recent Miniconda installer for Windows 64 from the miniconda website or just click here to download it automatically. Once the .exe is downloaded, run it. The .exe file has the format Miniconda3-latest-Windows-x86_64 and will be in your default downloads folder C:\Users\USER NAME\Downloads.

Once the wizard is running, click next.

conda1

Click I Agree.

conda2

Ensure Just Me (recommended) is selected and click Next.

conda3

Click Next.

conda4

Ensure Create start menu shortcuts (supported packages only) is checked and Register Miniconda3 as my default Python 3.11 is NOT CHECKED.

conda5

Once installation is complete, click next.

conda6

You may deselected Getting started with Conda and Welcome to Anaconda then click Finish.

conda7

Navigate to the Windows Start Menu folder located at C:\Users\USER NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Miniconda3 (64-bit).

conda8

To create a desktop shortcut to Anaconda Prompt (the application that will be used interact with Miniconda), right click on Anaconda Prompt (Miniconda3), navigate to Send to, then click Desktop (create shortcut).

conda9

To verify that Miniconda is installed properly, open Anaconda Prompt (Miniconda3) and run the command

conda --version

If Miniconda is installed correctly, you should get a response that lists the version of Miniconda you just installed.

2 Install condynsate in a Miniconda virtual environment in Windows

To install condynsate in a Miniconda virtual environment, open Anaconda Prompt (Miniconda3) and run the command

conda create -n ae353

When prompted, type y and press enter.

When complete, run the command

conda activate ae353

You can confirm the virtual environment you just created is activated correctly when the text (base) on the left hand side of the command line changes to (ae353).

Once you've ensured the virtual environment is activated, configure it by running the commands

conda config --env --add channels conda-forge
conda config --env --set channel_priority strict
conda clean -a -y

Now install the Conda-Forge dependencies by running the command

conda install -y git matplotlib notebook numpy pybullet pynput pyside6 sympy scipy

Once the installation is complete, install condynsate by running the commands

pip cache purge
pip install condynsate

You can check that condynsate installed correctly by running the command

python

This starts a Python shell in your Anaconda prompt. Next run the commands

import condynsate
condynsate.__version__

If condynsate is installed correctly, the current version will be shown. You may now type

quit()

to quit the Python shell.

Running Projects in Windows

1 Change your working directory in Windows

Open Anaconda Prompt (Miniconda3) and run the command

conda activate ae353

You should see the prefix to your prompt change from (base) to (ae353).

Next, change your working directory to wherever you cloned this repository.

2 Get the latest version of the code in Windows

In your already open Anaconda Prompt (Miniconda3) run the commands

git fetch
git pull

Do not worry, this will not overwrite any of your own work.

3 Start a Jupyter Notebook in Windows

In your already open Anaconda Prompt (miniconda3) run the command

jupyter notebook

A browser window should open with the Jupyter Notebook interface. You can now navigate to and open any of the notebooks (with extension .ipynb) used for examples, tutorials, or design projects.

We strongly recommend you duplicate and work with a copy of any given notebook rather than working with the original. Feel free to ignore this suggestion if you are a git expert.

Linux Usage

Linux Command Line Basics

How to open the Terminal in Linux

When we say "open the terminal", what we mean is to start the Terminal application. To do this, you can use the keyboard shortcut ctrl+alt+t.

How to run a command in Linux

When we say "run a command," what we mean is to type something into the window of the Terminal and press enter.

How to change the working directory in Linux

All the files on your computer are organized in folders, which are commonly referred to as "directories." When you are working on the command line, you are working in one of these directories. Commands you run can find files in that directory, but cannot (by default) find files in other directories.

When we say "change the working directory," we mean exactly that --- telling the Terminal the directory in which you want to work.

To move in the directory tree, we run the command

cd path\to\directory

where "path\to\directory" is replaced by the location of the directory in which you want to work. If you want to move up a single directory, you can run the command

cd ..

Linux Installation

1 Install Miniconda for Linux

If you do not have Miniconda already installed, run these four commands in the Terminal to quickly and quietly install the latest 64-bit version of the installer.

mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh

Restart the Terminal. After installing, initialize your newly-installed Miniconda by running the command

~/miniconda3/bin/conda init bash

To verify that Miniconda is installed properly, run the command

conda --version

You should get a response that lists the version of Miniconda you just installed. If you do not, more help on installation can be found here.

2 Install condynsate in a Miniconda virtual environment in Linux

To install condynsate in a Miniconda virtual environment, open the Terminal and run the command

conda create -n ae353

When prompted, type y and press enter. This creates a new virtual environment. to activate the environment, run the command

conda activate ae353

You can confirm the virtual environment you just created is activated correctly when the text (base) on the left hand side of the command line changes to (ae353).

Once you've ensured the virtual environment is activated, configure it by running the commands

conda config --env --add channels conda-forge
conda config --env --set channel_priority strict
conda clean -a -y

Now install the Conda-Forge dependencies by running the command

conda install -y git matplotlib notebook numpy pybullet pynput pyside6 sympy scipy

Once the installation is complete, install condynsate by running the commands

pip cache purge
pip install condynsate

You can check that condynsate installed correctly by running the command

python3

This starts a Python shell in your Anaconda prompt. Next run the commands

import condynsate
condynsate.__version__

If condynsate is installed correctly, the current version will be shown. You may now type

quit()

to quit the Python shell and exit out of the Terminal.

Running Projects in Linux

1 Change your working directory in Linux

Open the Terminal and change your working directory to wherever you cloned this repository.

2 Get the latest version of the code in Linux

Run the commands

git fetch
git pull

Do not worry, this will not overwrite any of your own work.

3 Activate your Conda environment in Linux

Run the command

conda activate ae353

You should see the prefix to your prompt change from (base) to (ae353). This means you are in the Conda environment you created for work with AE353.

4 Start a Jupyter Notebook in Linux

Run the command

jupyter notebook

A browser window should open with the Jupyter Notebook interface. You can now navigate to and open any of the notebooks (with extension .ipynb) used for examples, tutorials, or design projects.

We strongly recommend you duplicate and work with a copy of any given notebook rather than working with the original. Feel free to ignore this suggestion if you are a git expert.

MacOS Usage

MacOS Command Line Basics

How to open the Terminal in MacOS

When we say "open a terminal," what we mean is to start the Terminal application. Here are two ways to do that:

See documentation on Open Terminal for more information. Note that it is often helpful to have more than one terminal window open at the same time (or more than one tab in the same window).

How to run a command in MacOS

When we say "run a command," what we mean is to type something into the Terminal and press return. For example, suppose we said:

run the command pwd to find your current working directory

You would type pwd into the terminal window and press return, with the result being something like this:

timothybretl@Timothys-MacBook-Pro ~ % pwd
/Users/timothybretl

See documentation on Execute commands and run tools in Terminal on Mac for more information. Also see the Command Line Primer for a list of frequently used commands.

How to change the working directory in MacOS

All the files on your computer are organized in folders, which are commonly referred to as "directories." When you are working on the command line in a terminal, you are working in one of these directories. Commands you run can find files in that directory, but cannot (by default) find files in other directories.

When we say "change the working directory," we mean exactly that --- telling the terminal the directory in which you want to work.

To do this, we run the command

cd path/to/directory

where "path/to/directory" is replaced by the location of the directory in which you want to work. One easy way way to find this location (i.e., the "path" to your directory) is by dragging its folder from the Finder into your terminal window (see documentation on Drag items into a Terminal window on Mac). In particular, I would first type "cd " (note the single trailing space):

timothybretl@Timothys-MacBook-Pro ~ % cd 

Then, I would drag a folder into the terminal window and press return. For instance, suppose I had created a folder called ae353 somewhere on my computer and dragged it in, then pressed return --- I would see something like this:

timothybretl@Timothys-MacBook-Pro ~ % cd /Users/timothybretl/Documents/ae353
timothybretl@Timothys-MacBook-Pro ae353 %

See documentation on Specify files and folders in Terminal on Mac for other ways to specify the path to a directory.

MacOS Installation

1 Install xcode select for MacOS

If you do not already have Command Line Tools installed, open the Terminal and run the command

xcode-select --install

Click the Install button on the window that opens and agree to the license agreement.

2 Install Miniconda for MacOS

ARM64 archtecture (M1)
mkdir -p ~/miniconda3
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -o ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh
~/miniconda3/bin/conda init bash
~/miniconda3/bin/conda init zsh
conda --version
x86_64 archtecture (Intel)
mkdir -p ~/miniconda3
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh
~/miniconda3/bin/conda init bash
~/miniconda3/bin/conda init zsh
conda --version

3 Grant Input Monitoring Access to Terminal in MacOS

To use keyboard interactivity in the projects, you must first grant the Terminal security access to monitor inputs (keyboards and mice). To do this

4 Install condynsate in a Miniconda virtual environment in MacOS

To create a new Miniconda virtual environment, in your already open Terminal run the command

conda create -n ae353

When prompted, type y and press enter. This creates a new virtual environment. To activate the environment, run the command

conda activate ae353

You can confirm the virtual environment you just created is activated correctly when the text (base) on the left hand side of the command line changes to (ae353).

Once you've ensured the virtual environment is activated, configure it by running the commands

conda config --env --add channels conda-forge
conda config --env --set channel_priority strict
conda clean -a -y

Now install pip from Conda-Forge by running the command

conda install pip

Once the installation is complete, install condynsate and other dependencies via pip by running the commands

pip cache purge
pip install wheel condynsate pyside6

You can check that condynsate installed correctly by running the command

python3

This starts a Python shell in your Terminal. Next run the commands

import condynsate
condynsate.__version__

If condynsate is installed correctly, the current version will be shown. You may now type

quit()

to quit the Python shell.

Running Projects in MacOS

1 Change your working directory in MacOS

Open the Terminal and run the command

conda activate ae353

You should see the prefix to your prompt change from (base) to (ae353).

Next, change your working directory to wherever you cloned this repository.

2 Get the latest version of the code in MacOS

In your already open Terminal run the commands

git fetch
git pull

Do not worry, this will not overwrite any of your own work.

3 Start a Jupyter Notebook in MacOS

In your already open Terminal run the command

jupyter notebook

A browser window should open with the Jupyter Notebook interface. You can now navigate to and open any of the notebooks (with extension .ipynb) used for examples, tutorials, or design projects.

We strongly recommend you duplicate and work with a copy of any given notebook rather than working with the original. Feel free to ignore this suggestion if you are a git expert.

Examples and Tutorials

For examples of usage, see examples. For tutorials on using condynsate to design a project, see tutorials.