Error in port widths or dimensions

5 visualizaciones (últimos 30 días)
oualid doukhi
oualid doukhi el 23 de En. de 2018
Respondida: Andrew Tayler el 1 de Nov. de 2021
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 comentarios
krishneel kumar
krishneel kumar el 13 de Feb. de 2018
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 el 21 de Mzo. de 2019
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?

Iniciar sesión para comentar.

Respuestas (5)

Tohru Kikawada
Tohru Kikawada el 21 de Feb. de 2018
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 comentario
Mahdi Nobar
Mahdi Nobar el 21 de Mzo. de 2019
Editada: Mahdi Nobar el 21 de Mzo. de 2019
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?

Iniciar sesión para comentar.


Calogero Forte
Calogero Forte el 4 de Oct. de 2018
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 comentarios
Mahdi Nobar
Mahdi Nobar el 5 de Jun. de 2019
You need to inistall Robotics System toolbox and ROS custom message for MATLAB. Follow the instructions on links below:
Ami
Ami el 6 de Oct. de 2020
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.

Iniciar sesión para comentar.


Li Jack
Li Jack el 5 de Jun. de 2019
Hello, have you solved this problem? I was stuck in this problem too, also using ros message.

Aaron Angert
Aaron Angert el 24 de En. de 2020
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 comentarios
Ami
Ami el 23 de Oct. de 2020
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 el 26 de Oct. de 2020
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.

Iniciar sesión para comentar.


Andrew Tayler
Andrew Tayler el 1 de Nov. de 2021
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;

Community Treasure Hunt

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

Start Hunting!

Translated by