C++ OOP Library for Programming the Lego NXT - c++

A while back, I got a LEGO Mindstorms NXT set for Christmas, and now I would like to program it in C++.
I have looked around, here and other places, and could not find a cross-platform, open source, OOP C++ library that "felt right", including lestat and nxtOSEK.
So, I have decided that unless I can find one I do like, then it would be a great learning experience for me to write my own library.
I have done a little research, and decided it would be easiest to communicate with it over bluetooth, rather than compiling my programs to the NXT machine code.
I would also like this to be done in OOP style, meaning the NXT brick, motors, sensors, etc would exist as objects.
So, my question is: what do I need to know before embarking on this? where can I get good references (besides here, and specific to the NXT)? What are other decent "basic" libraries* for things like Bluetooth communication?
*I am all for using boost and the STL, if necessary, by the way.
Alternatively, I believe in not reinventing the wheel if I don't have to, so if there is a decent C++ OOP bluetooth-communicating NXT library out there, let me know!

I've taken a look at doing this before.
Start looking here: http://bricxcc.sourceforge.net/
On this page you can download the source for it. What I ended up doing is compiling my C source code down to byte codes that the NXT brick can understand.
This allowed me to add some custom extensions to C though I did spend alot of time compiling C down to a compact enough form in byte codes that fit into the NXT's memory:)
If you want to use an existing C implementation then check out this chart: http://www.teamhassenplug.org/NXT/NXTSoftware.html
For a list of the NBC(Next Byte Codes) start with this page. I found it extremely helpful.
http://bricxcc.sourceforge.net/nbc/

I used this one, I don't know whether you have checked it out or not:
http://www.norgesgade14.dk/bluetoothlibrary.php
This library provides support for reading various sensor data over a bluetooth connection as well as support for controlling motors.
Moreover the library can be easily modified, and I found it extremely easy to reconfigure it.

I came across this thread last year, while working on a project using C++ to control a robot arm. I used 2 NXT bricks and 5 motors.
You can find the original NXT++ 0.6 library here:
http://nxtpp.clustur.com
https://sourceforge.net/projects/nxtpp/forums/
Unfortunately this site is not being updated.
I forked a new version NXT++ 0.7 with some fixes, and support for multiple bricks, via USB or Bluetooth:
https://github.com/dbworth/nxt-plus-plus
See the Readme file for details.
Another user, Piotr, has added support to NXT++ 0.6-2 for the HiTechnic sensor multiplexor and Lego color sensor:
http://wmii.uwm.edu.pl/~artem/downloads.html
Regards,
David.

Lets see the demonstration of possibilities of NXT++, the histogram filtering,
https://www.youtube.com/watch?v=PDYtjWgvsxg
it is based on the latest version supporting multiplexers,
from http://wmii.uwm.edu.pl/~artem and download section,

Related

Using a STM upsd3200 series mcu for the first time

I've received a dk 3200 kit recently. I know it's old but I would like to start using it to have more of a challenge than just arduino. It came with the board, an st flashlink FL-101B and some cables. I do not have the install disc, but I found the software for psd soft express online. It doesn't work with current windows 7 64bit. If I could use my arduino to program it, that would be great! Or maybe just do it through USB or the parallel ports? I've read that st provides a stm32 library used to help make code. If that works for my mcu, I'll use that.
Thanks
ST is a company that loves to re-organize their website and break links, but a data sheet for a part of what seems to be the same family as on your board is available from a toolchain vendor at:
http://www.keil.com/dd/docs/datashts/st/upsd321x_ds.pdf
On page 118 this seems to indicate that programs can be loaded using JTAG In System Configuration commands, which may be somewhat standardized though quick searching isn't producing a lot of leads. A reference is also made to ST's AN1153 which would be worth trying to locate a copy of, however it's not entirely clear if that will say anything about the programming, or if it only covers the additional two optional signals which have been added for hardware acceleration of the interface.
In theory, if you can find sufficient information about this device (looking at related devices may provide clues) then you should be able to craft a programming from an Arduino or anything else that can be adapted to twiddle bits at the appropriate voltage/threshold levels.
In practice, you may be better off trying to find an old Windows XP box, or even trying to run that software on a virtual/emulated environment and trap the I/O access either to proxy or to figure out what it is doing and reverse engineer your own programmer.
But unless you have a large installed base of boards using these chips, or particular need some unusual feature of them (I thought I saw something about a built-in CPLD?) it's really not going to be worth the effort.

windows programming using template in c++

