求教 看demodemo mode怎么取消消自动导视

查看: 1306|回复: 5|关注: 0
simulink VR工具箱demo求教。。
matlab中有个Vehicle Dynamics Visualization with Graphs例子,就是和虚拟现实工具箱,GUI界面共同做出的仿真例子!自己感觉这个例子特别厉害。有好多不懂:怎样将simulink仿真的结果和VR模拟的结果放在一个GUI中显示??这都用到了什么??求大神解惑。。。自己的项目想做成这种效果。。。。。。。。。。。。。。。。
关注者: 5
所有与这辆车相关的例子都不是在“仿真”
都只是在展示
因为没有计算过程
计算过程可能在其他模型中
所有用到的数据全在test_lap中
这组数据是怎么得来的才是真正厉害的
test_lap中的数据都是“原始状态”
就是不符合3D Animation的vrml语法
所以用了大量的转换模块
这个模型用到了3D Animation和S-Function以及并不能独立算的GUI
利用3D Animation展示动画 两个
需要一个vr sink以及建好的地形与车的模型
定义两个观察点就有两个动画
利用S-Function将动画与坐标轴图形(axes)放在一起
并在S-Function里面设置编辑GUI
如果我的回答解决了你的问题,请采纳最佳答案,为其他有同样问题的人提供帮助,非常感谢。
所有与这辆车相关的例子都不是在“仿真”
都只是在展示
哦哦,有点了解 。但是怎样可以将动画和坐标轴放在一起显示啊?
所有与这辆车相关的例子都不是在“仿真”
都只是在展示
怎样将VR的图像嵌入在GUI中???求教
关注者: 5
function FigHandle = Create_3GFigure(block, worldfile)
% the figure doesn't exist, create one
FigHandle = figure('Units',& && && & 'pixels', ...
& && && && && && & 'Position',& && & [100 100 800 600], ...
& && && && && && & 'Color',& && && & [0.314 0.314 0.314], ...
& && && && && && & 'Name',& && && &&&BlockFigureTitle(block), ...
& && && && && && & 'Tag',& && && && &'octavia_graphs_fig', ...
& && && && && && & 'NumberTitle',& & 'off', ...
& && && && && && & 'IntegerHandle',&&'off', ...
& && && && && && & 'Toolbar',& && &&&'none', ...
& && && && && && & 'DeleteFcn',& && &'octavia_graphs([], [], [], ''DeleteFigure'', [], [])');
% store the block handle in the figure UserData
ud.Block =
% the x-axis (time) range corresponds to the model Stop time
stoptime = str2double(get_param(bdroot, 'StopTime'));
% create the first graph in the figure
ud.G1_Axes = axes('Position', [0.05 0.1 0.28 0.25], ...
& && && && && && &'XGrid',& & 'on', ...
& && && && && && &'YGrid',& & 'on', ...
& && && && && && &'Color',& & 'k', ...
& && && && && && &'XColor',& &'w', ...
& && && && && && &'YColor',& &'w', ...
& && && && && && &'XLim',& &&&[0 stoptime]);
set(ud.G1_Axes, 'Title', title('Speed [m/s]', 'Color', 'w'));& &
ud.G1_Line = line(0, 0, 'EraseMode', 'None', 'Color', 'y', 'LineStyle', '-');& &&&
ud.XData = [];
ud.Y1Data = [];
% create the second graph in the figure
ud.G2_Axes = axes('Position', [0.37 0.1 0.28 0.25], ...
& && && && && && &'XGrid',& & 'on', ...
& && && && && && &'YGrid',& & 'on', ...
& && && && && && &'Color',& & 'k', ...
& && && && && && &'XColor',& &'w', ...
& && && && && && &'YColor',& &'w', ...
& && && && && && &'XLim',& &&&[0 stoptime]);
set(ud.G2_Axes, 'Title', title('Longitudal acceleration [m/s^2]', 'Color', 'w'));&&
ud.G2_Line = line(0, 0, 'EraseMode', 'None', 'Color', 'y', 'LineStyle', '-');
ud.XData = [];
ud.Y2Data = [];
% create the third graph in the figure
ud.G3_Axes = axes('Position', [0.69 0.1 0.28 0.25], ...
& && && && && && &'XGrid',& & 'on', ...
& && && && && && &'YGrid',& & 'on', ...
& && && && && && &'Color',& & 'k', ...
& && && && && && &'XColor',& &'w', ...
& && && && && && &'YColor',& &'w', ...
& && && && && && &'XLim',& &&&[0 stoptime]);&&
set(ud.G3_Axes, 'Title', title('Lateral acceleration [m/s^2]', 'Color', 'w'));& && && && && &&&
ud.G3_Line = line(0, 0, 'EraseMode', 'None', 'Color', 'y', 'LineStyle', '-');
ud.XData = [];
ud.Y3Data = [];
% open vrworld if not open already
vr_world = vrworld(worldfile);
if ~isopen(vr_world)
&&open(vr_world);
end
ud.vr_world = vr_
% create two canvases in the figure
vr.canvas(vr_world, 'Parent', FigHandle, ...
& && && & 'Units', 'normalized', ...
& && && & 'Position', [0.03 0.45 0.45 0.53]);&&
c2 = vr.canvas(vr_world, 'Parent', FigHandle, ...
& && && && && &'Units', 'normalized', ...
& && && && && &'Position', [0.52 0.45 0.45 0.53]);&&
set(c2, 'Viewpoint', 'View_Driver_Car1');
% Associate the figure with the block, and set the figure's UserData.
Set_3GFigure(block, FigHandle);
set(FigHandle, 'UserData', ud, 'HandleVisibility', 'callback');
% end Create_3GFigure复制代码
这个函数就是布局GUI的整个过程了
前后还有很多处理
如果需要可以自己打开demo看看
这个函数就是布局GUI的整个过程了
前后还有很多处理
如果需要可以自己打开demo看看 ...
非常非常感谢!!!!有点懂了~真的很谢谢~我还想问下,这个sfunction是simulink中的子系统模块中的对吧?能不能再详细讲讲这个子系统模块与sfunction函数???拜托大哥了!!!!我自己把vrsink模块链接的wrl文件改成自己的wrl文件后,仿真就出错了,总报错说什么startfuc错误,然后打不开对应的wrl文件???一直找不到原因?我是将自己的wrl文件和它的所有模块都放在同一目录下的!其它端口连接也连对了。求救啊!!方便给个QQ不?
站长推荐 /1
Powered by很久以前就想写这么一个无限滚动的Demo了,最近学习了下Swift,手中没有可以用来练手的Demo,所以才将它实现了。
Github地址(由于使用了UIView+AutoLayout第三方进行布局,所以Github判断主要语言是OC):/wzpziyi1/DisplayingImage
使用UICollectionView来实现的,不同于UIScrollView实现的一点是,就是不需要再手动实现缓存池功能,因为UICollectionView中的cell本就是循环利用的,我只是需要处理好无限滚动以及定时器的移除与添加即可。
这里需要注意下,MJExtension框架,并不能完美支持Swift,我在编写的过程中,利用它解析一个plist文件,并未成功,然后自己写了个KVC解析的,希望MJ老师尽快将它升级为Swift版本吧。
示例图片:
在编写过程中,遇到的问题还是比较多的,是因为我不是那么熟悉Swift导致的,个人觉得Swift现在最不好的一点,就是还没有一个统一的规范。我是从OC转Swift的,所以代码中基本是使用OC的那一套规范,但是从其他语言转过来的,可能就会有很大差异了。
这是一个从plist里面读取数据,并将之存储到数组里面的代码:
class ZYNew: NSObject {
var icon: String!
var title: String!
init(dict: Dictionary&String, String&) {
super.init()
self.setValuesForKeysWithDictionary(dict)
class func getNews() -& Array&ZYNew&
let path = NSBundle.mainBundle().pathForResource("newses.plist", ofType: nil)
let originArray: NSArray? = NSArray(contentsOfFile: path!)
var news = Array&ZYNew&()
originArray?.enumerateObjectsUsingBlock({ (obj: AnyObject, index: Int, stop: UnsafeMutablePointer&ObjCBool&) -& Void in
let tmp = ZYNew(dict: obj as! Dictionary&String, String&)
news.append(tmp)
return news
这里有个极为坑的地方,Swift中的Array类型竟然没有contentsOfFile方法,也就是说,使用Array是不能从一个文件路径中读取一个plist,然后将之转化为数组的。好吧,没有那就算了,反正也是可以使用NSArray,那么我用NSArray转化就好,然后就掉进坑里了。在Swift里面,OC中的NSArray\NSDictionary等里面装的对象它是全部将之认为是anyObject类型的,这就意味着,你在将NSArray强制转化为Array&ZYNew&的时候,是错误的。比如说,在上面的代码,我就使用如下代码强制转化过:& & & & &let originArray: NSArray? = NSArray(contentsOfFile: path!)& & & & &let news: Array&ZYNew& = originArray as! [ZYNew]这样转,在这里是错误的,因为anyObject的真正类型是字典,然后我修改成上面的代码了。
自定义UICollectionViewCell的代码:
import UIKit
class ZYNewCell: UICollectionViewCell {
//Mark:- 存储属性
var new: ZYNew? {
print(new?.icon)
self.imageView.image = UIImage(named: (new?.icon)!)
self.titleLabel.text = new?.title
//MARK:- 计算属性
//MARK:- UI属性
private weak var imageView: UIImageView!
private weak var titleLabel: UILabel!
override init(frame: CGRect) {
super.init(frame: frame)
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
private func commitInit()
let imageView = UIImageView()
imageView.contentMode = UIViewContentMode.ScaleAspectFill
imageView.clipsToBounds = true
self.addSubview(imageView)
self.imageView = imageView
let titleLabel = UILabel()
titleLabel.textAlignment = NSTextAlignment.Center
titleLabel.textColor = UIColor.whiteColor()
self.addSubview(titleLabel)
self.titleLabel = titleLabel
override func layoutSubviews() {
super.layoutSubviews()
self.imageView.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsZero)
self.titleLabel.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsZero, excludingEdge: ALEdge.Bottom)
self.titleLabel.autoSetDimension(ALDimension.Height, toSize: 30)
这里倒是编写得很顺利,由于OC的编码习惯,我喜欢将类的属性进行分层,这样方便我后期开发中快速查找问题所在,代码看过去也是一目了然。
Swift中的属性有两种:& & & & 存储属性:它有willSet和didSet方法& & & & 计算属性:它有set和get方法感觉就是对应OC中的getter和setter方法,可以进行重写。
主要代码ZYImageDisplayingView:
import UIKit
class ZYImageDisplayingView: UIView, UICollectionViewDelegate, UICollectionViewDataSource {
//MARK:- 常量
private let identifier = "ZYNewCell"
//MARK:- 存储属性
override var frame: CGRect{
if (self.collectionView != nil) {
self.collectionView?.removeFromSuperview()
if (frame.width == 0.0 && frame.height == 0.0 && frame.origin.x == 0.0 && frame.origin.y == 0.0) {
let layout = UICollectionViewFlowLayout()
layout.itemSize = frame.size
layout.scrollDirection = UICollectionViewScrollDirection.Horizontal
layout.minimumLineSpacing = 0
let collectionView = UICollectionView(frame: CGRectMake(0, 0, frame.width, frame.height), collectionViewLayout: layout)
collectionView.registerClass(ZYNewCell.self, forCellWithReuseIdentifier: identifier)
collectionView.showsHorizontalScrollIndicator = false
self.addSubview(collectionView)
self.collectionView = collectionView
self.collectionView!.delegate = self
self.collectionView!.dataSource = self
self.collectionView!.backgroundColor = UIColor.whiteColor()
self.collectionView!.pagingEnabled = true
self.collectionView!.scrollToItemAtIndexPath(NSIndexPath(forItem: 0, inSection: ZYImageGroups / 2), atScrollPosition: UICollectionViewScrollPosition.None, animated: false)
self.bringSubviewToFront(pageControl)
self.addTimer()
var news = ZYNew.getNews()
var timer: NSTimer?
//MARK:- 计算属性
//MARK:- UI控件
weak var collectionView: UICollectionView?
weak var pageControl: UIPageControl!
//MARK:- 初始化方法
override init(frame: CGRect) {
super.init(frame: frame)
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
private func commitInit(){
self.backgroundColor = UIColor.yellowColor()
var pageControl = UIPageControl()
pageControl.numberOfPages = self.news.count
pageControl.pageIndicatorTintColor = UIColor.redColor()
pageControl.currentPageIndicatorTintColor = UIColor.whiteColor()
self.addSubview(pageControl)
self.pageControl = pageControl
//MARK:- UICollectionViewDataSource
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -& Int {
return ZYImageGroups
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -& Int {
return self.news.count
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -& UICollectionViewCell {
var cell:ZYNewCell? = collectionView.dequeueReusableCellWithReuseIdentifier(self.identifier, forIndexPath: indexPath) as? ZYNewCell
if (cell == nil) {
cell = ZYNewCell()
print(self.news[indexPath.row])
cell?.new = self.news[indexPath.row]
return cell!
//MARK:- UIScrollViewDelegate
func scrollViewWillBeginDragging(scrollView: UIScrollView) {
self.removeTimer()
//当scrollView减速完毕时调用,最好是在这个时候添加定时器
func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
self.addTimer()
func scrollViewDidScroll(scrollView: UIScrollView) {
let size = scrollView.contentOffset
print(size)
self.pageControl.currentPage = Int(size.x / (self.collectionView?.frame.width)! + 0.5) % self.news.count
//MARK:- 定时器处理
func addTimer()
self.removeTimer()
self.timer = NSTimer(timeInterval: 2, target: self, selector: Selector("updateTimer"), userInfo: nil, repeats: true)
NSRunLoop.mainRunLoop().addTimer(self.timer!, forMode: NSRunLoopCommonModes)
func removeTimer()
self.timer?.invalidate()
self.timer = nil
func updateTimer()
let currentIndexPath = self.resetIndexPath()
var section = currentIndexPath.section
var row = currentIndexPath.row + 1
if (row == self.news.count) {
self.collectionView?.scrollToItemAtIndexPath(NSIndexPath(forItem: row, inSection: section), atScrollPosition: UICollectionViewScrollPosition.None, animated: true)
func resetIndexPath() -& NSIndexPath
let currentIndexPath = self.collectionView?.indexPathsForVisibleItems().first
self.collectionView?.scrollToItemAtIndexPath(NSIndexPath(forItem: (currentIndexPath?.row)!, inSection: ZYImageGroups / 2), atScrollPosition: UICollectionViewScrollPosition.None, animated: false)
return NSIndexPath(forItem: (currentIndexPath?.row)!, inSection: ZYImageGroups / 2)
override func layoutSubviews() {
super.layoutSubviews()
self.pageControl.autoPinEdgeToSuperviewEdge(ALEdge.Bottom, withInset: 8)
self.pageControl.autoPinEdgeToSuperviewEdge(ALEdge.Right, withInset: 20)
self.pageControl.autoSetDimensionsToSize(CGSizeMake(100, 20))
&这部分代码更多的是逻辑处理吧。plist里面只有5个具体的model,我是假设collectionViewCell有100组(也就是section等于100),每一组有5行(也就是row等于5),每一次要滚动到下一个cell的时候,我会先让它滚动到sectio等于50的地方,然后row不变,在开始滚动到下一张,也就是row+1,如果row超过plist中model的个数,那么相应的,section++,row清零。这里值得说的一点的是,我是重写了父类的frame属性,当ZYImageDisplayingView的frame发生改变的时候,就会触发这个属性的didSet方法,我在这个方法里面初始化了UICollectionView,并做了相应的设置。个人认为这里写的不是很好,我不应该在这个方法里面初始化UICollectionView,这要有这样几点考虑:& & & & 如果我是用autoLayout来布局这个控件,是不会触发frame的didSet方法的。& & & & 如果我需要更改ZYImageDisplayingView的位置,那么为了避免重复创建UICollectionView,& & & & 我必须先把以前创建的UICollectionView移除,再& & & & 创建新的collectionView。其他的,OC中的[ZYImageDisplayingView class]对应Swift中的ZYImageDisplayingView.selfOC中的#pragma mark 对应Swift中的 //MARK:-
ViewController里面的代码:
import UIKit
class ViewController: UIViewController {
weak var displayingView: ZYImageDisplayingView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = UIColor.whiteColor()
let displayingView = ZYImageDisplayingView()
self.view.addSubview(displayingView)
self.displayingView = displayingView
self.displayingView.frame = CGRectMake(50, 100, 300, 130)
self.displayingView.autoPinEdgeToSuperviewEdge(ALEdge.Left, withInset: 50)
self.displayingView.autoPinEdgeToSuperviewEdge(ALEdge.Top, withInset: 100)
self.displayingView.autoSetDimensionsToSize(CGSizeMake(300, 130))
这里需要注意的是,不要使用autoLayout对displayingView进行布局,否则会导致collectionView的frame为CGRectZero。当然,这是我的Swift还不怎么熟练所导致的,后续会进行一定的更改。
阅读(...) 评论()demo-move labview编写的软件,可以模拟焊接轨迹运动,对于自动 机器人的示教编程有很好的参
247万源代码下载-
&文件名称: demo-move& & [
& & & & &&]
&&所属分类:
&&开发工具: LabView
&&文件大小: 628 KB
&&上传时间:
&&下载次数: 0
&&提 供 者:
&详细说明:labview编写的软件,可以模拟焊接轨迹运动,对于自动焊接机器人的示教编程有很好的参考作用。-labview write software that can simulate welding trajectory, for teaching programming automatic welding robots have a good reference.
文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):
&&demo-move\demo run.vi&&.........\demo-move.vi&&.........\Display_Glue\Display_Data_Glue.ctl&&.........\............\Display_Face_Glue.vi&&.........\............\Display_Glue.ctl&&.........\............\Display_int_Glue.vi&&.........\............\Display_Path_For_Glue.xctl&&.........\............\Display_State_Read.vi&&.........\............\Display_State_Write.vi&&.........\............\Knife_Pos_2.vi&&.........\............\Knife_Pos_2_Write.vi&&.........\............\Points_To_3D.vi&&.........\............\Points_To_3D_2.vi&&.........\............\Show_Pos_Read.vi&&.........\............\Show_Pos_Write.vi&&.........\gloable-value.vi&&.........\test1.zzz&&.........\test2.zzz&&.........\XY Table\我的源代码发布\D\Program Files (x86)\National Instruments\LabVIEW 2014\vi.lib\express\express input\FileDialogBlock.llb\subFile Dialog.vi&&.........\........\..............\.\...................\....................\............\......\Utility\error.llb\DialogType.ctl&&.........\........\..............\.\...................\....................\............\......\.......\.........\General Error Handler.vi&&.........\........\..............\.\...................\....................\............\......\.......\file.llb\Close File+.vi&&.........\........\..............\.\...................\....................\............\......\.......\........\Open File+.vi&&.........\........\..............\.\...................\....................\............\......\.......\........\Read File+ (string).vi&&.........\........\..............\.\...................\....................\............\......\.......\........\Read From Spreadsheet File (DBL).vi&&.........\........\..............\.\...................\....................\............\......\.......\........\Read From Spreadsheet File (I64).vi&&.........\........\..............\.\...................\....................\............\......\.......\........\Read From Spreadsheet File (string).vi&&.........\........\..............\.\...................\....................\............\......\.......\........\Read From Spreadsheet File.vi&&.........\........\..............\.\...................\....................\............\......\.......\........\Read Lines From File.vi&&.........\........\..............\.\...................\....................\............\......\.......\........\Write Spreadsheet String.vi&&.........\........\..............\.\...................\....................\............\......\.......\........\Write To Spreadsheet File (DBL).vi&&.........\........\..............\.\...................\....................\............\......\.......\........\Write To Spreadsheet File (I64).vi&&.........\........\..............\.\...................\....................\............\......\.......\........\Write To Spreadsheet File (string).vi&&.........\........\..............\.\...................\....................\............\......\.......\........\Write To Spreadsheet File.vi&&.........\........\..............\E\XY Table Current\demo run.vi&&.........\........\..............\.\................\demo-move.vi&&.........\........\..............\.\................\gloable-value.vi&&.........\........ Current\Display_Glue\Display_Data_Glue.ctl&&.........\................\............\Display_Face_Glue.vi&&.........\................\............\Display_Glue.ctl&&.........\................\............\Display_int_Glue.vi&&.........\................\............\Display_Path_For_Glue.xctl&&.........\................\............\Display_State_Read.vi&&.........\................\............\Display_State_Write.vi&&.........\................\............\Knife_Pos_2.vi&&.........\................\............\Knife_Pos_2_Write.vi&&.........\................\............\Points_To_3D.vi&&.........\................\............\Points_To_3D_2.vi&&.........\................\............\Show_Pos_Read.vi&&.........\................\............\Show_Pos_Write.vi&&.........\演示说明.pptx&&.........\XY Table\我的源代码发布\D\Program Files (x86)\National Instruments\LabVIEW 2014\vi.lib\express\express input\FileDialogBlock.llb&&.........\........\..............\.\...................\....................\............\......\.......\express input&&.........\........\..............\.\...................\....................\............\......\Utility\error.llb&&.........\........\..............\.\...................\....................\............\......\.......\file.llb&&.........\........\..............\.\...................\....................\............\......\express&&.........\........\..............\.\...................\....................\............\......\Utility&&.........\........\..............\.\...................\....................\............\vi.lib&&.........\........\..............\.\...................\....................\LabVIEW 2014&&.........\........\..............\.\...................\National Instruments&&.........\........\..............\.\Program Files (x86)&&.........\........\..............\E\XY Table Current&&.........\........\..............\D&&.........\........\..............\E&&.........\........\我的源代码发布&&.........\........ Current\Display_Glue&&.........\Display_Glue&&.........\XY Table&&.........\XY Table Current&&demo-move
&输入关键字,在本站247万海量源码库中尽情搜索:

我要回帖

更多关于 java教务管理系统demo 的文章

 

随机推荐