# mirror-FR3Py
**Repository Path**: caodev/mirror-FR3Py
## Basic Information
- **Project Name**: mirror-FR3Py
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-10-31
- **Last Updated**: 2025-10-31
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# FR3Py
FR3Py is unified Python simulation and hardware communication environment for Franka FR3 robots. The motivation of this project is to remove the burden of developing an easy interface for the robot, and minimize the effort required for going from simulation to real-world by provides an identical Python class to interface with simulation and the real robot. All you need to do, is changing one class!
## Installation
The C++ bridge should be excuted on a computer with preempt-RT kernel patch applied and docker installed. This computer communicates with the robot on one end and interracts with the FR3Py python class running on the same computer or any other computer on the same network.
### Linux Kernel with Preempt-RT Kernel Patch
Install the preempt-RT Linux kernel as instructed on the Franka official Linux installation procedure [here](https://frankaemika.github.io/docs/installation_linux.html#setting-up-the-real-time-kernel).
### Install Docker
Make sure docker is installed as instructed [here](https://docs.docker.com/engine/install/ubuntu/).
### Install Dev Containers Extension
FR3Py provides the `.devcontainer` configuration files required for easy and quick installation of the development environment. This requires the Dev Containers extension to be installed in your VSCode.
## Usage
### Workflow for the Real Robot
#### Step0
Enable the Multicast for the interface connected to the robot's network. To do so, first identify the name of that interface based on the IP address of the robot:
```bash
ifconfig
```
Then run the `unicast_config.py` file in the `tools` directory of this repository with the identified interface name as the argument:
```bash
sudo python3 tools/multicast_config.py # e.g. eth0
```
#### Step1
Open the repository folder inside your VSCode. Then press `SHIFT+CTRL+P` and choose `Rebuild and Reopen in Container`. After the completion of the build process open a terminal inside the container and run the FR3 C++ bridge:
```bash
fr3_joint_interface
```
The `unique_robot_ID` is a unique name used to determine the name of the LCM topics corresponding to the robot with IP `robot_ip`. Furtheremore, `interface_type` determines how we want to control the robot. Currently, joint torque (`torque`) and joint velocity (`velocity`) types are supported.
***Note:*** Step1 assumes that the `FCI` interface is enabled through the `Desk` and the robot's FCI ethernet port (the port on the main control box and not the robot base) is connected to the local network of the development PC.
#### Step2
The robot is now ready to take commands from your python script. It is as easy as:
```python
from FR3Py.robot.interface import FR3Real
from FR3Py.robot.model import PinocchioModel
robot = FR3Real(robot_id='fr3_robot1') # The same ID used when running the bridge
model = PinocchioModel()
while running:
state = robot.getStates()
info = model.getInfo(state['q'], state['dq'])
#User control computations to compute the joint velocity or torque command u ...
robot.sendCommands(u)
```
### Workflow for Simulation
The simulation API is exactly the same as that used for controlling a real robot. Simply enable xhost request access in a system terminal by running:
```bash
xhost +
```
Then open the repository folder inside your VSCode and press `SHIFT+CTRL+P` and choose `Rebuild and Reopen in Container`. After the completion simulate the robot simply by changing the robot object in your python code with the simulation opject:
```python
from FR3Py.robot.interface import FR3Real
from FR3Py.robot.model import PinocchioModel
robot = FR3Sim(interface_type='velocity') # Simulation with joint velocity and joint torque interfaces are supported.
model = PinocchioModel()
while running:
state = robot.getStates()
info = model.getInfo(state['q'], state['dq'])
#User control computations to compute the joint velocity or torque command u ...
robot.sendCommands(u)
```
## Examples
A set of examples and tutorials are provided [here](examples/) to get you up and running quickly.