I am interested in writing simple windows-based programs for scientific calculations in c++. Is there a place I could find source code for a template that I could use? The window I would create would hardly ever vary -- it would be something similar to this (but simpler!):
http://www.lisisoft.com/imglisi/6/Science/73401version4xp.jpg
I am not a c++ programmer -- but I have created similar programs in visual basic (blush!). This is my way of learning c++ by working within a limited range of program design...mainly at first just changing the formulas and a few labels.
Can anyone help or point me in the right direction?
First off, there are a million things you need to know before you can just download some code from somewhere and try to work with it. My best advice would be to pick up an "Introduction to C++" book.
But, putting that aside, I will try to answer the question.
There are 2 main ways to make GUI apps in windows using C++:
Get a C++ GUI library, there is an extensive list here.
Work with the Windows API directly.
Once you have choosen either step 1 or 2, try to search for samples by searching the library name you have chosen followed by the word "samples" or "examples" (i.e, "WxWidgets Samples", "Qt examples" or "Windows API examples")
However, either way you choose, in order to make something like the example in your picture, I would estimate that it would take you at least 6 months (and thats if you program everyday).
For a windows C++ GUI library try reliable software library at www.relisoft.com. If you want to use native windows GUI programming you can also try using QT libraries.

Sound output through M-Audio ProFire 610

I got an assignment at work to create a system which will be able to direct sound to different output channels of our sound card. We are using M-Audio ProFire 610, which has 8 channel output and connects through FireWire. We are also using a Mac Mini as our host server and I'm gonna be working in Xcode.
This is the diagram of what I am building:
diagram http://img121.imageshack.us/img121/7865/diagramy.png
At first I thought that Java will be enough for this project, however later on I discovered that Java is not able to push sound to other than default output channels of the sound card so I decided to switch to C++. The problem is that I am a web developer and I don't have any experience in this language whatsoever - that is why I am looking for help from more experienced developers.
I found a Core Audio Primer for ios4 but not sure how much of it I can use for my project. I find it a bit confusing, too.
What steps should I take to complete this assignment? What frameworks should I use? Any code examples? I am looking for any help, hints, tips - well anything that will help me complete this project.
If you're just looking for audio pass-through, you might want to look at something that's already been built, like Jack which creates a software audio device that looks and works just like a real one (you can set it as default output for your app) and then allows you to route each channel anywhere you want (including to other applications).
If you want/need to make your own, definitely go with C++, for which there are many many tutorials (I learned from cplusplus.com). CoreAudio is the low-level C/C++ interface as Justin mentioned, but it's really hard to learn and use. A much simpler API is provided by PortAudio, for which I've worked a bit on the Mac implementation. Look at the tutorials there, make something similar for default input and output, and then to do the channel mapping use PaMacCore_SetupChannelMap, which is described here. You'll need to call it twice, once for the input stream and once for the output stream. Join the mailing list for PortAudio if you need more advice! Good luck!
the primary APIs are at CoreAudio/AudioHardware.h
most of the samples/supporting code provided by apple is in C++. however, the APIs are totally C (don't know if that helps you or not).
you'll want to access the Hardware Abstraction Layer (aka HAL), more details in this doc:
http://developer.apple.com/documentation/MusicAudio/Conceptual/CoreAudioOverview/CoreAudioOverview.pdf
for (a rather significant amount of) additional samples/usage, see $DEVELOPER_DIR/Extras/CoreAudio/

Modifying old Windows program for Mac OS X

This application was written for windows back in 1998,
I loved using this program, Now I want to learn how to make it
work on Mac, And maybe changing and adding functionality,
The problem is I don't know where to start, I Have studied C++ php, javascript, But don't really know how to read this code. or where to start.
Thanks for taking a look
http://github.com/klanestro/textCalc
From http://www.atomixbuttons.com/textcalc/
What is TextCalc?
TextCalc is a combination of an
expression calculator and a text
editor. Being both, it has several
advantages over conventional
calculators.
1) You can evaluate expressions like
9*4-2+95-12 just the way you write
them on paper.
2) You can put comments besides your
answer and expressions.
3) You can save, reload, edit and
print your results and expressions.
4) You do not need to write your
answer down on a paper before
computing another expression, as you
can leave the previous result in the
editor.
5) You can open an existing text data
file and perform calculations on it.
6) You can apply an expression to many
numbers at one go. For example, you
can change the list 1 2 3 4 5 to 2 4
6 8 10 by multiplying each number by
2.
7) You can sum, average, convert into
hex etc. a list of numbers easily.
The editor is capable of parsing
numbers and strings enclosed in double
quotes " ". Numbers will be colored
blue and strings will be colored red.
This makes it ideal for editing files
containing numeric data.
★✩
Based on the screenshots and info on the TextCalc site, I think this is best implemented as a Mac OS X service. You can assign a hot key to trigger your service in the System Preferences -> Keyboard -> Services.
It would actually be rather easy. You don't need to write the text editor portion, it will be available in all text areas in all apps. You will be handed the text the user has selected, and all you need to do is evaluate it. There's a built-in command line tool, bc, that you should be able to delegate this to.
There is a guide to implementing services. You will need to read through the Cocoa intro material to understand it. This is a good first project, though.
I don't think there's any reason to try to read the source of the original app in this case. You just need to know what you want the behavior to be.
Check out the Calculator example from the second chapter of Stroustrup's "The C++ Programming Language".
It looks like this application is written using MFC, which is quite Windows-centric. Translating this program to use a different API such as Cocoa would be a lot of work, and would require good familiarity with both MFC and Cocoa. Not to mention the work involved in translating the C++ to Objective-C, of course.
You may be better off running it as-is in a virtual machine such as VirtualBox, or under Wine. Unfortunately, the free version of Microsoft Visual C++ does not include MFC, so to modify this code you would have to either purchase a non-free version of MSVC, or translate the program to "bare bones" Win32, without using MFC.
The core part of this program (Expression Evaluation) has been taken from this smaller program written by Zoly Farkas.
So I would suggest the following:
Learn Objective C.
As an exercise, port Zoly Farkas' Expression Evaluation to Objective-C, to use as a library or on the command line.
Learn Cocoa.
As an exercise, create a graphical interface for your library using Cocoa. You don't need MFC.
Should be fun! :-)
I would not recommend to "port" such a old program using MFC which you cant use on a Mac anyway.
Rather i would recommend to create the skeleton of a new blank application and then to insert more or less large fragments from the old code. The skeleton may use whatever language is appropriate: C++, Objective-C, real Basic. But as the code to reuse is C++ its probably best to use C++.
If you decide to re-write it, I recommend RealBasic. It has many components that will help shorten the development cycle and you can compile the program for Windows, Mac and Linux.
Easy to learn and very productive platform.
Why not rewrite it in C# .NET and use Mono to compile it on the Mac? You can rewrite the GUI parts in Native Cocoa from c# using a wrapper. Depends on your program but this program doesn't sound like your going to sell it to the public so L+F issues are probably not an issue.
The code looks to be in C++. C++ is available on Macs.
The code relies on MFC, which if course is not available on OS X. So you'll need to pick a framework like WxWidgets, Qt, FLTK, etc. that's available on both the Mac and Windows. Then you need to translate from MFC to your new framework.
In the process you'll learn more about MFC than you intend to.

