Re: Incorporating my project into a robot car.
Bernhard Wymann <[email protected]>
| Newsgroups | gmane.games.torcs.general |
|---|---|
| Organization | wytec |
| Message-ID | <[email protected]> |
Hi Henry > In short my plan has been to produce my project in C# (a language I'm > more comfortable in than C++) and use COM to provide a bridge between > the two languages. I've developed a bridge class for C++ which does > successfully gets the basic bits of info I need across and everything > operates fine. The bit I've come slightly unstuck with (and would really > appreciate help with) is linking my bridge class into the berniw > tutorial robot. (Or any other suitable robot!) Ok, if I get it right it you just need to call you custom COM stuff from the robot. Depending on your requirements you have to decide somewhere between these 2 extreme cases: 1. The c++ robot acts only as "COM bridge" and all decisions are made in C#. 2. The robot is fully in C++ and just calls you specific learning algorithms via COM. 1 requires some work to bring all data you need through the COM interface, there you have to decide up to what level this is beneficial (tradeoff, as usual...). 2 should be very easy, but it might not fit your requirements (e.g. if your C# robot should be general and requires a clean interface/own datastructures to plug it into other simulations, so you need to map the data anyway). A comment to the COM interface: COM is not portable, maybe a TCP/UDP approach might be better (e.g. see this: http://cig.ws.dei.polimi.it/?page_id=134 and http://sourceforge.net/projects/cig/ and http://games.ws.dei.polimi.it/competitions/scr/. Beware, there could be another easy way (I did this in the past): - Compile your robot as "Managed C++ assembly", because it is a DLL and the interface to TORCS stays "as is" it does not matter for TORCS. Then you can access your C# assemblies more or less without a fuss, IIRC. To the technical stuff (to the COM idea): - I would recommend you to compile TORCS with VS2008, it should be easy to link you C++ robot to COM (I did something similar years ago in a commercial software project, IIRC it is pretty easy, so just use Google and MSDN documentation). > What I need to be able to do is to access the robot's steering angle, > the velocity, the position along the track (in a single dimensional > length if possible?) and the car's lap time. I would also need to access > and modify the robot's brake and acceleration levels and the damage This is all easy to find, just sneak into the robot tutorial, steering angle/velocity is chapter 1 I guess, the position along the track is car->_distFromStartLine (see also src/libs/raceengineclient/raceengine.cpp, around line 344 in TORCS 1.3.3). > meter for the car. (My project is looking into whether Reinforcement > Learning Methods would allow the car to adjust to wearing brakes, I'm > using the damage to keep track of the brake wear.) If you want to implement brake wear you should do it in the simulation engine (see src/modules/simu/simuv2). You should then add new fields to the car structures to keep track of it. > It might also be useful to know when the lap ends (however if I know how > far along the lap the car is, and the length of the track I can work > that out from those two bits of data). As above, sneak into src/libs/raceengineclient/raceengine.cpp. You should as well have a look into the FAQ here: http://torcs.sourceforge.net/index.php?name=Sections&op=viewarticle&artid=30#c6_1, 6.7 and 6.8 might be interesting for you. > Thanks in advance, > Henry You are welcome, let us know if this helped and how you solved it finally such that others can learn from it. Best regards Bernhard ------------------------------------------------------------------------------ For Developers, A Lot Can Happen In A Second. Boundary is the first to Know...and Tell You. Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! http://p.sf.net/sfu/Boundary-d2dvs2