Simulink对于JointState等变长度的数据处理起来比较麻烦,可以参考以下帮组教程,但我尝试的结果并不好用。无奈之下,只好自定义了一个topic,然后用m文件重新转发。(当然也可以在ROS里写一个脚本转换,但在这里尽量使用matlab)新建一个scriber,当收到数据后,便调用topROSCallback.m转换数据(将topROSCallback.m添加到matlab可运行的路径里)。设置Variable-length arrays 参考帮助:Working with ROS messages in Simulink· Variable-length arrays (ROS type ...[]) are converted to fixed-length array with customizable maximum lengths. By default, the fixed length is 128 for primitive types (e.g., uint8[],float32[]), and 16 for nested arrays of messages (e.g., geometry_msgs/Point[]).Tools > Robot Operating System > Manage Array Sizes.找到SL_Bus_robotROS2_sensor_msgs_JointState把position、velocity、effort的Dimension从128改为4Receiving and applying commands from ROS.-------------------------------------------------------------------
免责声明:凡注明来源全球无人机网的所有作品,均为本网合法拥有版权或有权使用的作品,欢迎转载,请注明出处。非本网作品均来自互联网,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。