Sample of saving ROS2's camera_info topic in json format to Database.
- Docker
- Docker Compose
- Python 3.6.x or later is required
- mysql-connector-python (pip)
- ROS2 (The test was done with Humble.)
- v4l2_camera (webcam information publisher)
camera_info_sql
├── docs
│ └── figures/
├── db
│ ├── migration/
│ ├── Dockerfile
│ └── docker-compose.yml
├── resource/
│ └── jsons/
└── camera_info_sql
├── sql_operations/
├── ${Python files for table operations}
└── camera_info_sql_node.py
Run the following command:
Get Repository
cd ~/ros2_ws/src
git clone [email protected]:koukemo/camera_info_sql.git
Building
cd ~/ros2_ws
colcon build --packages-select camera_info_sql
Run the following command:
Terminal1 (DB)
cd camera_info_sql/db
docker-compose up
Terminal2 (Webcam publisher)
ros2 run v4l2_camera v4l2_camera_node
Terminal3 (Run camera_info_sql)
cd ~/ros2_ws
. ./install/setup.bash
ros2 run camera_info_sql camera_info_sub
With the docker DB container started, run the following:
(The password is set to "test" by default.)
mysql -h 127.0.0.1 -P 3306 -u test -p
View Table Name
python3 ~/ros2_ws/src/camera_info_sql/camera_info_sql/show_tables.py
View Table Datas
default settings | table : 'json_tables', column : '*'
(If you want to change the settings, edit camera_info_sql/camera_info_sql/show_columns.py)
python3 ~/ros2_ws/src/camera_info_sql/camera_info_sql/show_columns.py
Warning
Note that if you do the following, all tables will be empty!
Delete all data in table
python3 ~/ros2_ws/src/camera_info_sql/camera_info_sql/delete_columns.py
SQL Content :
Json content :