Difference between revisions of "Algorithms and Data Structures"

From David Vernon's Wiki
Jump to: navigation, search
(Created page with "ThIs guide provides a step-by-step guide to downloading, installing, and checking the software required to develop DREAM software and write and run DREAM robot applications....")
 
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
ThIs guide provides a step-by-step guide to downloading, installing, and checking the software required to develop DREAM software and write and run DREAM robot applications.  
+
This page provides some additional resources that are relevant to my course on [http://vernon.eu/ADS.htm Algorithms and Data Structures] on my main website.
 +
== Software Development Environment ==
  
== Operating System ==
 
  
We assume you are running Windows 7.
+
This guide provides a step-by-step guide to downloading, installing, and using the software required to submit an assignment for the Algorithms and Data Structures course.  This environment is required to ensure that software developed by students can be compiled directly by the course instructor after it has been submitted.
  
== C/C++ Compiler ==  
+
=== Operating System ===
  
Download the Microsoft Visual C++ Express compiler, version 10.0 (also known as Visual C++ 2010).  It is important to use this version; earlier versions are no longer supported by Microsoft and later versions cause problems with YARP.  
+
I assume you are running Windows 7.
  
This is significant because you will be downloading the YARP binaries in the next step and these are version-specific.  
+
=== C/C++ Compiler ===
 +
 
 +
Download the Microsoft Visual C++ Express compiler, version 10.0 (also known as Visual C++ 2010 or MSVC++ 2010).  It is important to use this version; earlier versions are no longer supported by Microsoft and later versions cause problems with some libraries.  
  
 
You can download the required compiler from [http://www.visualstudio.com/downloads/download-visual-studio-vs here].
 
You can download the required compiler from [http://www.visualstudio.com/downloads/download-visual-studio-vs here].
Line 15: Line 17:
 
Run the installer and follow the instructions.
 
Run the installer and follow the instructions.
  
Once the compiler is installed, try compiling a simple program.  Some versions of Windows 7 may need the the Microsoft Visual Studio 2010 Service Pack 1 to be installed.  If you get an error trying to compile and run a simple program, this may be the problem.  CMake (see below) will also fail in this case.
 
  
== YARP ==
+
'''Problem Alert'''
  
Download the YARP v. 2.3.63  binaries for x86, MSVC v. 10.  Here's the [http://wiki.icub.org/wiki/Downloads#Windows link to the instructions] and here is the  
+
Some versions of Windows 7 may need the the Microsoft Visual Studio 2010 Service Pack 1 to be installed.   If you have problems with CMake (see below) this is almost certainly the cause.   To be on the safe side, you can install Service Pack 1 by following the instructions [http://www.microsoft.com/en-us/download/details.aspx?id=23691 here]. You can also check to see whether or not you have Service Pack 1 by checking the your version number:  from the Microsoft Visual C++ 2010 Express menu, select ''Help > About Visual C++ 2010 Express''. You will see a message on the top right something like the following.
[http://sourceforge.net/projects/yarp0/files/yarp2/yarp-2.3.63/windows/yarp_2.3.63_v10_x86_0.exe/download link] to the installer itself.
+
  
Run the installer and follow the instructionsThe installer will do everything for you including updating your path and adding all the necessary environment variables.
+
Microsoft Visual Studio 2010
 +
Version 10.0.40219.1 RTMRel
 +
  Microsoft .NET Framework
 +
Version 4.0.30319 RTMRel
  
== CMake ==
+
The <code>RTMRel</code> means <code>Release To Manufacturing</code>.  If you have Service Pack 1 installed you would see something like the following.
 +
 
 +
Microsoft Visual Studio 2010
 +
Version 10.0.40219.1 SP1Rel
 +
Microsoft .NET Framework
 +
Version 4.0.30319 SP1Rel
 +
 
 +
=== CMake ===
  
 
Download CMake binaries from [http://www.cmake.org/download/ here].   
 
Download CMake binaries from [http://www.cmake.org/download/ here].   
 +
  
 
You can opt for either the WIN32 installer or the Windows zip file.  The installer has the advantage that it gives you the option to update your system path automatically (which you should take by clicking the appropriate radio button during the installation process).
 
You can opt for either the WIN32 installer or the Windows zip file.  The installer has the advantage that it gives you the option to update your system path automatically (which you should take by clicking the appropriate radio button during the installation process).
  
== OpenCV ==
+
=== ADS Repository ===
  
Download and install OpenCV from [http://sourceforge.net/projects/opencvlibrary/files/opencv-win/ here].  Choose the version 2.4.9 self-installer, download it, and execute it, and extract the library to <code>C:</code>.
+
Copy the full ADS repository to the <code>C:</code> drive. 
 +
This will be made available the next time the course is being run.
  
Add <code>C:\opencv\build\x86\vc10\bin</code> to the PATH environment variable and add a new environment variable <code>OPENCV_DIR</code> with the value <code>C:\opencv\build</code>, as follows.
+
<!-- You can download a zip archive with all the files from  [http://www.vernon.eu/ADS.zip here]. -->
  
* From Windows 7 toolbar, select ''Control Panel > System and Security > System > Advanced System Settings''
+
Copy it to <code>C:</code> drive and unzip it so that you have a directory called <code>C:\ADS</code> with a sub-directory structure explained in class (for our purposes here, there will be an  <code>assignments</code> sub-directory and it will contain an example <code>assignment</code> sub-directory ... later on there will be <code>C:\ADS\assignments\assignment1</code> and <code>C:\ADS\assignments\assignment2</code>, and so on).  A <code>C:\ADS\lectures</code> sub-directory will also be added with the code from the lectures.
* Click ''Environment Variables''
+
* Select <code>Path</code> from ''System Variables''
+
* Click ''Edit''
+
* Add <code>C:\opencv\build\x86\vc10\bin</code> (be sure to separate different paths with a semi-colon)
+
* Under ''User variables'', click ''New''
+
* Insert <code>OPENCV_DIR</code> in the ''Variable name'' box and <code>C:\opencv\build</code> in the ''Variable value'' box
+
* Click ''OK''
+
  
== DREAM Repository ==
 
  
Copy the full DREAM repository to the <code>C:</code>  drive.  Since the official DREAM repository is not yet available, you can download a zip file from [http://www.vernon.eu/DREAM.zip here].
+
The next step is to build a MSVC++ <code>.sln</code> solution file so that you can compile all the ADS executables. To do this, you need to run CMake against the <code>C:ADS\assignment</code> directory (where you will find the main <code>CMakeLists.txt</code> file).
 
+
Copy it to <code>C:</code> drive and unzip it so that you have a directory called <code>C:\DREAM</code> with a sub-directory structure shown below.
+
 
+
The next step is to build a MSVC++ <code>.sln</code> solution file so that you can compile all the DREAM executable components. To do this, you need to run CMake against the <code>C:DREAM\release</code> directory (where you will find the main <code>CMakeLists.txt</code> file)  
+
  
 
* Launch the CMake GUI from the Windows 7 toolbar.
 
* Launch the CMake GUI from the Windows 7 toolbar.
  
* In the ''Where is the source code:'' input (browse to)  <code>C:\DREAM\release</code>
+
* In the ''Where is the source code:'' input (browse to)  <code>C:\ADS\assignments\assignment</code>
  
* In the ''Where to build the binaries:'' input (browse to) <code>C:\DREAM\release\bin</code>
+
* In the ''Where to build the binaries:'' input (browse to) <code>C:\ADS\assignments\assignment\build</code>
  
* Select ''File > Delete Cache'' from the top menu (you '''must''' do this the first time in case there is an old invalid configuration in the DREAM directory)
+
* Select ''File > Delete Cache'' from the top menu (you '''must''' do this the first time in case there is an old invalid configuration in the ADS directory)
  
 
* Click ''Configure''
 
* Click ''Configure''
Line 67: Line 67:
 
* Click ''Finish'' and watch CMake configure your project.  The dialogue box will still highlighted in red so ...
 
* Click ''Finish'' and watch CMake configure your project.  The dialogue box will still highlighted in red so ...
  
* Click ''Configure'' again and everything should be fine (unless you have forgotten to download and install OpenCV, in which case you will get an error and you will have install OpenCV and start this process again)
+
* Click ''Configure'' again and everything should be fine.
  
* Click ''Generate''  to create the MSVC++ <code>DREAM.sln</code> file in <code>C:\DREAM\release\bin</code>
+
* Click ''Generate''  to create the MSVC++ <code>assignment.sln</code> file in <code>C:\ADS\Assignment\build</code>. Do this twice.
  
  
Next, update your environment variables.  
+
Now you are ready to launch MSVC++ and build the ADS assignment executables.
  
* From Windows 7 toolbar, select ''Control Panel > System and Security > System > Advanced System Settings''
+
* Go to the <code>C:\ADS\assignments\assignment\build</code> directory and open the <code>Assignment.sln</code> file.  This launches Microsoft Visual C++ 2010 Express.
  
* Click ''Environment Variables''
+
* Select <code>Release</code> in the ''Solutions Configuration'' box.
  
* Select <code>Path</code> from ''System Variables''
+
* Select ''Build > Build Solution'' from the top menu, (if you don't see this and you see  ''Debug > Build Solution'' instead, it's probably because your IDE is set to basic settings. To change this, select ''Tools > Settings > Expert Settings'').
  
* Click ''Edit''
 
  
* Add <code>C:\DREAM\release\bin\Release</code> (be sure to separate different paths with a semi-colon)
+
This will compile and link the programs in the the <code>C:\ADS\assignments\assignment\src</code> sub-directory and install then in the <code>C:\ADS\assignments\assignment\bin</code> directory.
  
* Under ''User variables'', click ''New''
 
  
* Insert <code>DREAM_ROOT</code> in the ''Variable name'' box and <code>C:\DREAM</code> in the ''Variable value'' box
+
Check to see that the example <code>Vernon</code> executable is thereIf it is not, then select  'Build > Configuration Manager'' from the menu and make sure the ''INSTALL'' check-box is ticked.   Now rebuild the project again.
 
+
* Click ''OK''
+
+
 
+
Now you are ready to launch MSVC++ and build the DREAM component executables.  
+
 
+
* Go to the <code>C:\DREAM\release\bin</code> directory and open the <code>DREAM.sln</code> fileThis launches Microsoft Visual C++ 2010 Express.
+
 
+
* Select <code>Release</code> in the ''Solutions Configuration'' box (Why? Because you specified <code>C:\DREAM\release\bin\Release</code> when updating your path environment variable above).
+
 
+
* Select ''Build > Build Solution'' from the top menu, (if you don't see this and you see  ''Debug > Build Solution'' instead, it's probably because your IDE is set to basic settings. To change this, select ''Tools > Settings > Expert Settings'').
+
  
  
This will compile and link the components in the the <code>C:\DREAM\release\bin\Release</code> sub-directory. Check to see that both component executables are there. If they are not, build the solution again.
+
You are now ready to run the example <code>Vernon</code>  application that is provided with the ADS release. To do this, double click the< code>Vernon</code> executable in <code>C:\ADS\assignments\assignment\bin</code>.   Open <code>input.txt</code> file and, after running <code>Vernon</code>, the <code>output.txt</code> file.
  
You are now ready to run the test applications that are included in each component sub-directory (see directory structure below) and to begin developing your own components.
 
  
To run the test application for the <code>protoComponent</code> example that is provided with the DREAM release, follow the instructions on the [[Software Users Guide]].
+
To develop your own assignment program, you need to edit the <code>C:\ADS\assignments\assignment\src\CMakeLists.txt</code> file and uncomment out the line with your name by deleting the <code>#</code> character at the beginning of the line.  Now, copy your source files (<code>.c, .cpp, .h</code>) to the directory with your name, and then run CMake again.  Then re-open the <code>Assignment.sln</code> file. Your files should now be visible and you can now compile your code and install it in the <code>bin</code> directory by selecting ''Build > Build Solution'' from the top menu.  Again, make sure that the ''INSTALL'' check-box is ticked when you select ''Build > Configuration Manager'' from the menu to ensure that your executable is installed in the <code>C:\ADS\assignments\assignment\bin</code> directory.
  
 +
== Humour ==
  
<center><strong>Logical Directory Structure of the DREAM Repository</strong></center>
+
[http://xkcd.com/1185/ Some Ineffective Sorts]
  
[[File:directory_structure.png]]
+
[https://xkcd.com/399/ Travelling Salesman Problem]

Latest revision as of 02:14, 5 September 2021

This page provides some additional resources that are relevant to my course on Algorithms and Data Structures on my main website.

Software Development Environment

This guide provides a step-by-step guide to downloading, installing, and using the software required to submit an assignment for the Algorithms and Data Structures course. This environment is required to ensure that software developed by students can be compiled directly by the course instructor after it has been submitted.

Operating System

I assume you are running Windows 7.

C/C++ Compiler

Download the Microsoft Visual C++ Express compiler, version 10.0 (also known as Visual C++ 2010 or MSVC++ 2010). It is important to use this version; earlier versions are no longer supported by Microsoft and later versions cause problems with some libraries.

You can download the required compiler from here.

Run the installer and follow the instructions.


Problem Alert

Some versions of Windows 7 may need the the Microsoft Visual Studio 2010 Service Pack 1 to be installed. If you have problems with CMake (see below) this is almost certainly the cause. To be on the safe side, you can install Service Pack 1 by following the instructions here. You can also check to see whether or not you have Service Pack 1 by checking the your version number: from the Microsoft Visual C++ 2010 Express menu, select Help > About Visual C++ 2010 Express. You will see a message on the top right something like the following.

Microsoft Visual Studio 2010
Version 10.0.40219.1 RTMRel
Microsoft .NET Framework
Version 4.0.30319 RTMRel

The RTMRel means Release To Manufacturing. If you have Service Pack 1 installed you would see something like the following.

Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel
Microsoft .NET Framework
Version 4.0.30319 SP1Rel

CMake

Download CMake binaries from here.


You can opt for either the WIN32 installer or the Windows zip file. The installer has the advantage that it gives you the option to update your system path automatically (which you should take by clicking the appropriate radio button during the installation process).

ADS Repository

Copy the full ADS repository to the C: drive. This will be made available the next time the course is being run.


Copy it to C: drive and unzip it so that you have a directory called C:\ADS with a sub-directory structure explained in class (for our purposes here, there will be an assignments sub-directory and it will contain an example assignment sub-directory ... later on there will be C:\ADS\assignments\assignment1 and C:\ADS\assignments\assignment2, and so on). A C:\ADS\lectures sub-directory will also be added with the code from the lectures.


The next step is to build a MSVC++ .sln solution file so that you can compile all the ADS executables. To do this, you need to run CMake against the C:ADS\assignment directory (where you will find the main CMakeLists.txt file).

  • Launch the CMake GUI from the Windows 7 toolbar.
  • In the Where is the source code: input (browse to) C:\ADS\assignments\assignment
  • In the Where to build the binaries: input (browse to) C:\ADS\assignments\assignment\build
  • Select File > Delete Cache from the top menu (you must do this the first time in case there is an old invalid configuration in the ADS directory)
  • Click Configure
  • Select Visual Studio 10 (2010) from the drop-down menu as the generator for the project
  • Click Finish and watch CMake configure your project. The dialogue box will still highlighted in red so ...
  • Click Configure again and everything should be fine.
  • Click Generate to create the MSVC++ assignment.sln file in C:\ADS\Assignment\build. Do this twice.


Now you are ready to launch MSVC++ and build the ADS assignment executables.

  • Go to the C:\ADS\assignments\assignment\build directory and open the Assignment.sln file. This launches Microsoft Visual C++ 2010 Express.
  • Select Release in the Solutions Configuration box.
  • Select Build > Build Solution from the top menu, (if you don't see this and you see Debug > Build Solution instead, it's probably because your IDE is set to basic settings. To change this, select Tools > Settings > Expert Settings).


This will compile and link the programs in the the C:\ADS\assignments\assignment\src sub-directory and install then in the C:\ADS\assignments\assignment\bin directory.


Check to see that the example Vernon executable is there. If it is not, then select 'Build > Configuration Manager from the menu and make sure the INSTALL check-box is ticked. Now rebuild the project again.


You are now ready to run the example Vernon application that is provided with the ADS release. To do this, double click the< code>Vernon</code> executable in C:\ADS\assignments\assignment\bin. Open input.txt file and, after running Vernon, the output.txt file.


To develop your own assignment program, you need to edit the C:\ADS\assignments\assignment\src\CMakeLists.txt file and uncomment out the line with your name by deleting the # character at the beginning of the line. Now, copy your source files (.c, .cpp, .h) to the directory with your name, and then run CMake again. Then re-open the Assignment.sln file. Your files should now be visible and you can now compile your code and install it in the bin directory by selecting Build > Build Solution from the top menu. Again, make sure that the INSTALL check-box is ticked when you select Build > Configuration Manager from the menu to ensure that your executable is installed in the C:\ADS\assignments\assignment\bin directory.

Humour

Some Ineffective Sorts

Travelling Salesman Problem