Matlab Agent New Use Case - Trajectory planning of a Robotic Arm#33
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #33 +/- ##
=======================================
Coverage ? 90.31%
=======================================
Files ? 35
Lines ? 3540
Branches ? 0
=======================================
Hits ? 3197
Misses ? 343
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
@marcomelloni Thanks for the PR. Please see the suggestions. In addition, the following changes are suggested.
- The
docs/examplesdirectory has templates for batch and streaming simulations. The template for interactive simulation is missing. Please make a copy and add.templateextension. - In the README.md of the example, please add the instructions to run the example.
- When the simulation is run, the following error occurs.
matlab-agent --config-file .\config.yaml
2025-10-28 22:06:49 - MATLAB-AGENT - INFO - Initializing MATLAB agent with ID: matlab
2025-10-28 22:06:49 - MATLAB-AGENT - INFO - Configuration validated successfully.
2025-10-28 22:06:49 - MATLAB-AGENT - INFO - Initializing RabbitMQ broker
2025-10-28 22:06:50 - MATLAB-AGENT - INFO - MATLAB agent running and listening for requests
2025-10-28 22:14:53 - MATLAB-AGENT - INFO - Received simulation type: batch
2025-10-28 22:14:53 - MATLAB-AGENT - INFO - Starting simulation 'simulation.m'
=== [DEBUG] Inputs received by the simulation ===
qs (start pose):
-1.5708 -1.2500 1.2500 3.1000 -0.0010 -3.1000
qg (goal pose):
1.5708 -1.2000 1.2000 0 0.0010 0
tf (duration): true
ts (time step): 0.005
showGui: 5
===============================================
Error using simulation
Expected tf to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64
Instead its type was logical.
Error in simulation (line 36)
validateattributes(tf, {'numeric'}, {'scalar','real','finite','>',0}, mfilename, 'tf');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-28 22:15:21 - MATLAB-AGENT - ERROR - Simulation error:
File C:\Users\foo\git\simulation-bridge\agents\matlab\matlab_agent\docs\examples\trajectory-planning-robotic-arm\simulation.m, line 36, in simulation
Expected tf to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64
Instead its type was logical.
Traceback (most recent call last):
File "C:\Users\foo\git\simulation-bridge\agents\matlab\.venv\Lib\site-packages\matlab_agent\src\core\matlab_simulator.py", line 99, in run
result: Union[Any, Tuple[Any, ...]] = self.eng.feval(
^^^^^^^^^^^^^^^
File "C:\Users\foo\git\simulation-bridge\agents\matlab\.venv\Lib\site-packages\matlab\engine\matlabengine.py", line 71, in __call__
_stderr, feval=True).result()
^^^^^^^^
File "C:\Users\foo\git\simulation-bridge\agents\matlab\.venv\Lib\site-packages\matlab\engine\futureresult.py", line 62, in result
return self.__future.result(timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\foo\git\simulation-bridge\agents\matlab\.venv\Lib\site-packages\matlab\engine\fevalfuture.py", line 76, in result
self._result = pythonengine.getFEvalResult(self._future,self._nargout, None, out=self._out, err=self._err)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
matlab.engine.MatlabExecutionError:
File C:\Users\foo\git\simulation-bridge\agents\matlab\matlab_agent\docs\examples\trajectory-planning-robotic-arm\simulation.m, line 36, in simulation
Expected tf to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64
Instead its type was logical.python .\use_matlab_agent_batch.py
[DT] Infrastructure ready.
[DT] Infrastructure ready.
[DT] Request sent → MATLAB (routing key dt.matlab).
Press Ctrl+C to exit manually…
[DT] Waiting for results (binding key 'matlab.result.dt')…
[DT] Result received:
{'bridge_meta': 'unknown', 'destinations': ['dt'], 'error': {'code': 500, 'details': 'InteractiveSimulation.m', 'message': 'Error processing message', 'type': 'execution_error'}, 'request_id': 'unknown', 'simulation': {'name': '', 'type': ''}, 'source': 'matlab', 'status': 'error', 'timestamp': '2025-10-28T22:06:39Z'}
----------------------------------------
[DT] Result received:
{'bridge_meta': {'protocol': 'rabbitmq'}, 'destinations': ['dt'], 'progress': {'percentage': 0}, 'request_id': 'abcdef12345', 'simulation': {'name': 'simulation.m', 'type': 'batch'}, 'source': 'matlab', 'status': 'in_progress', 'timestamp': '2025-10-28T22:14:53Z'}
----------------------------------------
[DT] Result received:
{'bridge_meta': {'protocol': 'rabbitmq'}, 'destinations': ['dt'], 'progress': {'percentage': 50}, 'request_id': 'abcdef12345', 'simulation': {'name': 'simulation.m', 'type': 'batch'}, 'source': 'matlab', 'status': 'in_progress', 'timestamp': '2025-10-28T22:15:15Z'}
----------------------------------------
[DT] Result received:
{'bridge_meta': 'unknown', 'destinations': ['dt'], 'error': {'code': 500, 'message': 'Simulation error: \n File C:\\Users\\foo\\git\\simulation-bridge\\agents\\matlab\\matlab_agent\\docs\\examples\\trajectory-planning-robotic-arm\\simulation.m, line 36, in simulation\nExpected tf to be one of these types:\n\ndouble, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64\n\nInstead its type was logical.\n', 'type': 'execution_error'}, 'request_id': 'unknown', 'simulation': {'name': 'simulation.m', 'type': 'batch'}, 'source': 'matlab', 'status': 'error', 'timestamp': '2025-10-28T22:15:21Z'}
----------------------------------------
agents/matlab/matlab_agent/docs/examples/trajectory-planning-robotic-arm/simulation.m
Show resolved
Hide resolved
| timestamp: "2024-01-01T00:00:00Z" | ||
| timeout: 60 | ||
| inputs: | ||
| qs: [1.5708, -1.2000, 1.2000, 0.0000, 0.0010, 0.0000] |
There was a problem hiding this comment.
This is an list type input. Is this the major change? The PR description hints at it. Just want to be sure. Also is this type supported for outputs as well?
Also simul8 agent supports list type in inputs and outputs. Call you please check to make sure that the implementation is consistent?
There was a problem hiding this comment.
Yes.
The main change in this new use case is the ability to declare and show list-type inputs. In the new YAML example (api/simulation.yaml.example, line 10), qs and qg are arrays of six values. The MATLAB pipeline already supports this: input dictionaries are now ordered by function signature, and any list is converted to matlab.double before execution (matlab_simulator.py, lines 96 and 135).
Outputs are unaffected, _process_results already converts any MATLAB vector or matrix into standard Python lists before returning them (matlab_simulator.py, line 113).
The Simul8 agent is consistent: its configuration examples use lists for rows and columns (simulation_batch.yaml.example, line 7), these are validated as Python arrays and serialized to CSV, and outputs are mapped back as dictionaries, supporting list values when present (simul8_simulator.py, line 296).
Adds dedicated agent for Simul8 software. This agent supports only batch mode simulation and works only on Windows. The code also contains one example. --------- Co-authored-by: Marco Melloni <adddministro@gmail.com> Co-authored-by: prasadtalasila <prasadtalasila@users.noreply.github.com>
|
Hi @prasadtalasila , thanks for the suggestions. Please find my considerations below: The crash was caused by the MATLAB agent relying on the YAML key order to determine the argument order. I’ve also translated all comments into English and verified that list-type input/output handling is consistent with the Simul8 agent. There is a folder: |
|
I’ve checked the Matlab agent code and didn't find any issues. I only made a modification to the client source code to prevent the key parameters from being sorted. Could you please try it now? It works on my PC. |
|



This pull request introduces a new example for joint space control and quintic trajectory tracking for a Universal Robots UR10e robotic arm in MATLAB. It includes a full simulation script, a helper function for quintic polynomial fitting, updated documentation, and an example API YAML. Additionally, there are improvements to the MATLAB simulator's Python integration and its associated unit tests to better handle output processing and empty output lists.
MATLAB Robotic Arm Trajectory Planning Example:
README.md) describing the quintic trajectory tracking approach, control law, input/output parameters, visualization options, and troubleshooting tips for the UR10e robotic arm simulation.simulation.m) for trajectory generation, proportional control with velocity feedforward, data logging, and visualization of robot motion and tracking error.polynomialfit.m) to compute quintic polynomial coefficients for smooth joint trajectories with boundary conditions for position, velocity, and acceleration.api/simulation.yaml.example) for batch simulation requests, specifying input and output formats.Python Integration and Testing Improvements:
matlab_simulator.py) to robustly handle MATLAB results as dicts, lists, tuples, and single values, and to generate default output names when none are provided.test_matlab_simulator.py) to verify correct handling of empty output lists, ensuring the simulator returns outputs with default names and matches expected values.Registrazione.schermo.2025-10-26.alle.00.02.56.mov