Remote Development of Mobotware Using Eclipse: Difference between revisions
No edit summary |
(→Ubuntu) |
||
(One intermediate revision by the same user not shown) | |||
Line 90: | Line 90: | ||
sshfs {kalmanusername}@kalman.iau.dtu.dk:''projectpath'' ''mountPoint'' | sshfs {kalmanusername}@kalman.iau.dtu.dk:''projectpath'' ''mountPoint'' | ||
If you created a tunnel as described before, | If you created a tunnel as described before, then you need to go through that tunnel | ||
sshfs -p 10000 {kalmanusername}@localhost:''projectpath'' ''mountPoint'' | sshfs -p 10000 {kalmanusername}@localhost:''projectpath'' ''mountPoint'' | ||
Line 100: | Line 100: | ||
== Set up an Eclipse Remote Development Project == | == Set up an Eclipse Remote Development Project == | ||
Go to '''File->New->Project...'''. Under '''C/C++''', choose '''C++ Project''' and click '''Next'''. Give your project a name, and uncheck the '''Use default location''' checkbox. This will enable the '''Location''' field. Choose the base folder of your project inside the | Go to '''File->New->Project...'''. Under '''C/C++''', choose '''C++ Project''' and click '''Next'''. Give your project a name, and uncheck the '''Use default location''' checkbox. This will enable the '''Location''' field. Choose the mounted base folder of your project inside the ''mountPoint''. In the '''Project Type''' field, choose '''Makefile project->Empty Project'''. Choose whichever GCC option in the '''Toolchains''' field. Create the project by pressing '''Finish'''. | ||
Your project should now be visible in the '''Project Explorer''' view. At this point, you should be edit your source files, perform content assist on them and use many other Eclipse features, except for debugging on the robot and building on the server. If that is enough for you, you can stop here. | |||
Next, we need to define the connections to ''nyquist'' (or ''jensen'') for compiling the project and to the SMR of your choice for running and debugging the executables on. | |||
Again, if you're not on the automation network, you will need to tunnel some ports. In order to be able to ssh to these, you will have to forward, say, 10001 to ''nyquist'' port 22 and 10002 to SMRX (replace X!!!) port 22. You will also need to tunnel to an extra port on the SMR for the remote GDB server to communicate with your local GDB client. Eclipse CDT uses the port 2345 by default, so let's just forward that. | |||
'''Windows''' | |||
Add the new tunnels to the session settings... | |||
'''Ubuntu''' | |||
ssh -L10001:nyquist.iau.dtu.dk:22 -L10002:smrx.iau.dtu.dk:22 -L2345:smrx.iau.dtu.dk:2345 {gbarusername}@login.gbar.dtu.dk | |||
We now need to define the connection to SMRX in eclipse. Go to '''File->New->Other...'''. Under '''Remote System Explorer''' choose '''Connection''' and press '''Next'''. Choose '''SSH Only''' and press '''Next'''. | |||
'''If you have direct access to SMRX (you are in the automation network):''' | |||
* You can simply give ''smrx.iau.dtu.dk'' as the host name, so write ''smrx'' in the '''Host name''' and the '''Connection name''' fields and press '''Finish'''. | |||
'''If you are tunneling to the SMR instead:''' | |||
* You need to write ''localhost'' in the ''Host name''' field and ''smrx'' in the '''Connection name''' field. In this case, you also need to specify that we are connecting through port 10002. To do that, go to '''Window->Show View->Other...''' and pick '''Remote Systems Details''' under '''Remote Systems'''. As a result, the '''Remote System Details''' view opens somewhere. Double-click on the ''smrx'' connection, and change all the ports (The 3rd column of the table) to 10002. | |||
Now right click on your project in the '''Project Explorer''' view and pick '''Properties'''. Pick '''C/C++ Build''' and under '''Builder Settings''' uncheck the '''Use default build command''' checkbox. In the '''Build command''' field, type: | |||
'''If you have direct access to SMRX:''' | |||
ssh {kalmanusername}@nyquist.iau.dtu.dk "cd ''projectPath''; make" | |||
'''else:''' | |||
ssh -p 10001 {kalmanusername}@localhost "cd ''projectPath''; make" | |||
Do not forget to replace {kalmanusername} and ''projectPath''. Under '''Behavior''' tab, you might want to uncheck the '''Build (Incremental build)''' and '''Clean''' checkboxes to avoid unnecessary, lengthy builds all the time. Don't forget to build your project when it's necessary though. Press '''OK''' to finish. | |||
In order to set up the debugging; right click on your project in the '''Project Explorer''' view and pick '''Debug As->Debug Configurations...'''. Right click on '''C/C++ Remote Application''' and pick '''New'''. Under the '''Main''' tab, choose ''smrx'' in the connection dropdown list. Click '''Browse''' next to the '''C/C++ Application''' field, and choose the executable you would like to debug on the SMR. Then enter the absolute path of that executable in the SMRX file system. You can also find that file by using the '''Browse''' button and picking the ''smrx'' connection. If you would like to run the executable in a special folder (f.x. where you have your .ini files...), in the '''Commands to execute before application''' field, type: | |||
cd ''workingDirectory'' | |||
''workingDirectory'' being obviously the directory that you want to run your executable in. Finally, check the '''Skip download to target path''' checkbox. If you press '''Debug''' now, you will start debugging! (given that you have built your project and SMRX is running etc...) |
Latest revision as of 16:05, 15 June 2011
It is possible to use an Eclipse, running locally on one's computer to remotely develop Mobotware residing in Kalman. This tutorial will describe how to set up eclipse so that one can:
- use full features of Eclipse including indexing, content assist, error highlighting and much more...
- build on the automation servers from inside Eclipse
- debug the code running on the SMRs while stepping through the source code and observing variables in Eclipse
The following description is for Eclipse Galileo (Eclipse 3.5.2), hopefully, the steps will not be very different in future versions.
There are essentially 4 things to do:
- Install Eclipse and the required plug-ins
- Mounted on the local file system the Mobotware directory (or a sub-directory of it) residing in Kalman.
- Set up an Eclipse project for remote development
- Configure Eclipse to make sure all the nice features are available
NOTE: The windows tutorial is not finished as of this very moment!
Install Eclipse
One first needs to install Eclipse, along with the necessary plug-ins for C++ development as well as remote development. Installing Eclipse and enabling it for C++ development differs substantially between operating systems:
Windows
It is non-trivial to set up an Eclipse C++ development environment under windows. It is not particularly hard, but it's an integration between Eclipse, a plug-in called CDT and GCC ported to windows. It would be futile to list the steps as of writing this tutorial, as the process changes slightly depending on the versions of the named software elements. Try googling "C/C++ development using Eclipse under Windows" and come back when you have this working properly.
Now, it is necessary to install two other plug-ins for our task:
- TM and RSE (Remote system Explorer)
- Eclipse C/C++ Remote Launch
As you've probably already noticed while installing CDT, one installs Eclipse plug-ins through Help->Install New Sofware.... The drop down list next to Work with lists some software sites, but the ones we need are probably not there. Click on the 'Available Software Sites' link just under the Add... button to get a list of software sites compatible with your version of eclipse. You need to add:
RSE - http://download.eclipse.org/dsdp/tm/updates/3.1 - for TM and RSE CDT - http://download.eclipse.org/tools/cdt/releases/galileo - for Eclipse C/C++ Remote Launch, under CDT Optional Features
Note that the above links and names might differ slightly depending on the version, but you're choosing from a list anyway.
Ubuntu
It is much easier to set up Eclipse for C++ development under Ubuntu. Simply type
sudo apt-get install eclipse
At the command line to install eclipse. This will probably be vanilla Eclipse that won't support plug-ins. So, if you have problems installing the plug-ins later, type
sudo apt-get install eclipse-pde
To prepare eclipse for the plug-ins. Eclipse plug-ins are installed through Help->Install New Sofware.... The drop down list next to Work with lists some software sites. We will install CDT (C/C++ Development Tools) from Galileo Update Site - http://download.eclipse.org/releases/galileo/. This is for Eclipse Galileo of course, it will look slightly different on different versions. Select that site, and under Programming Languages mark Eclipse C/C++ Development Tools. Finish the installation by clicking Next and so on...
At this point, you should be able to create, compile, run and debug local C/C++ projects as long as you have gcc and make installed. If not, try
sudo apt-get install gcc make
Now, it is necessary to install two other plug-ins for our task:
- TM and RSE (Remote system Explorer)
- Eclipse C/C++ Remote Launch
Go to Help->Install New Sofware... again, but the software sites we need are probably not in your drop down list. Click on the 'Available Software Sites' link just under the Add... button to get a list of software sites compatible with your version of eclipse. You need to add:
RSE - http://download.eclipse.org/dsdp/tm/updates/3.1 - for TM and RSE CDT - http://download.eclipse.org/tools/cdt/releases/galileo - for Eclipse C/C++ Remote Launch, under CDT Optional Features
Note that the above links and names might differ slightly depending on the version, but you're choosing from a list anyway.
Mount the Mobotware directory
There are many ways to mount your home folder or directly the Mobotware directory residing on Kalman to your local file system. To avoid most complications, we will do it using sshfs here. In order to do so, we need to be able to connect to kalman.iau.dtu.dk using ssh.
If you are outside the automation network (such as on DTU wireless), you will have to tunnel to kalman through DTU G-Bar for instance. How to do this depends on your operating system. Note that, you do not need the tunneling step if you can already connect to kalman.iau.dtu.dk
Tunneling to Kalman
Windows
[www.putty.org putty] is a great and free ssh client for windows and it supports tunneling.
Ubuntu
In order to tunnel to kalman through G-Bar, you will simply need to type the following in a new terminal:
ssh -L10000:kalman.iau.dtu.dk:22 {gbarusername}@login.gbar.dtu.dk
Don't forget to substitute {username} with your own.
Mounting a Directory from Kalman on Your File System
Windows
Dokan can be used to mount an sshfs drive on windows. Download and install the Dokan Library and then download and run the Dokan SSHFS
Ubuntu
If you do not already have it installed, type the following to install sshfs
sudo apt-get install sshfs
Now create the folder where you would like to mount.
mkdir mountPoint
If you have direct access to Kalman you can type the following to mount a drive from Kalman:
sshfs {kalmanusername}@kalman.iau.dtu.dk:projectpath mountPoint
If you created a tunnel as described before, then you need to go through that tunnel
sshfs -p 10000 {kalmanusername}@localhost:projectpath mountPoint
At this point, you should see the contents of the projectpath at the mountPoint. You can verify this with:
ls mountPoint
Set up an Eclipse Remote Development Project
Go to File->New->Project.... Under C/C++, choose C++ Project and click Next. Give your project a name, and uncheck the Use default location checkbox. This will enable the Location field. Choose the mounted base folder of your project inside the mountPoint. In the Project Type field, choose Makefile project->Empty Project. Choose whichever GCC option in the Toolchains field. Create the project by pressing Finish.
Your project should now be visible in the Project Explorer view. At this point, you should be edit your source files, perform content assist on them and use many other Eclipse features, except for debugging on the robot and building on the server. If that is enough for you, you can stop here.
Next, we need to define the connections to nyquist (or jensen) for compiling the project and to the SMR of your choice for running and debugging the executables on.
Again, if you're not on the automation network, you will need to tunnel some ports. In order to be able to ssh to these, you will have to forward, say, 10001 to nyquist port 22 and 10002 to SMRX (replace X!!!) port 22. You will also need to tunnel to an extra port on the SMR for the remote GDB server to communicate with your local GDB client. Eclipse CDT uses the port 2345 by default, so let's just forward that.
Windows
Add the new tunnels to the session settings...
Ubuntu
ssh -L10001:nyquist.iau.dtu.dk:22 -L10002:smrx.iau.dtu.dk:22 -L2345:smrx.iau.dtu.dk:2345 {gbarusername}@login.gbar.dtu.dk
We now need to define the connection to SMRX in eclipse. Go to File->New->Other.... Under Remote System Explorer choose Connection and press Next. Choose SSH Only and press Next.
If you have direct access to SMRX (you are in the automation network):
- You can simply give smrx.iau.dtu.dk as the host name, so write smrx in the Host name and the Connection name fields and press Finish.
If you are tunneling to the SMR instead:
- You need to write localhost in the Host name' field and smrx in the Connection name field. In this case, you also need to specify that we are connecting through port 10002. To do that, go to Window->Show View->Other... and pick Remote Systems Details under Remote Systems. As a result, the Remote System Details view opens somewhere. Double-click on the smrx connection, and change all the ports (The 3rd column of the table) to 10002.
Now right click on your project in the Project Explorer view and pick Properties. Pick C/C++ Build and under Builder Settings uncheck the Use default build command checkbox. In the Build command field, type:
If you have direct access to SMRX:
ssh {kalmanusername}@nyquist.iau.dtu.dk "cd projectPath; make"
else:
ssh -p 10001 {kalmanusername}@localhost "cd projectPath; make"
Do not forget to replace {kalmanusername} and projectPath. Under Behavior tab, you might want to uncheck the Build (Incremental build) and Clean checkboxes to avoid unnecessary, lengthy builds all the time. Don't forget to build your project when it's necessary though. Press OK to finish.
In order to set up the debugging; right click on your project in the Project Explorer view and pick Debug As->Debug Configurations.... Right click on C/C++ Remote Application and pick New. Under the Main tab, choose smrx in the connection dropdown list. Click Browse next to the C/C++ Application field, and choose the executable you would like to debug on the SMR. Then enter the absolute path of that executable in the SMRX file system. You can also find that file by using the Browse button and picking the smrx connection. If you would like to run the executable in a special folder (f.x. where you have your .ini files...), in the Commands to execute before application field, type:
cd workingDirectory
workingDirectory being obviously the directory that you want to run your executable in. Finally, check the Skip download to target path checkbox. If you press Debug now, you will start debugging! (given that you have built your project and SMRX is running etc...)