Error in port widths or dimensions

조회 수: 5 (최근 30일)
oualid doukhi
oualid doukhi 2018년 1월 23일
답변: Andrew Tayler 2021년 11월 1일
I am using Robotics System toolbox to publish direct motor commands (Angular velocities=[v1,v2,v3,v4]) for a quadrotor (rotors simulator) as following
I got the following error
Error in port widths or dimensions. Output port 1 of 'pelican/Command Velocity Publisher/Mux' is a one-dimensional vector with 4 elements. Component: Simulink | Category: Model error Error in port widths or dimensions. Input port 2 of 'pelican/Command Velocity Publisher/Bus Assignment1' is a one-dimensional vector with 128 elements.
when I publish through the terminal using rospub it works fine
rostopic pub /pelican/command/motor_speed mav_msgs/Actuators '{angular_velocities: [100, 100, 100, 100]}'
I tried to manage the array sizes for ROS msgs in Simulink from 128 to 4 :
in this case, Simulink running without error, but I got a new error and gazebo simulator shutdown,
Thanks in advance
  댓글 수: 2
krishneel kumar
krishneel kumar 2018년 2월 13일
Hey I had the same issues as you did. Have you managed to solve the latter? I have been stuck at this for a while now.
Thanks in advance
Mahdi Nobar
Mahdi Nobar 2019년 3월 21일
Hi, could you manage to solve the error? Is there any way to send the AngularVelocity from topic type mav_msgs/Actuators directly from Simulink to Gazebo?

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

답변 (5개)

Tohru Kikawada
Tohru Kikawada 2018년 2월 21일
If you want to assign the data to the variable-length array, you will need to follow the "Task 1 - Access Data in a Variable-length Array" section in this link.
Hope this helps.
  댓글 수: 1
Mahdi Nobar
Mahdi Nobar 2019년 3월 21일
편집: Mahdi Nobar 2019년 3월 21일
Hi, I looked at the link but it could not solve the error. According to the claim of this website Interfacing RotorS through Matlab, the error is because of the fact that MathWorks Robotics System Toolbox only supports the forwarding of custom messages only via Matlab scripts, and the Simulink schemes have to be adapted and integrated with Matlab scripts for exchanging data and commands with ROS and Gazebo. So, I was wondering this claim would be correct? Isn't there any way to send the AngularVelocity from topic type mav_msgs/Actuators directly from Simulink to Gazebo?

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


Calogero Forte
Calogero Forte 2018년 10월 4일
Ehi, How did you work with "mav_msgs/xxx" message type? In my enviroment, this type of message does not exist and Matlab does't create the custome messages with rosgenmsg function.
  댓글 수: 2
Mahdi Nobar
Mahdi Nobar 2019년 6월 5일
You need to inistall Robotics System toolbox and ROS custom message for MATLAB. Follow the instructions on links below:
Ami
Ami 2020년 10월 6일
Hi. If you don't mind, can you please share how you used rosgenmsg and were you using windows? I'm having a bit of trouble with that function.

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


Li Jack
Li Jack 2019년 6월 5일
Hello, have you solved this problem? I was stuck in this problem too, also using ros message.

Aaron Angert
Aaron Angert 2020년 1월 24일
All variables in the ROS bus start off empty, so just make a matlab function that loops through and assigns each vector element to the ones coming in, i.e.:
function y = fcn(Bus, Ct, Points, Current_len, ReceivedLen)
Bus.Ct = Ct;
disp(size(Points,1))
for c = 1:size(Points,1)
Bus.Points(c) = Points(c);
end
Bus.Points_SL_Info.CurrentLength = Current_len;
Bus.Points_SL_Info.ReceivedLength = ReceivedLen;
y = Bus;
  댓글 수: 2
Ami
Ami 2020년 10월 23일
Hello. Where do I get the Ct, Points, Current_len, ReceivedLen so that I can supply the function with those values? Can you please show a screenshot of how you implemented this method in Simulink?
Aaron Angert
Aaron Angert 2020년 10월 26일
Hi, Ct is specific for the bus in this example you can leave that out. Points is the array of data values, Current_len and recieved_len are also specific to the bus, and are the amount of points in the array. you can use a matlab function in simulink to implement the above code.

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


Andrew Tayler
Andrew Tayler 2021년 11월 1일
I encountered this same issue and managed to solve it by changing the dimensions of the mav_msgs_Actuators bus in the Model Explorer to 4 and then updating the bus with a matlab function like Aaron suggested. See below:
Hope this helps.
function msg = fcn(Bus,angVel) % Input modified mav_msgs_Actuators bus and motor speeds
Bus.AngularVelocities = angVel'; % [motor1, motor2, motor3, motor4]'
Bus.AngularVelocities_SL_Info.CurrentLength = uint32(4); % Update the length of the velocities vector
msg = Bus;

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by