我正在使用此代码中的示例程序http://sicktoolbox.sourceforge.net/ > http://sourceforge.net/projects/sicktoolbox/files/.它基本上是一个距离扫描仪驱动程序.我想要运行的程序是在sicktoolbox-1.0.1/c ++/examples/lms/lms_plot_values中,以防你想看到我正在谈论的代码.
无论如何,lms_plot_values项目文件夹包含gnuplot_i.cc,gnuplot_i.hpp,main.cc,Makefile,Makefile.am,Makefile.in.所以我把前三个文件放在我的Eclipse Indigo CDT中,编译(没有编译错误,一切都已经在Eclipse中正确链接,并且添加了所有需要的库),但是这个示例程序被编写为接受命令行参数.这是代码得到的.
/*!
* \file main.cc
* \brief Illustrates how to acquire a measurements from the Sick
* LMS 2xx using the configured measuring mode.
*
* Note: This example should work for all Sick LMS 2xx models.
*
* Code by Jason C. Derenick and Thomas H. Miller.
* Contact derenick(at)lehigh(dot)edu
*
* The Sick LIDAR Matlab/C++ Toolbox
* Copyright (c) 2008, Jason C. Derenick and Thomas H. Miller
* All rights …Run Code Online (Sandbox Code Playgroud) 我对Java非常熟悉,这是允许的.然而,看起来它不适用于C++.我在尝试分配valuesToGrab = updatingValues;时收到"无效的数组赋值".
//these are class attributes
int updatingValues[361] = {0};
int valuesToGrab[361] = {0};
//this is part of a function that is causing an error.
for (unsigned int i=0; i < 10; i++) {
//this fills values with 361 ints, and num_values gets set to 361.
sick_lms.GetSickScan(values,num_values);
//values has 361 ints, but a size of 2882, so I copy all the ints to an array
//of size 361 to "trim" the array.
for(int z = 0; z < num_values; …Run Code Online (Sandbox Code Playgroud) 我非常习惯Java,我可以创建一个ArrayList来保存多个对象,但我不知道如何在C++中这样做.
我有6个不同的对象:WebcamData UltrasonicData KinectData ImuData GpsData SickData
我需要在一个数组中保存每个实例.
在java中它会是这样的:
ArrayList array = new ArrayList();
array.add(new WebcamData);
array.add(new UltrasonicData);
Run Code Online (Sandbox Code Playgroud)
等等...
如何在C++中创建类似的数组?
谢谢