Open Source sound engine

When I started using SoundEngine (from CrashLanding and TouchFighter), I had read about a few people recommending not to use it, for it was, according to them, not stable enough. Still it was the only solution I knew of to play sounds with pitch and position control without learning C++ and OpenAL, so I ignored the warnings and went on with it.
But now I'm starting to worry. The 2.2 SDK introduced AVFoundation. Using both SoundEngine from CrashLanding (for sounds) and AVAudioPlayer (for music), I found out SoundEngine behaves strangely when the only existing AVAudioPlayer is released (all sounds stop until a new AVAudioPlayer is initiated). Around the same time as the 2.2 SDK came out, the CrashLanding sample code was mysteriously removed from the ADC site. I'm worried there are more bad surprises to come.
My question is, is anyone aware of an Open Source alternative to SoundEngine? Maybe even a C++ library that uses OpenAL?
Look at this library, but i don't know is this what you need.
The Kowalski project provides a data driven and portable sound engine that currently runs on iOS, OS X and Windows. The engine is released under the zlib license and provides positional audio, pitch control etc.
ObjectAL for iPhone
Clone it. Use it. Love it. Enjoy the freedom.
Why not just use AVFoundation? It's pretty simple to handle and nicely flexible - apart from if you need exact timing (says the Apple documentation - but I've been testing it fairly extensively and yet to find any significant practical issues) I don't see any reason for not leveraging it.
AVFoundation lacks sound placement. This makes me sad.
I’ve written a simple sound engine around OpenAL. There are no position controls (I didn’t need them), but they would be trivial to add if you find the rest to your liking. And there is also some experimental sound code in the Cocos2D engine. It has both pitch and position controls and looks quite usable.