Simulink對(duì)于JointState等變長度的數(shù)據(jù)處理起來比較麻煩,可以參考以下幫組教程,但我嘗試的結(jié)果并不好用。無奈之下,只好自定義了一個(gè)topic,然后用m文件重新轉(zhuǎn)發(fā)。(當(dāng)然也可以在ROS里寫一個(gè)腳本轉(zhuǎn)換,但在這里盡量使用matlab)新建一個(gè)scriber,當(dāng)收到數(shù)據(jù)后,便調(diào)用topROSCallback.m轉(zhuǎn)換數(shù)據(jù)(將topROSCallback.m添加到matlab可運(yùn)行的路徑里)。設(shè)置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.-------------------------------------------------------------------
?
免責(zé)聲明:凡注明來源全球無人機(jī)網(wǎng)的所有作品,均為本網(wǎng)合法擁有版權(quán)或有權(quán)使用的作品,歡迎轉(zhuǎn)載,請(qǐng)注明出處。非本網(wǎng)作品均來自互聯(lián)網(wǎng),轉(zhuǎn)載目的在于傳遞更多信息,并不代表本網(wǎng)贊同其觀點(diǎn)和對(duì)其真實(shí)性負(fù)責(zé)。