The repository is organized in folders with files as follows:
├── data/ # simulation results are saved in .mat files here
├── lib/ # all functions for this repository
├── simulink/ # simulink files
│ ├── matlabVPC.slx/ # matlab VPC Simulink file
│ └── unityVPC.slx/ # unity VPC simulink file
├── vpc_library/ # the VPC-core library
├── unityVPC/ # Unity project files
├── plot_results.m # plots the figures in the paper
├── generateGPdata.m # generates the GP datasets
├── startup.m # loads all libraries and other files for simulation
└── init.m # initializes all parameters
In order to run any file, please make sure that
startup.m
has been called to load all libraries (either automatically during the start of MATLAB, or manually).
Run the file generateGPdata.m
. It uses the technique from the paper
M. Omainska, J. Yamauchi, T. Beckers, T. Hatanaka, S. Hirche, M. Fujita, “Gaussian process-based visual pursuit control with unknown target motion learning in three dimensions”. SICE Journal of Control, Measurement, and System Integration, Vol. 14, No. 1, pp. 116-127, 2020.
to generate the Rigid Body Motion data for the GP models used in this repository. It will also optimize the hyperparameters and create a few animation windows to help design a trajectory.
Before every simulation, please ensure that the parameters have been initialized by calling the script
init.m
. To plot the results in the paper, please run the scriptplot_results.m
.
There are two ways to run the simulation.
This will run a simulation with switched trajectories within MATLAB only. Please note that factors like communication delays, air-resistance etc. are not considered here. To run this simulation, please start the Simulink file matlabVPC.slx
.
This is a more practical simulation, as it will include factors that are likely to happen in the real world. Please ensure that you have already done the following:
- Created the ROS docker image as explained in this guide.
- Followed the unity setup guide at the end of this file.
- Compiled the new ROS messages within the folder
ros/custom_msgs/
in MATLAB by the command:>> rosgenmsg('ros/custom_msgs/')
Follow these steps in order to run the unity simulation:
-
(If no local ROS-environment is used) Setup the Docker-composed ROS network
-
Start the ROS docker container as explained in this guide
-
Connect to the Docker-composed ROS network with Tunnelblick or any other OpenVPN client.
-
Open a new terminal and log into the ros docker container with:
docker exec -it ros_melodic /bin/bash
Then, start the server endpoint with the following command:
roslaunch ros_tcp_endpoint endpoint.launch
-
-
Open the Unity Project and click on the triangle
Play
button. This will start the simulation, and we are ready to send the control inputs with MATLAB. -
Open MATLAB, run
startup.m
andinit.m
, and connect to the ROS master within the Docker container:>> rosinit('docker-ros',11311,'NodeHost','192.168.255.6')
-
Open the simulink file
unityVPC.slx
and run the simulation.
If you want to plot the results, please refer to plot.results.m
.
To setup Unity, please follow these steps:
-
Install Unity (
v2020.3+
). -
Open the Unity Hub, select
Open -> Add project from disk
and navigate to the root folder of this repository to open the project folderunityVPC
. Wait for Unity to open and install all dependencies. -
Within Unity, open the
Package Manager
and ensure thatROS-TCP-Connector
has been installed. If not, click the + button at the top left corner. Select "add package from git URL" and enter "https://github.com/Unity-Technologies/ROS-TCP-Connector.git?path=/com.unity.robotics.ros-tcp-connector" to install the ROS-TCP-Connector package. If you need a more in-depth guide, please follow the tutorial at the official Unity Robotics Hub GitHub Project page. -
Open
Robotics/ROS Settings
from the Unity menu bar, and set theROS IP Address
variable depending on your environment:- If you followed the guide for how to connect to a ROS docker container over a virtual private network, please change the
ROS IP Address
to172.25.0.3
. - If you followed the guide for how to remove the Docker isolation, please leave the IP address as
127.0.0.1
. - If you have your own ROS environment, please change it to the PC that is running the ROS master.
- If you followed the guide for how to connect to a ROS docker container over a virtual private network, please change the