Windows/Matlab 和Ubuntu/Ros 通讯 自定义消息格式的设置

1、下载matlab的附加包

 

 适用于2017b之后的版本

2、将ros里边写的消息包整个拷贝出来

 

3、在matlab的安装目录里边建立一的自定义消息信息文件夹(my_msg)

我的路径:

 上图中,vehicle_msg 是ros拷贝的自定义消息格式的pkg,直接整个放到my_msg下,matlab_gen 是调用工具后生成的,现在不用管。

matlab  
  ____| my_msg
          ____| vehicle_msg 
                     ______| msg
                     ______| include
                     ______| src
                     ______| packge.xml

4、调用 ROS toolbox 里的函数

matlab命令行输入:

rosgenmsg('C:\my_software\matlab2020a\my_msg')

如果成功会显示:

Checking subfolder "vehicle_msg" for custom messages.
 
Building custom message files for the following packages:
   vehicle_msg
 
 
Generating MATLAB classes for message packages in C:\my_software\matlab2020a\my_msg\matlab_gen\jar.
 
Loading file vehicle_msg-0.0.0.jar.
Generating MATLAB code for vehicle_msg/control message type.
Generating MATLAB code for vehicle_msg/decision message type.
Generating MATLAB code for vehicle_msg/global_path message type.
Generating MATLAB code for vehicle_msg/lane message type.
Generating MATLAB code for vehicle_msg/local_map message type.
Generating MATLAB code for vehicle_msg/local_path message type.
Generating MATLAB code for vehicle_msg/localpath_pose message type.
Generating MATLAB code for vehicle_msg/localpath_stamped message type.
Generating MATLAB code for vehicle_msg/obstacle message type.
Generating MATLAB code for vehicle_msg/obstacle_trajectory message type.
 
To use the custom messages, follow these steps:
 
1. Edit javaclasspath.txt, add the following file locations as new lines, and save the file:
 
C:\my_software\matlab2020a\my_msg\matlab_gen\jar\vehicle_msg-0.0.0.jar
 
2. Add the custom message folder to the MATLAB path by executing:
 
addpath('C:\my_software\matlab2020a\my_msg\matlab_gen\msggen')
savepath
 
3. Restart MATLAB and verify that you can use the custom messages. 
   Type "rosmsg list" and ensure that the output contains the generated
   custom message types.

需要按照指示完成三步:

(1)点击打开” javaclasspath.txt “,

将“C:\my_software\matlab2020a\my_msg\matlab_gen\jar\vehicle_msg-0.0.0.jar”放入txt文件保存

 (2)终端输入命令

>> addpath('C:\my_software\matlab2020a\my_msg\matlab_gen\msggen')
>> savepath

  (3)重启完活

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值