There are a few things me and my team have been wondering about how C++ works on the kovan.
1) Is kovan.hpp auto-included or do we need to include it at the top of every program?
2) Is there a guide I can distribute to my team for how to use things like motors and sensors?
3) Would multi-file projects cause problems when sending and compiling?
4) Does it use C++11?
5) Is there much of a change from the standard or is it just a regular g++ compiler?
Thank you in advance for any help you might be able to give me and my team
1) Yes, it should be auto-included like kovan/kovan.h is in C.
2) Unfortunately, the only documentation for libkovan C++ is in the header files. They are usually pretty easy to follow, but they aren't as easy a guide. We are slowly working on correcting this, but it is low priority. The C++ APIs are generally more powerful and flexible than their C counterparts (libkovan is programmed in C++, the C part is just a wrapper.) Let me know if you have any questions. It's design is generally based on CBCJVM's API.
3) Right now yes. This is high priority to be fixed. (Next week or so).
4) Nope, sorry. See 5.
5) Right now it is completely standard g++. We'll probably switch to Clang/LLVM 3.0+ eventually (compilation speed concerns with g++), so I wouldn't use any *extremely specific* g++ features. Clang is good at being compatibile with gcc extensions like
__attribute__((constructor))
, however. This should enable C++11.Thanks,
Braden
Braden McDorman
Developer of the KIPR Link, KISS IDE, KIPR's 2D Simulator, and CBCJVM.
Reach me at bmcdorman(cat)kipr(dog)org where (cat)=@ and (dog)=. if you need assistance of any kind.
Thank you very much. I'll probably have a few questions on the headers now. That's what I've been using so far, but I'm the only person on my team comfortable reading through them, so I'll probably just write a simple guide for them.
1) What functions are used for measuring millisecond time or is clock()*1000/CLOCKS_PER_SEC what I should use?
2) For motors is there anyway to have the abbreviated functions like bmd for the Motor class? I wasn't able to find anything like that in the headers I looked at.
3) Is there a guide to threading using the kovan libraries or would it be best to use pthreads?
I'll probably have more next week once we actually start programming the new robot.
1. seconds() * 1000.0 will give you submillisecond precision.
2. I wasn't planning on it. Verbosity is a good thing in a lot of cases. I'd recommend just deriving your own from mine if you need bmd().
3. The C++ threading in libkovan is based on pthreads. I'll post a guide soon. pthreads will be usable in a user program starting 1.6.
Braden McDorman
Developer of the KIPR Link, KISS IDE, KIPR's 2D Simulator, and CBCJVM.
Reach me at bmcdorman(cat)kipr(dog)org where (cat)=@ and (dog)=. if you need assistance of any kind.
Thanks seconds() is a standard function in libkovan isn't it?
Thanks I'm writing, with some help, some wrapper classes called CBC and Create. I'll probably include them in there just because many people on my team are used to it from KISS-C.
Yeah, seconds() is ours. Awesome!
Also, just to clarify my statement on bmd, we do have the function but it isn't a contraction. It's Motor::blockMotorDone(). Sorry, I thought you wanted a contracted version :P
Braden McDorman
Developer of the KIPR Link, KISS IDE, KIPR's 2D Simulator, and CBCJVM.
Reach me at bmcdorman(cat)kipr(dog)org where (cat)=@ and (dog)=. if you need assistance of any kind.
That was what I meant was that I wanted a contracted version. I am having some problems compiling with KISS 4.0.4 targeting the simulator. It is telling me that Motor is not defined. Is it just missing the header or is Motor in some namespace I am not aware of?
That's interesting. What happens if you manually include <kovan/motor.hpp> ?
Braden McDorman
Developer of the KIPR Link, KISS IDE, KIPR's 2D Simulator, and CBCJVM.
Reach me at bmcdorman(cat)kipr(dog)org where (cat)=@ and (dog)=. if you need assistance of any kind.
It tells me that no such file exists...
Maybe there was a problem with my installation. What should I do to check that?
I am kind of scared hearing back from my team after the Texas workshop. They told me they were warned against using C++ because there were some problems with it? Is this just seem people not quite understanding the transition or is there something I should look out for?
Finally I was looking into OpenCV(I can't believe I've never used this before it looks amazingly useful). Would VideoCapture cap(0); be good for opening the camera for getting frames? If so does imshow work and how do I create a window for that? Is there a guide for using it on the kovan?
EDIT: http://pastebin.com/YZ2zS8T8 is my code if its any help
Ah. It appears it should be motors.hpp, not motor.hpp. My fault for not knowing the header name :P
All of the libkovan headers should be under ks2/prefix/usr/include/kovan. That directory (/usr/include) is accessible from your program.
The only issue with C++ is that it's undocumented right now. Did Matthew say that? I should get everyone in the office on the same page (we are undergoing revisions extremely fast.)
Yeah, that's pretty much how our camera stuff works. Alternatively, you may want to use:
#include <kovan/camera.hpp>
...
Camera::Device camera;
camera.open();
// Already opened, no need to do anything else.
cv::VideoCapture *cap = camera.videoCapture();
...
camera.close();
That way you can use our camera stuff and use OpenCV directly. I don't know if user programs are currently linking against OpenCV, so you might get errors when compiling an OpenCV program. I'll make sure that's kinked out in the next release. In the mean time I'd recommend using OpenCV in conjunction with a webcam. imshow (and all highgui functions) should work.
Thanks.
Braden McDorman
Developer of the KIPR Link, KISS IDE, KIPR's 2D Simulator, and CBCJVM.
Reach me at bmcdorman(cat)kipr(dog)org where (cat)=@ and (dog)=. if you need assistance of any kind.
I thought it was motors at first so I had tried that and it failed too. Any other ideas?
As long as C++ works I'm fine with getting my team to use it. I personally think it is easier to use than C for lots of things.
EDIT: My team has been told that KIPR would prefer C to be used instead. Is that true? My team is really against using C++ because of that