jMAVSim半硬件仿真(HITL)
2016-07-19 12:31
1526 查看
jMAVSim半硬件仿真(HITL)
jMAVSim,玩四轴的朋友会知道这是一款模拟器,用来模拟飞行器的各种旋转动作。官网也有对jMAVSim做了解释:
jMAVSim is a simple and lightweight multirotor simulator. It connects directly to the hardware-in-the-loop (HITL, via serial) or software-in-the-loop (SITL, via UDP) instance of the autopilot.
大体意思是jMAVSim是一个简单的轻量级多转子模拟器。它直接连接到硬件(HITL,通过串行)或软件(SITL,通过UDP)自动驾驶仪的实例。
下面介绍一下jMAVSim半硬件仿真的实际操作方法,也可以直接访问官方网站:http://www.pixhawk.com/dev/hil/jmavsim
1.获取jMAVSim文件
获取jMAVSim文件是直接从git服务器上克隆的,执行指令(环境是Ubuntu14):
jMAVSim,玩四轴的朋友会知道这是一款模拟器,用来模拟飞行器的各种旋转动作。官网也有对jMAVSim做了解释:
jMAVSim is a simple and lightweight multirotor simulator. It connects directly to the hardware-in-the-loop (HITL, via serial) or software-in-the-loop (SITL, via UDP) instance of the autopilot.
大体意思是jMAVSim是一个简单的轻量级多转子模拟器。它直接连接到硬件(HITL,通过串行)或软件(SITL,通过UDP)自动驾驶仪的实例。
下面介绍一下jMAVSim半硬件仿真的实际操作方法,也可以直接访问官方网站:http://www.pixhawk.com/dev/hil/jmavsim
1.获取jMAVSim文件
获取jMAVSim文件是直接从git服务器上克隆的,执行指令(环境是Ubuntu14):
$ git clone https://github.com/PX4/jMAVSim.git[/code]运行jMAVSim需要添加相关依赖$ sudo apt-get install ant openjdk-7-jdk openjdk-7-jre在这里有些同学会遇到一些问题,安装不上,主要是Java版本降级的原因,后续介绍。。。
mac系统执行指令:brew install ant
2.工程建立和运行
运行jMAVSim需要初始Git仓库~/Documents$ cd jMAVSim/ ~/Documents/jMAVSim$ git submodule init ~/Documents/jMAVSim$ git submodule update
运行~/jMAVSim$ ant Buildfile: /jMAVSim/build.xml make_dirs: compile: jmavsim: all: BUILD SUCCESSFUL Total time: 0 seconds
3.半硬件仿真(HITL,Hardware in
the Loop)
官方也给出了相关的仿真步骤,经常动手的同学知道,官网的例子运行的好好地,为什么到了我的系统上就不行了呢?
官网给出的步骤:
Hardware
in the Loop (HITL)
Here is an example for quadrotor X.
1.Configure PX4 autopilot for HIL setup using either of these methods:
a.Using QGroundControl: Connect to board, click Setup, click Airframe, check the box in the Simulation selection (last one in list) and pick the type of HIL setup you want from the drop-down. Apply and Restart, Reconnect.
b.By hand: Set parameter SYS_AUTOSTART = 1001, save parameters and reboot.
2.Run jMAVSim in HITL mode. Change the serial port to the port of Pixhawk and make sure to have QGroundControl NOT connected to serial.java -Djava.ext.dirs= -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator -serial /dev/tty.usbmodem1 921600 -qgc3.The console will display mavlink text messages from the autopilot.
4.To connect QGroundControl to this system: Select the default UDP link from the “connect” button in the top right corner and connect it.
5.Ready to fly!
大致翻译一下:
以四轴为例
1,使用a,b中任何一个方法配置PX4自动驾驶
a.使用QGC:链接板子,点击设置,选择飞机框架,勾选选择模拟器(最后一个)并选择HIL类型(每次选择飞机类型都要校准传感器,个人觉得比较烦。问题1:选择模拟模式的时候,遥控器遥控飞机的时候,飞机实物电机会不会不转,而在模拟环境中转?待考证。。。),应用重启,重新连接。
b.手动:设置SYS_AUTOSTART参数为1001,保存重启。
2.在HIL模式下运行jMAVSim,将串口改为Pixhawk串口,并且确保QGC没有连接到串口。(问题2:还不知道硬件怎么接?)
打开终端输入指令:~/jMAVSim$ java -Djava.ext.dirs= -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator -serial /dev/tty.usbmodem1 921600 -qgc Options parsed, starting Sim. Starting GUI... 3D [dev] 1.6.0-pre12-daily-experimental daily ERROR: Failed to open MAV port: jssc.SerialPortException: Port name - /dev/tty.usbmodem1; Method name - openPort(); Exception type - Port not found. ^CShutting down...但是报错了,提示打不开MAV端口,原因是没有端口权限。。。端口权限我也是第一次听说,感觉自己好low
下面打开端口权限执行指令:$ sudo chmod 777 /dev/ttyACM0(输入打开端口权限指令的时候,端口一定要介入,不然会显示找不到文件)
再次输入指令,但是要做修改:~/Documents/jMAVSim$ java -Djava.ext.dirs= -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator -serial /dev/ttyACM0 921600 -qgc Options parsed, starting Sim. Starting GUI... 3D [dev] 1.6.0-pre12-daily-experimental daily Init MAVLink MSG: [inav] GPS signal found MSG: [inav] init ref: 47.3977420, 8.5455940, 488.0000 MSG: [inav] GPS timeout MSG: [inav] GPS signal foundjMAVSim成功打开了!
后面利用无线通信模块将四轴跟电脑Win系统里面的QGC相连接,打开安全开关就可以用力遥控器遥控飞机了,QGC可以查看飞机的路径,速度,高度等信息;jMAVSim可以查看飞机的具体动作,方向等信息。
后面解答一下那两个问题吧!
问题1:我没采用选择模拟类型的方法,我感觉那样比较繁琐,每次还要校准,我选择改变参数的方法,遥控器控制的时候,实体飞机是不动的,只有飞控板在工作。
问题2:连接方式,飞控板通过USB线连接虚拟机中的linux,然后再利用无线模块将飞控板与Win系统中的QGC相连,最后打开安全开关,就可以控制飞机了。
相关文章推荐
- px4开发指南——linux下qgroundcontrol地面站安装
- Ubuntu下编译QGroundControl源码
- QGroundControl for mac(模块化应用程序) V3.2.1 破解版
- 解决Pixhawk启动解锁过程中出现一些问题
- 使用无线数传 radio telemetry 连接pixhawk进入offboard模式进行mavlink协议通讯的尝试
- pixhawk 模拟飞行
- stackoverflow第一篇帖子
- Bootstrap基本使用
- java基础之关键字、标识符等
- Android 传感器
- POJ3070 Fibonacci
- ldconfig和ldd用法详解
- [LeetCode] 25. Reverse Nodes in k-Group
- qsort和sort的详解和比较函数的区别
- JQuery 控制元素显示隐藏
- Notification 的onCreate多次执行
- 对抽象,继承,多态的理解
- Lua中强大的元方法__index详解
- linux进程通信(一)--共享内存--mmap()
- wing IDE破解方法