# V2X_SJTU
## Introduction
A repository of basic codes and usage instructions for [Mokar V2X devices](https://www.huali-tec.com/project.php). The project is sponsored by Shanghai Jiaotong University.
Here are some introductions and tutorials for the V2X device. Honestly speaking, I 'm just a beginner in this field. My document and tutorial contain only some basic ways to code & run programs on the V2X device.
**Instruction about Symbols**
In this instruction, all the linux commands with "$" should be run on your own computer, and the orders with "#" should be run on device.
## Content
1. Description
2. Installation
3. Hardware Connection
4. Before Communication
5. Samples
6. Coding
7. TCP Communication
8. Other Problems
9. Contact
## 1.Description
Folder tree:
.
├── lidar_ros *--ros package for message sending*
│ ├── include
│ ├── msg
│ └── src
├── mde *--SDK provided by Mokar Technology*
│ └── mocar
│ ├── bin *--Compiled files here*
│ ├── build *--Make file here*
│ ├── docs *--Documents by Mocar*
│ ├── libs *--Library*
│ ├── license *--License*
│ └── samples *--Some sample codes by Mokar, except Lidar_send and Lidar_recv generated by Fantasticos*
├── NTP *--Clock Synchronization Software*
│ └── ntpclient-2015
└── TCP_Scripts *--TCP communication code*
├── test_tcp_1 *--Old version 1*
├── test_tcp_2 *--Old version 2*
├── test_tcp_3 *--Latest version*
└── test_tcp_3 (copy) *--Copy of old version 3*
***mde*** is a developing kit provided and copyrighted by Mokar Technology.
***TCP_Scripts*** contains some simple programs and their codes for socket TCP communication between **computer** and **Mokar V2X devices**.
***lidar_ros*** is a ros package sending messages to road side devices
***NTP*** is a software for clock synchronization
## 2. Installation
To clone the codes from Github
`$ cd /your_own_work_space`
`$ git clone https://github.com/Fantasticos/V2X_SJTU.git`
Install some essential libraries
`$ sudo apt-get install libc6:i386`
`$ sudo apt-get install lib32stdc++6`
`$ sudo apt-get install lib32z1`
**Install *arm-linux-gnueabihf* cross compiler**
Download [compiler](https://pan.baidu.com/s/1o6HW8bS#list/path=%2Fshare)
Move *.tar* to `/opt`
`$ sudo mv gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux/ /opt`
Extract
`$ tar -xvf gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux.tar`
Modify profile
`$ cd /etc`
`$ sudo gedit profile`
add `export PATH=$PATH:/opt/gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux/bin`
`$ sudo gedit ~/.bashrc`
add `source /etc/profile`
reboot the terminal
## 3. Hardware Connection
Refer to the handbook provided by Huali for hardware wire connection instruction
If you want to connect your computer and v2x device by Wifi, search for Wifi AP named "IMASTERXXXX", default device ip address 192.168.10.1
If you want to connect through Ethernet, change your local ip address to be 192.168.253.1 and wire-connect directly to the Mokar device, or through a switch. Default device ip address 192.168.253.10
## 4. Before Communication
Suppose you connect through a wire, the ip address of V2X device will be 192.168.253.10. If you connect wirelessly, just replace the ip with 192.168.10.1
**IMPORTANT**
You should change your ip address according to your target address. For example, if you want to connect to 192.168.253.10 with Ethernet, you have to change your own ipv4 address to be 192.168.253.x, x can be replaced by any integer from 0 to 255 except 10 (you cannot set your ip to be identical with your device's)
Before you test the communicaiton, you have to upload the essential libraries.
```
$ cd mde/mocar/libs
$ scp libmocarv2x.so root@192.168.253.10:/usr/lib/
$ scp base/libasnhl.so root@192.168.253.10:/usr/lib/
$ scp base/libosstoed.so root@192.168.253.10:/usr/lib/
$ scp base/libLLC.so root@192.168.253.10:/usr/lib/
$ scp base/libstack.so root@192.168.253.10:/usr/lib/
$ scp base/libsmartway.so root@192.168.253.10:/usr/lib/
$ scp ../samples/mocar_log.conf root@192.168.253.10:/usr/local
```
**PASSWORD:** hL2017.moKar
## 5. Run Samples
The sample codes are in `mocar/samples`, you can compile the sample under `mocar/build`
```
$ cd mde/mocar/build
$ make
```
Upload the sample app to the v2x device, take **bsm** for example
```
$ cd ../bin
$ scp bsm root@192.168.253.10:/var
```
Open a new terminal, log into the device through SSH
`$ ssh -l root 192.168.253.10`
**PASSWORD:** hL2017.moKar
Enter `/var` and run the sample app
`# cd /var`
`# ./bsm`
If warn `undefined symbol: mde_stack_init`, just remove `usr/local` and upload the .conf file again.
`# rm -rf /usr/local/*`
`$ scp ../samples/mocar_log.conf root@192.168.253.10:/usr/local`
Now you can see the device sending bsm message at 10 HZ.
You can repeat this process and upload program to another Mokar device, run the same `./bsm`, you can definitely see the two device communicating!!!
**If you want to change the IP of device**
`# vi /etc/network/interfaces`
change the address
## 6. Coding
The coding work now takes place in `mocar/samples`
Two example are provided, *lidar_send* and *lidar_recv*. I wrote these two program for my graduation project. They combine both TCP communication and BSM message.
To generate your own code, I suggest you to copy one sample, like **bsm**, copy the folder and rename the folder. Also remember to replace the code file name and the name in makefile.
Now you can write any funcion in c++ you like!!!
## 7. TCP Communicaiton
The communication between computer and V2X device is done by TCP.
In **TCP_Scripts**, programs include *client* and *server*, client runs on the computer and server runs on the device.
In my project, the tcp server is merged into `samples/lidar_send` and `samples/lidar_recv`. *lidar_send* is for the Road Side Device, while *lidar_recv* is for the On Board device
To test, you can upload *lidar_send* or *lidar_recv* to the device, these two are both tcp servers. *lidar_send* is for road side unit while *lidar_recv* is for on board unit.
I wrote 2 clients for this project, one is road side client. It subscribe messages from rostopic and publish them through tcp to the road side v2x device.
Another client is `TCP_Scripts/test_tcp_3/TCP_Client2.c` or its executable `client2`
I also wrote a `talker.cpp` to simulate the message published by the lidar.
To fully function the communication chain, follow the steps **carefully**:
1. Move `/lidar_ros` to your own workspace i.e. `catkin_ws`
```
$ cd catkin_ws
$ catkin_make
$ roscore
```
2. Start the 2 tcp servers on the devices, take the road side device for example, you can repeat it again with OBU.
use ssh login 192.168.10.1
`# cd /var`
`# ./lidar_send`
open another terminal and ssh login again, use the ntp to synchronize the two clock
`# cd /var`
`# ./ntpclient -s -d -c 1 -i 5 -h 192.168.10.101`
**you can refer to 8. Other Problems for instruction on ntpclient**
**ATTENTION**
Some times when you run *lidar_send* or *lidar_recv* you will meet the segment fault. This is because the time should be changed to 01/01/2010 before running the program. (I'm also confused why, but this is what the engineer told me)
To fix this problem
open another terminal, ssh login
`# date 0101000010`
3. Start the clients
for road side unit, open the client to send messages
`$ rosrun lidar_ros talker`
`$ rosrun lidar_ros listener 192.168.10.1`
for on board unit
`$ cd TCP_Scripts/test_tcp_3`
`$ ./client2 192.168.253.10`
Now you can see the two device communicating messages generated by talker.
## 8. Other Problems
**Synchronization of clock**
To make sure that the clock
没有合适的资源?快使用搜索试试~ 我知道了~
软件技术毕业设计项目源码-V2X_SJTU:MocarV2X设备的基本代码和使用说明存储库。该项目由上海交通大学赞助
共111个文件
c:22个
makefile:13个
o:12个
需积分: 47 7 下载量 154 浏览量
2021-06-12
00:49:49
上传
评论 1
收藏 2.38MB ZIP 举报
温馨提示
软件技术毕业设计 项目源码V2X_上海交通大学 介绍 的基本代码和使用说明的存储库。 该项目由上海交通大学赞助。 这里有一些 V2X 设备的介绍和教程。 老实说,我只是这个领域的初学者。 我的文档和教程仅包含一些在 V2X 设备上编码和运行程序的基本方法。 符号说明在本说明中,所有带“$”的linux命令都应该在你自己的电脑上运行,带“#”的命令应该在设备上运行。 内容 描述 安装 硬件连接 沟通前 样品 编码 TCP通讯 其他问题 接触 1.说明 文件夹树: . ├── lidar_ros --ros 消息发送包│ ├── 包括│ ├── 味精│ └── src ├── mde --摩卡科技提供的SDK │ └── 莫卡│ ├── bin --编译文件在这里│ ├── build --在这里制作文件│ ├── docs --Documents by Mocar │├──库--library │ ├── license --License │ └── samples -- Mokar 的一些示例代码,除了 Fantasticos 生成的 Lidar_send 和 Lidar_recv
资源详情
资源评论
资源推荐
收起资源包目录
软件技术毕业设计项目源码-V2X_SJTU:MocarV2X设备的基本代码和使用说明存储库。该项目由上海交通大学赞助 (111个子文件)
ntpclient.1 3KB
adjtimex.1 2KB
rate2.awk 5KB
rate.awk 666B
bsm 16KB
ntpclient.c 19KB
phaselock.c 11KB
lidar_send.c 10KB
lidar_recv.c 10KB
bsm_main.c 5KB
map_main.c 5KB
spat_main.c 5KB
adjtimex.c 4KB
TCP_Client2.c 4KB
tim_main.c 4KB
srm_main.c 4KB
ssm_main.c 4KB
rtcm_main.c 4KB
tcp_server.c 4KB
rsa_main.c 3KB
TCP_Client.c 3KB
TCP_Server.c 2KB
tcp_client.c 2KB
TCP_Server.c 2KB
tcp_server.c 2KB
tcp_client.c 2KB
TCP_Client.c 1KB
client 13KB
client 13KB
client 9KB
client 7KB
client2 13KB
mocar_log.conf 1005B
listener.cpp 5KB
talker.cpp 2KB
test.dat 12KB
mk_reg.dat 80B
envelope 2KB
base.tar.gz 683KB
lidar_recv(copy).tar.gz 8KB
v2x_msg_tim.h 19KB
v2x_msg_bsm.h 12KB
v2x_msg_spat.h 9KB
v2x_msg_map.h 9KB
v2x_msg_common.h 5KB
v2x_msg_srm.h 4KB
v2x_msg_ssm.h 3KB
v2x_api.h 2KB
v2x_msg_rtcm.h 1KB
v2x_msg_rsa.h 1KB
ntpclient.h 353B
HOWTO 9KB
lidar_recv 21KB
lidar_send 21KB
Makefile 1KB
Makefile 576B
Makefile 512B
Makefile 512B
Makefile 503B
Makefile 503B
Makefile 502B
Makefile 501B
Makefile 501B
Makefile 501B
Makefile 501B
Makefile 501B
Makefile 309B
map 18KB
README.md 9KB
lidar_grad.msg 78B
ntpclient 19KB
lidar_recv.o 16KB
lidar_send.o 16KB
map_main.o 15KB
tim_main.o 14KB
srm_main.o 14KB
ssm_main.o 14KB
spat_main.o 13KB
bsm_main.o 12KB
rsa_main.o 11KB
rtcm_main.o 10KB
ntpclient.o 9KB
phaselock.o 6KB
Mocar V2X SDK API Specification 3.0.pdf 419KB
Mocar V2X SDK user manual 3.0.pdf 316KB
log2date.pl 320B
README 10KB
reg32 10KB
reg64 10KB
rsa 15KB
rtcm 15KB
server 13KB
server 13KB
server 13KB
server 13KB
libasnhl.so 947KB
libosstoed.so 535KB
libLLC.so 218KB
libmocarv2x.so 105KB
libstack.so 14KB
共 111 条
- 1
- 2
weixin_38722193
- 粉丝: 5
- 资源: 908
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0