This code implements the control of a double joint robot using Sony's Dualsense (PS5) controller. The robot is visualized using the Streamlit library and is perfectly responsive. This project is written in Pure Python in under 100 lines of code. Created by Brian Lesko for Learning Purposes.
This code uses the following libraries:
streamlit
: for building the user interface.numpy
: for creating arrays.matplotlib
: for saving image dataio
: for saving image datahidapi
: for accessing usb connections on the host device
Run the following commands:
pip install --upgrade streamlit libusb hidapi matplotlib modern_robotics
streamlit run REPLACE
This will start the local Streamlit server, and you can access the chatbot by opening a web browser and navigating to http://localhost:8501
.
The app as follows:
- The hidapi library is used to initiate a connection to the PS5 controller
- The dualsense class is used to decode the received bytes
- The robot class is used to plot the robot figure
- Streamlit is used to display the robot
repository/
├── app.py # the code and UI integrated together live here
├── customize_gui # class for adding gui elements
├── dualsense.py # The class used to decode received bytes from the wired controller
├── requirements.txt # the python packages needed to run locally
├── .gitignore # includes the local virtual environment named my_env
├── .streamlit/
│ └── config.toml # theme info for the UI
└── docs/
└── preview.png # preview photo for Github
Python | Streamlit | Git | Low Code UI
External device | HIDapi | decode bytes | PS5 | Sony | Dualsense | communication | Remote control
custom classes
Self taught coding | Mechanical engineer | Robotics engineer
╭━━╮╭━━━┳━━┳━━━┳━╮╱╭╮ ╭╮╱╱╭━━━┳━━━┳╮╭━┳━━━╮ ┃╭╮┃┃╭━╮┣┫┣┫╭━╮┃┃╰╮┃┃ ┃┃╱╱┃╭━━┫╭━╮┃┃┃╭┫╭━╮┃ ┃╰╯╰┫╰━╯┃┃┃┃┃╱┃┃╭╮╰╯┃ ┃┃╱╱┃╰━━┫╰━━┫╰╯╯┃┃╱┃┃ ┃╭━╮┃╭╮╭╯┃┃┃╰━╯┃┃╰╮┃┃ ┃┃╱╭┫╭━━┻━━╮┃╭╮┃┃┃╱┃┃ ┃╰━╯┃┃┃╰┳┫┣┫╭━╮┃┃╱┃┃┃ ┃╰━╯┃╰━━┫╰━╯┃┃┃╰┫╰━╯┃ ╰━━━┻╯╰━┻━━┻╯╱╰┻╯╱╰━╯ ╰━━━┻━━━┻━━━┻╯╰━┻━━━╯
follow all of these or i will kick you