Error in port widths or dimensions

19 次查看(过去 30 天)
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 中查找有关 Publishers and Subscribers 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by