ROS-虚拟CAN通讯/实质CAN通信

1.源码安装canopen
从官网下载canopen至Ubuntu,下载地址:
https://github.com/ros-industrial/ros_canopen/tree/kinetic-devel

2.创建ROS文件的canopen框架:

mkdir -p ~/canopen/src  #建立一个名为canopen的文件夹
cd ~/canopen/
$ catkin_make

3.再将刚才下载的canopen文件解压到/canopen/src文件目录下.

4.安装:sudo apt install libmuparser-dev(已安装可以跳过此步骤)

5.终端再次输入(提前安装:sudo apt install libmuparser-dev省的缺少依赖报错):

$ catkin_make

6.编译完成后,执行:

source ~/canopen/devel/setup.bash

此处留意,要是在第2步在其他路径创建的ROS框架;此处的~/canopen/需要替换相对应的文件路径;

7.为了以后每次执行方便can命令可以将此步编写进:/home下的.bashrc内.

source ~/can_open/devel/setup.bash  #command  modeprode(can/canopen)

配置CAN
终端输入:

$ sudo modprobe mttcan
$ sudo modprobe can
$ sudo modprobe can_raw
$ sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on
$ sudo ip link set up can0
$ sudo ip link set can1 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on
$ sudo ip link set up can1

使用

$ ifconfig

查询CAN端口是否打开


3、测试
新建终端打开roscore

$ roscore

新建终端输入:

$  rosrun socketcan_bridge socketcan_to_topic_node

可以查看是否成功连接上了CAN0

在新建终端输入:

$ rostopic echo /received_messages

可以在线监测来自于can0收到的数据

虚拟CAN操作借鉴:(如何在linux上创建虚拟CAN_Unknown Screwer的博客-CSDN博客_虚拟can

1.sudo modprobe vcan

加载虚拟can模块

2.sudo ip link add dev can0 type vcan

添加can0网卡

3.ifconfig -a

查看can0

 4.sudo ip link set dev can0 up

开启can0

5.sudo ip link set dev can0 down

关闭can0

6. sudo ip link del dev can0

删除can0

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
In file included from /home/acceler/code/apollo_ros/apollo_ros/src/apollo.ros-1.0.0-master/apollo_common/include/apollo_common/apollo_app.h:46:0, from /home/acceler/code/apollo_ros/apollo_ros/src/apollo.ros-1.0.0-master/apollo_common/src/apollo_app.cc:33: /home/acceler/code/apollo_ros/apollo_ros/src/apollo.ros-1.0.0-master/apollo_common/include/apollo_common/log.h:40:10: fatal error: glog/logging.h: No such file or directory #include <glog/logging.h> ^~~~~~~~~~~~~~~~ compilation terminated. apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/build.make:62: recipe for target 'apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/src/apollo_app.cc.o' failed make[2]: *** [apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/src/apollo_app.cc.o] Error 1 make[2]: *** Waiting for unfinished jobs.... In file included from /home/acceler/code/apollo_ros/apollo_ros/src/apollo.ros-1.0.0-master/apollo_common/include/apollo_common/adapters/adapter_manager.h:48:0, from /home/acceler/code/apollo_ros/apollo_ros/src/apollo.ros-1.0.0-master/apollo_common/src/adapters/adapter_manager.cc:33: /home/acceler/code/apollo_ros/apollo_ros/src/apollo.ros-1.0.0-master/apollo_common/include/apollo_common/adapters/adapter.h:49:10: fatal error: glog/logging.h: No such file or directory #include <glog/logging.h> ^~~~~~~~~~~~~~~~ compilation terminated. apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/build.make:110: recipe for target 'apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/src/adapters/adapter_manager.cc.o' failed make[2]: *** [apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/src/adapters/adapter_manager.cc.o] Error 1 CMakeFiles/Makefile2:3894: recipe for target 'apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/all' failed make[1]: *** [apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [ 54%] Linking CXX executable /home/acceler/code/apollo_ros/apollo_ros/devel/lib/IntegratedNavigation/IntegratedNavigation_node [ 54%] Built target IntegratedNavigation_node [ 55%] Linking CXX executable /home/acceler/code/apollo_ros/apollo_ros/devel/lib/TimeSynchronierProcess/timeSynchronierProcess_node [ 55%] Built target timeSynchronierProcess_node Makefile:140: recipe for target 'all' failed make: *** [all] Error 2 Invoking "make -j4 -l4" failed
07-23

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值