|
|
# Rospy controllers
|
|
|
|
|
|
The `rospy_controllers` package implements a Python ROS node that can be used to implement controllers for CRS in Python. It mimics the structure of [`ros_controllers`](Ros-Controllers) with a few differences.
|
|
|
|
|
|
- All Python files are stored in the same folder (e.g. for the visualizer, solver generation, controller).
|
|
|
- Control inputs and visualization are managed by the Python controller.
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
1. Set `control_package:=rospy_controllers` in the CRS launch file (e.g. in [`sim_single_car.launch`](https://gitlab.ethz.ch/ics-group/projects/andrea/crs-2.0/-/tree/main/src/ros4crs/crs_launch/launch/sim_single_car.launch)).
|
|
|
2. Set `controller_type` in the controller configuration such that it is correctly resolved in [`__init__.py`](https://gitlab.ethz.ch/ics-group/projects/andrea/crs-2.0/-/tree/main/src/ros4crs/rospy_controllers/src/rospy_controllers/__init__.py).
|
|
|
3. Launch!
|
|
|
|
|
|
### Implemented controllers
|
|
|
|
|
|
#### Zero-order GP-MPC
|
|
|
|
|
|
The documentation for the zero-order GP-MPC controllers can be found [here](Ros-Controllers-Python-zoGPMPC).
|
|
|
|
|
|
## Development
|
|
|
|
|
|
### Adding a new Python controller
|
|
|
|
|
|
To add a new Python controller,
|
|
|
1. Add another Python module (directory with `__init__.py`) in the [`rospy_controllers`](https://gitlab.ethz.ch/ics-group/projects/andrea/crs-2.0/-/tree/main/src/ros4crs/rospy_controllers/src/rospy_controllers) directory.
|
|
|
2. Decide on a `controller_type` for your Python controller and resolve it in the [`__init__.py`](https://gitlab.ethz.ch/ics-group/projects/andrea/crs-2.0/-/tree/main/src/ros4crs/rospy_controllers/src/rospy_controllers/__init__.py) file. Set the same `controller_type` in your controller config, see, e.g., [this example config](https://gitlab.ethz.ch/ics-group/projects/andrea/crs-2.0/-/tree/main/src/ros4crs/rospy_controllers/config/mpcc_controller_rospy.yaml).
|
|
|
3. Implement your controller as a subclass of the abstract `RosPyController` class defined in [`rospy_controller.py`](https://gitlab.ethz.ch/ics-group/projects/andrea/crs-2.0/-/tree/main/src/ros4crs/rospy_controllers/src/rospy_controllers/rospy_controller.py). In particular, it needs to return a control input when calling `get_input(state)`; visualization is performed by publishing messages with `publish_visualization()`; both methods are called at every controller sampling time. |