Matlab Emio Communicaiton - #38
Open
AlessandriniAntoine wants to merge 14 commits into
Open
Conversation
Collaborator
|
We won't merge this PR but we will integrate the UDP server #39, and we created a repo with a minimal the matlab example https://github.com/SofaComplianceRobotics/MatlabxEmio. |
There was a problem hiding this comment.
Pull request overview
Adds a Matlab/Simulink-oriented Python bridge and extends the camera stack to support raw image-frame tracker coordinates and a split acquisition/processing workflow (to enable inter-process synchronization).
Changes:
- Introduces
examples/matlab/with a UDP bridge, multiprocessing camera/motor processes, configuration, and a hardware-free test loop. - Extends
DepthCamera/EmioCamerawithget_frame()+process_frame()separation and exposes raw tracker pixel coordinates (trackers_pos_image). - Adds a plane-intersection helper in position estimation and updates
.gitignorefor MATLAB/Simulink artifacts.
Reviewed changes
Copilot reviewed 16 out of 63 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/matlab/udp_bridge.py | UDP clock-master bridge with handshake, timeout/desync handling, and reconnection logic |
| examples/matlab/main.py | Spawns camera + motor processes and wires shared memory + events |
| examples/matlab/camera.py | Camera process + marker extraction modes (top/front/plan) feeding shared memory |
| examples/matlab/process_motor.py | Motor process synchronized to camera ticks and bridged to Simulink via UDP |
| examples/matlab/test.py | Hardware-free loop to validate UDP bridge against a remote model |
| examples/matlab/params.py | Central configuration for example scripts (fps, UDP ports, camera settings) |
| examples/matlab/README.md | Usage/config docs and Simulink UDP block settings |
| examples/matlab/launch_python.m | MATLAB helper to launch the Python test loop in a terminal |
| emioapi/_depthcamera.py | Splits acquisition vs processing, stores depth rs-frame for point cloud, adds trackers_pos_image |
| emioapi/emiocamera.py | Exposes trackers_pos_image and splits update() into get_frame() + process_frame() |
| emioapi/_positionestimation.py | Adds camera-ray to plane intersection helper (used by "plan" mode) |
| examples/matlab/Jacobian/slprj/sim/varcache/jacobian/tmwinternal/simulink_cache.xml | Generated Simulink cache artifact added to repo |
| examples/matlab/Pendulum/State_Space/slprj/sim/varcache/transfert_function/tmwinternal/simulink_cache.xml | Generated Simulink cache artifact added to repo |
| examples/matlab/Pendulum/State_Space/slprj/sim/varcache/state_space/tmwinternal/simulink_cache.xml | Generated Simulink cache artifact added to repo |
| examples/matlab/Pendulum/slprj/sim/varcache/transfert_function/tmwinternal/simulink_cache.xml | Generated Simulink cache artifact added to repo |
| examples/matlab/Pendulum/slprj/sim/varcache/state_space/tmwinternal/simulink_cache.xml | Generated Simulink cache artifact added to repo |
| .gitignore | Ignores MATLAB/Simulink build/cache outputs (*.slxc, slprj/) |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+365
to
+373
| ray_world = self.camera_image_to_simulation(x, y, 1.0) - self.t | ||
| camera_pos_world = self.t | ||
| denom = plane_n.dot(ray_world) | ||
|
|
||
| if abs(denom) < 1e-6: | ||
| raise ValueError("Ray is parallel to the plane") | ||
| s = - (plane_n.dot(camera_pos_world) + plane_d) / denom | ||
| result = camera_pos_world + s * ray_world | ||
| return [result[0], result[1], result[2]] |
Comment on lines
+96
to
+99
| if side == "top": | ||
| pos = np.array(camera.trackers_pos).reshape(nb_markers, 3).copy() | ||
| pos = pos.astype(np.float64) | ||
| return pos |
Comment on lines
+110
to
+113
| for pixel_pos in camera.trackers_pos_image: | ||
| result = camera._camera.position_estimator.camera_image_to_simulation_plane_intersection( | ||
| pixel_pos[0],pixel_pos[1],prm.plane_n, prm.plane_d) | ||
| trackers_projected.append(result) |
Comment on lines
+1
to
+6
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <MF0 version="1.1" packageUris="http://schema.mathworks.com/mf0/SlCache/19700101"> | ||
| <slcache.FileAttributes type="slcache.FileAttributes" uuid="c7637f53-da09-4dd7-b4b0-a3ccfd495eec"> | ||
| <checksum>1CdfPOZQp2C+bnxfUmNTWYKBUzHQfJ90D+MY45thlKRqvvnRI62WZl9tmrGU0JViLHXTLzVjsSVsQ0wLJGdTBg==</checksum> | ||
| </slcache.FileAttributes> | ||
| </MF0> No newline at end of file |
Comment on lines
+1
to
+6
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <MF0 version="1.1" packageUris="http://schema.mathworks.com/mf0/SlCache/19700101"> | ||
| <slcache.FileAttributes type="slcache.FileAttributes" uuid="94ca11ee-1535-4f1a-8c9e-419ec7eeb144"> | ||
| <checksum>8qJKTnJiuTH/aGZ17KapfN6U09KZubf0XO7c/dUNBkw9N4OlINRVduUJFv6DJp0w1M4iZSujGkrAS9Osjaccsg==</checksum> | ||
| </slcache.FileAttributes> | ||
| </MF0> No newline at end of file |
Comment on lines
+1
to
+6
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <MF0 version="1.1" packageUris="http://schema.mathworks.com/mf0/SlCache/19700101"> | ||
| <slcache.FileAttributes type="slcache.FileAttributes" uuid="ea97faf6-8f70-4221-8aad-4ed8c5c25ada"> | ||
| <checksum>BNqY+xVWfqSfLgDHRoG8onrCNVcJaarE3f9pwALr1FtPC49Ts5/QI6qtSOJzrdX6Y0XNSVxKzDUzQWhcZV9oeg==</checksum> | ||
| </slcache.FileAttributes> | ||
| </MF0> No newline at end of file |
Comment on lines
+1
to
+6
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <MF0 version="1.1" packageUris="http://schema.mathworks.com/mf0/SlCache/19700101"> | ||
| <slcache.FileAttributes type="slcache.FileAttributes" uuid="4fd59ba0-7a75-48fa-bb5a-0c08c968adfb"> | ||
| <checksum>Jhh57wFTTsQB2/9iEyLWm46mwsyh3k2LeYZUtDgDoq3gtr3lhWAK3ItB18HMcTAJmdHu9K913ax+7uvnLohxrg==</checksum> | ||
| </slcache.FileAttributes> | ||
| </MF0> No newline at end of file |
Comment on lines
+1
to
+6
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <MF0 version="1.1" packageUris="http://schema.mathworks.com/mf0/SlCache/19700101"> | ||
| <slcache.FileAttributes type="slcache.FileAttributes" uuid="10d569cb-de26-461b-ac1b-e88403b0a43b"> | ||
| <checksum>Q83cycAKxswSGwblyt++9jH3boxpVi8p2pBf1zOSA9IdIK5zWmpZikphj/Ycn+E0fwdAmgo4ZB9GeXJsAe985w==</checksum> | ||
| </slcache.FileAttributes> | ||
| </MF0> No newline at end of file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
adds a Matlab/Simulink TP extensions to
_depthcamera.pyrequired to support it.Changes to
_depthcamera.pyget_frame()andprocess_frame()into two distinct calls, allowing synchronization via multiprocessing events between the camera and motor control processes.New:
examples/matlab/A complete Python/Simulink bridge for a compliant robotics TP:
params.pyfile