|
1 |
| -# crtk-matlab-client |
| 1 | +# CRTK Matlab client library for ROS2 |
2 | 2 |
|
3 |
| -## Introduction |
4 |
| - |
5 |
| -The goal of the CRTK Matlab Client utilities is to facilitate the use of ROS CRTK compatible devices in Matlab. The `crtk_utils` class hides all the ROS publishers and subscribers as well as data conversion from ROS messages to Matlab data types (and vice versa). It also provides methods to wait for state transitions such as waiting for a robot to home or wait for a motion to complete. |
6 |
| - |
7 |
| -The following has been tested on Ubuntu 18.04 with Matlab 2020a and Ubuntu 20.04 with Matlab 2020b. |
8 |
| - |
9 |
| -One can find examples of use in the [dVRK ROS package](https://github.com/jhu-dvrk/dvrk-ros/tree/master/dvrk_matlab). |
10 |
| - |
11 |
| -## Custom messages and paths |
12 |
| - |
13 |
| -Matlab's handling of custom messages is working but a bit frustrating to use. Please read carefuly the content of this section, this might save you some time. Choose the instructions to follow based on the Matlab version you're using: |
14 |
| -* [Matlab up to 2020a](./custom_msgs_up_to_2020a.md) |
15 |
| -* [Matlab 2020b and up](./custom_msgs_2020b_and_up.md) |
16 |
| - |
17 |
| -## Usage |
18 |
| - |
19 |
| -The first step is to create a Matlab class with dynamic properties. For example, let's assume we want to create a simple force sensor client: |
20 |
| -```matlab |
21 |
| -classdef force_sensor < dynamicprops |
22 |
| -``` |
23 |
| -The class should own an instance of `crtk_utils`: |
24 |
| -```matlab |
25 |
| - properties (Access = protected) |
26 |
| - crtk_utils; |
27 |
| - end |
28 |
| -``` |
29 |
| -Then in the constructor, create an instance of `crtk_utils` and add the CRTK features you need. For example, if the device supports `measured_cf`, use the method `add_measured_cf()`. |
30 |
| -```matlab |
31 |
| - methods |
32 |
| - function self = force_sensor(ros_namespace) |
33 |
| - self.crtk_utils = crtk.utils(self, ros_namespace); |
34 |
| - self.crtk_utils.add_measured_cf(); |
35 |
| - end |
36 |
| - end |
37 |
| -``` |
38 |
| -The method `add_measured_cf` will create the necessary ROS subscriber and add a function handle (`measured_cf`) to the force sensor class. Once this is done, you can create an instance of the force sensor and call the method `measured_cf`: |
39 |
| -```matlab |
40 |
| ->> fs = force_sensor('optoforce/'); |
41 |
| ->> cf = fs.measured_cf() |
42 |
| -cf = |
43 |
| - -0.0025 -0.0125 0.0775 0 0 0 |
44 |
| -``` |
45 |
| -If there are no messages on the CRTK topic subscribed to, you will get a warning similar to: |
46 |
| -```matlab |
47 |
| ->> cf = fs.measured_cf() |
48 |
| -Warning: measured_cf has not received messages yet (topic /optoforce/measured_cf) |
49 |
| -``` |
50 |
| -This can be used to make sure you're using the right ROS topic name and namespace. |
| 3 | +See crtk-robotics.readthedocs.io |
0 commit comments