ROS与Matlab系列:vrep仿真器中的无人机视觉控制
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.-------------------------------------------------------------------