This repository makes a Server in MATLAB and a Client in Unity. Moving the robot in the Unity will have the same change in the robot simulation in MATLAB which is created by Robotics Toolbox (Corke). The use of this package is when we want to use MATLAB numerical methods to solve some probelm in Unity (VR). We can send the messages to MATLAB solve the problem there.
The requirements are Robotics Toolbox by Corke in MATLAB in which we create the simulation of an RRR serial manipulator (RRR.m, MATLAB Simulation). Moreover, the right mapping between Unity coordinates (lefthanded, y-up) and MATLAB coordinates (righthanded, z-up) is needed. Function conM2U_Q in MATLAB converts the Coordinates of the robot from MATLAB in Unity. That is when we have the simulation in MATLAB and we want the same model simulated correctly in Unity. The input is a homogenous transformation and the output is a quaternion containing the rotation information, axis of rotation and angle of rotation plus the displacement in position. This should be entered in the Start() part of Unity while the Update() part provide the configuration of the robot in each update.
In Client script in Unity an instance of TcpClient is made and the messages are sent in the Update() part. To distinguish between each sent message the joint angles are placed netween 4 strings: "A" + JointAngle1 + "B" + JointAngle2 + "C" + JointAngle3 + "D". Then in MATLAB (RRR.m, MATLAB as a Server to listen to Unity), the messages are received and interpreted correctly so we have the joint values for each joint of the robot in MATLAB.
A video of the aforementioned process can be found in: https://youtu.be/uZj27E02dmQ