Git Product home page Git Product logo

haoxiaozi / v2x_sjtu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fantasticos/v2x_sjtu

0.0 2.0 0.0 15.69 MB

A repository of basic codes and usage instructions for Mocar V2X devices. The project is sponsored by Shanghai Jiaotong University

Makefile 11.89% C 68.18% Shell 3.02% M4 2.06% Emacs Lisp 0.01% HTML 10.27% CSS 0.02% C++ 1.94% Objective-C 0.05% sed 0.01% Yacc 0.22% Perl 0.90% Batchfile 0.15% Perl 6 0.02% Awk 0.17% Assembly 0.01% Roff 0.40% Scheme 0.03% Python 0.41% Ruby 0.24%

v2x_sjtu's Introduction

V2X_SJTU

Introduction

A repository of basic codes and usage instructions for Mokar V2X devices. 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.

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:
.
├── 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
└── 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.

2. Installation

To clone the codes from Github
$ cd /your_own_work_space
$ git clone https://github.com/Fantasticos/V2X_SJTU.git

Install arm-linux-gnueabihf cross compiler

Download compiler

Move .tar to /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 If you want to connect 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, so the ip address of V2X device is 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 [email protected]:/usr/lib/  
$ scp base/libasnhl.so [email protected]:/usr/lib/  
$ scp base/libosstoed.so [email protected]:/usr/lib/  
$ scp base/libLLC.so [email protected]:/usr/lib/  
$ scp base/libstack.so [email protected]:/usr/lib/  
$ scp base/libsmartway.so [email protected]:/usr/lib/  
$ scp ../samples/mocar_log.conf  [email protected]:/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 [email protected]:/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 [email protected]:/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!!!

6. Coding

The coding work now take place in mocar/samples
Two example are provided, lidar_send and lidar_recv. I wrote these two program for my graduation project. They combine TCP communication and BSM message sending and recving.
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 add any funcion 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, then move to test_tcp_3,run
$ ./client 192.168.253.10

or you can replace the ip address with 192.168.10.1 if connected through Wifi

8. Other Problems

Synchronization of clock

To make sure that the clock are at the same pace, I use NTP to synchronize it.

The NTP server should be installed on your own computer, you can google it yourself, there are plenty of tutorials.

The problem is that the compilation of NTP client in the device is difficult because it use gcc-linaro-arm-linux-gnueabihf to compile files. To make this step easy, I compiled the client on my computer and just share the executable

$ cd NTP/ntpclient-2015
$ scp ntpclient [email protected]:/var

If you have finished the construction of NTP server on your own computer, you can run the following code on the device, and you can see your clock synchronized.
./ntpclient -s -d -c 1 -i 5 -h 192.168.253.1

9. Contact

If you have any questions, feel free to email me. My email address is [email protected]

v2x_sjtu's People

Contributors

fantasticos avatar

Watchers

James Cloos avatar wenqingji avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.