|
| 1 | +# I2RT Python API |
| 2 | + |
| 3 | +A Python client library for interacting with [I2RT](https://i2rt.com/) products, designed with simplicity and extensibility in mind. |
| 4 | + |
| 5 | +[](https://i2rt.com/) |
| 6 | +## Features |
| 7 | + |
| 8 | +- Plug and play python interface for I2RT robots |
| 9 | +- Real-time robot control via CAN bus communication |
| 10 | +- Support for directly communicating with motor (DM series motors) |
| 11 | +- Visualization and gravity compensation using MuJoCo physics engine |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +```bash |
| 16 | +pip install -e . |
| 17 | +``` |
| 18 | + |
| 19 | +## CAN Usage |
| 20 | +Plug in the CAN device and run the following command to check the available CAN devices. |
| 21 | +```bash |
| 22 | +ls -l /sys/class/net/can* |
| 23 | +``` |
| 24 | + |
| 25 | +This should give you something like this |
| 26 | +```bash |
| 27 | +lrwxrwxrwx 1 root root 0 Jul 15 14:35 /sys/class/net/can0 -> ../../devices/platform/soc/your_can_device/can0 |
| 28 | +``` |
| 29 | + |
| 30 | +Where can0 is the CAN device name. |
| 31 | + |
| 32 | +You need to bring up the CAN interface with |
| 33 | +```bash |
| 34 | +sudo ip link set can0 up type can bitrate 1000000 |
| 35 | +``` |
| 36 | + |
| 37 | +We have provided a convenience script to reset all CAN devices. Simply run |
| 38 | +```bash |
| 39 | +sh scripts/reset_all_can.sh |
| 40 | +``` |
| 41 | + |
| 42 | +## YAM Robot Arm Usage |
| 43 | + |
| 44 | +### Getting started |
| 45 | +```python |
| 46 | +from i2rt.robots.motor_chain_robot import get_yam_robot |
| 47 | + |
| 48 | +# Get a robot instance |
| 49 | +robot = get_yam_robot(channel="can0") |
| 50 | + |
| 51 | +# Get the current joint positions |
| 52 | +joint_pos = robot.get_joint_pos() |
| 53 | + |
| 54 | +# Command the robot to move to a new joint position |
| 55 | +target_pos = np.array([0, 0, 0, 0, 0, 0, 0]) |
| 56 | + |
| 57 | +# Command the robot to move to the target position |
| 58 | +robot.command_joint_pos(target_pos) |
| 59 | +``` |
| 60 | + |
| 61 | +### Running the arm and visualizing it |
| 62 | +To launch the follower robot run. |
| 63 | +```bash |
| 64 | +python scripts/minimum_gello.py --mode follower |
| 65 | +``` |
| 66 | + |
| 67 | +To launch the robot mujoco visualizer run |
| 68 | +```bash |
| 69 | +python scripts/minimum_gello.py --mode visualizer |
| 70 | +``` |
| 71 | + |
| 72 | +### Running the arm on controlling it leader follower style |
| 73 | +This requires 2 robot arms. |
| 74 | + |
| 75 | +To launch the follower robot run |
| 76 | +```bash |
| 77 | +python scripts/minimum_gello.py --mode follower --can_channel can0 |
| 78 | +``` |
| 79 | + |
| 80 | +To launch the leader robot run |
| 81 | +```bash |
| 82 | +python scripts/minimum_gello.py --mode leader --can_channel can0 |
| 83 | +``` |
| 84 | + |
| 85 | +## Flow Base Usage |
| 86 | + |
| 87 | +### Running the demo |
| 88 | +You can control your flow base using a game controller. |
| 89 | +To run the joystick demo, run the following command. |
| 90 | +```bash |
| 91 | +python i2rt/flow_base/flow_base_controller.py |
| 92 | +``` |
| 93 | + |
| 94 | +### Getting started |
| 95 | +```python |
| 96 | +from i2rt.flow_base.flow_base_controller import Vehicle |
| 97 | + |
| 98 | +# Get a robot instance |
| 99 | +vehicle = Vehicle() |
| 100 | +vehicle.start_control() |
| 101 | + |
| 102 | +# move forward slowly for 1 second |
| 103 | +start_time = time.time() |
| 104 | +while time.time() - start_time < 1: |
| 105 | + user_cmd = (0.1, 0, 0) |
| 106 | + vehicle.set_target_velocity(user_cmd, frame="local") |
| 107 | +``` |
| 108 | + |
| 109 | +## Contributing |
| 110 | +We welcome contributions! Please make a PR. |
| 111 | + |
| 112 | +## License |
| 113 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 114 | + |
| 115 | +## Support |
| 116 | +- Contact: support@i2rt.com |
| 117 | + |
| 118 | +## Acknowledgments |
| 119 | +- [TidyBot++](https://github.com/jimmyyhwu/tidybot2) - Flow base hardware and code is inspired by TidyBot++ |
| 120 | +- [GELLO](https://github.com/wuphilipp/gello_software) - Robot arm teleop is inspired by GELLO |
0 commit comments