custom ROS service bus assignment

조회 수: 5 (최근 30일)
Nathaniel Goldfarb
Nathaniel Goldfarb 2021년 5월 25일
댓글: Nathaniel Goldfarb 2021년 5월 26일
Hello,
I am trying to call a ROS service using a custom service message in simulink. I have successfuly followed the instruction here: https://www.mathworks.com/help/ros/ug/create-custom-messages-from-ros-package.html to load the custom message into Matlab.
I need to do some string assignment in the message, I have been following the JointState publisher example to assaign the string array.
The problem I am running into is I cannot figure out what the Bus type should be sent too.
My message type is rbdl_server/RBDLInverseDynamicsRequest
So I assigned the bus type: SL_Bus_sliding_controller_rbdl_server_RBDLInverseDynamicsRequest
Which is causing the follow error:
=== Update Diagram (Elapsed: 1 sec) ===
Error:Expression 'SL_Bus_sliding_controller_rbdl_server_RBDLInverseDynamicsRequest' for type of data 'msg' did not evaluate to a valid type.
Caused by:
Invalid setting in 'sliding mode controller/MATLAB Function - String Array Assign1' for parameter 'Datatype'
Error evaluating MATLAB Function parameter data 'Datatype' in its parent workspace.
Unrecognized function or variable 'SL_Bus_sliding_controller_rbdl_server_RBDLInverseDynamicsReques'.
Variable 'SL_Bus_sliding_controller_rbdl_server_RBDLInverseDynamicsReques' does not exist.
what am I doing wrong? It seems like the message name is being truncated (missing the "t" at the end of the name) but I am not sure why that is happening or to fix that.
  댓글 수: 2
Abhijeet Gadkari
Abhijeet Gadkari 2021년 5월 26일
편집: Abhijeet Gadkari 2021년 5월 26일
Hello Nathaniel,
Could you please confirm the value of “DataType” parameter you entered in the MATLAB function block editor - if it matches the name of the bus? Also, could you please share some more information for further debugging:
  1. MATLAB version
  2. Simulink model
  3. Custom message definition
- Abhijeet
Nathaniel Goldfarb
Nathaniel Goldfarb 2021년 5월 26일
Thank you for the help Abhijeet . Is this the information yoiu need? I includeda screen shot to show you what I am looking at in my model.
  1. I am using 2019a
  2. my models name is sliding_controller
  3. Model def:
string model_name
float64[] q
float64[] qd
float64[] qdd
---
float64[] tau

댓글을 달려면 로그인하십시오.

채택된 답변

Abhijeet Gadkari
Abhijeet Gadkari 2021년 5월 26일
편집: Abhijeet Gadkari 2021년 5월 26일
Hello Nathaniel,
Thanks for the information, that was helpful. From the snap-shot of your model, it seems you are using R2019b (please verify using "ver" command in MATLAB).
Verify the names of the buses in your base-workspace.
whos SL_Bus_sliding_controller*
% Output should look as follows:
% Name Size Bytes Class Attributes
%
% SL_Bus_sliding_controller_RBDLInverseDynamicsReques_3qoi39 1x1 1890 Simulink.Bus
% SL_Bus_sliding_controller_geometry_msgs_Point 1x1 220 Simulink.Bus
% SL_Bus_sliding_controller_std_srvs_EmptyRequest 1x1 148 Simulink.Bus
% SL_Bus_sliding_controller_std_srvs_EmptyResponse 1x1 150 Simulink.Bus
The service request bus name (if it followed the convention of model name appended by request message name) would have been longer than 63 character limit.
length('SL_Bus_sliding_controller_rbdl_server_RBDLInverseDynamicsRequest')
So, generated bus name is truncated to meet the 63 character limit and unique hash string is appended to it.
It's recommended to use the data-type drop-down in MATLAB function editor to select the correct Simulink bus data-type.
Select bus from MATLAB function editor data-type drop-down
-Abhijeet
  댓글 수: 1
Nathaniel Goldfarb
Nathaniel Goldfarb 2021년 5월 26일
Awsome that solved my issue perfectly. I used the "ver" command it it said I was using 2021a.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 ROS 2 Network Access in Simulink에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by