Can't read ROS topic in Matlab
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I'm trying to read the /status topic from Husky A200 in Matlab. This is my bag file (20KB) I'm using this code:
%%Retrieve information from the ROSbag
filePath_Pro = 'matlab.bag';
bagPro = rosbag(filePath_Pro);
bagPro_System = select(bagPro, 'Topic', '/status');
N4=bagPro_System.NumMessages;
system_msg = readMessages(bagPro_System);
But when I call readMessages, I get this error:
Error using robotics.ros.BagSelection/deserializeMessages (line 445)
Java exception occurred:
org.ros.exception.RosMessageRuntimeException: java.lang.ClassNotFoundException:
husky_msgs.HuskyStatus
at org.ros.internal.message.definition.MessageDefinitionReflectionProvider.get(MessageDefinitionReflectionProvider.java:66)
at
org.ros.internal.message.DefaultMessageFactory.newFromType(DefaultMessageFactory.java:42)
at org.ros.internal.message.DefaultMessageDeserializer.deserialize(DefaultMessageDeserializer.java:42)
Caused by: java.lang.ClassNotFoundException: husky_msgs.HuskyStatus
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.ros.internal.message.definition.MessageDefinitionReflectionProvider.get(MessageDefinitionReflectionProvider.java:62)
... 2 more
Error in robotics.ros.BagSelection/readMessages (line 195)
msgs = obj.deserializeMessages(obj.MessageList, rows);
This is the output of the topic /status when I read it with rostopic echo /status :
header:
seq: 976
stamp:
secs: 1517311503
nsecs: 918934269
frame_id: ''
uptime: 1148382
ros_control_loop_freq: 9.91557364985
mcu_and_user_port_current: 0.57
left_driver_current: 7.69
right_driver_current: 9.26
battery_voltage: 24.51
left_driver_voltage: 24.67
right_driver_voltage: 24.57
left_driver_temp: 23.42
right_driver_temp: 27.25
left_motor_temp: 14.28
right_motor_temp: 15.51
capacity_estimate: 480
charge_estimate: 0.22
timeout: False
lockout: False
e_stop: False
ros_pause: False
no_battery: False
current_limit: False
I need to read the left_driver_current and right_driver_current. I'm able to read all the other topics, but not the /status topic.
I've already downloaded the Robotics System Toolbox Interface for ROS Custom Messages but I do not know how to use it and I do not know if it is useful for my problem.
I hope you can help me,
Thanks!
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!