If the ultrasonic cannot echo-locate the objects because they're too small, even with the sensor suspended very close to the floor, I suggest using a very sensitive feeler out front. It can be sticking forward like a jousting lance, and your robot can swivel back & forth while traveling to scan.
The trick to making it very sensitive is to:
(1) make it ...
The most basic solution would be to store the character read by fgetc, for example, instead of:
char val = fgetc(handle);
This way if the isspacecall returns false you will still have the latest character in the val variable.
I'd also suggest you look into the switch statement instead of using ...
Looking at your code, there are a few things that you need to consider.
Firstly, you have a while (true) loop which will run infinitely.
The first thing you have after the loop is OnFwd(...) which will turn motors A and B on.
Together, this means that whatever you do next, when then you will run the code again, turning on motors A and B.
The next thing to ...
To understand how to use the data, it help to understand how the color sensor works. Let's take a step back for a minute and have a look. The sensitive electrical component here is just a photodiode or phototransistor that lets us measure light intensity.
If we turn all of the LEDs off we are just measuring ambient light. If we turn on just one of the LEDs ...
Yes, it is possible. Have a look at the "Comm module functions" section of the NXT help file. For example, since the touch sensor status is a boolean value, you could use the SendRemoteBool and ReceiveRemoteBool functions. You can communicate wirelessly using the Bluetooth functions (BT*) or you can have a wired connection using RS485 by connecting input ...
NXC creates bytecode for the standard (or NXC upgraded) NXT virtual machine. The idea of this virtual machine is to create an abstraction layer to prevent malicious low level calls such as accessing memory registers on the processor.
So, without a low level compiler, such access would not be possible.
By "smoother limit", if you mean "when it gets closer to the limit, it will softly land there by slowing down" then:
I recommend using PID control where the response (how fast the motor is moving to the limit) is controlled proportional to the error (how far away from the limit you are).
Wikipedia has a good intro to PID control: http://en.wikipedia.org/...
Maybe you should look into using a multiplexer to add additional sensors to an NXT brick.
The Hitechnic Sensor Multiplexer lets you connect 4 sensors using only 1 of the NXT connection.
The same thing can be done with motors. For example using the Mindsensors NXTMMX, you can add 2 additional motors per multiplexer (even better, if you daisy-chain the ...
PosRegSetAngle should set the position of the motor relative to the position the motor was in when regulation was enabled. In what way didn't it work when you tried this?
It sounds like you may be asking how to wait for the rotation to finish. I'm not sure if there is a built-in way to do this in NXC or not, but I think that something along these lines ...
Not sure what language you are using, or calls you are making before this, but:
float var_Min = var_R; if (var_G > var_Min) var_Min = var_G; if (var_B > var_Min) var_Min = var_B;
Should be (note the use of < rather than >)
float var_Min = var_R; if (var_G < var_Min) var_Min = var_G; if (var_B < var_Min) var_Min = var_B;
Your posted code is ...
According to the docs (emphasis added):
This function requires the enhanced NBC/NXC firmware version 1.31+
Make sure you are using the enhanced firmware provided with NXC and not the official firmware from LEGO.
This application does seem to be pushing the limits of the official software provided by LEGO. If you are interested in C/C++ (or any other programming language), check out http://www.ev3dev.org.
I like to say that ev3dev is not firmware since it runs from a microSD card and is not loaded into the flash memory on the EV3. Nevertheless, it is an alternate ...
I've had great success with Bricx Command Center or BricxCC (as mentioned in this post) on my NXT using NXC (which is easy to pick-up when you already have a C/C++ foundation like you've mentioned).
Installation, using the supplied drivers and connecting via USB is a breeze :)
Hope this helps!
I like your username. I'm not exactly good at NXC either, but I'm experienced in C and Java. So here's some pseudocode that should get the job done. This will rotate the scanning motor 180 degrees, while remembering the closest object it's seen, and then rotating that motor back to point towards the closest object. You will need to change the functions to ...
In my experience, most 3rd-party firmware can be flashed to the NXT brick using the standard NXT-G software "Firmware Update Tool." As others have mentioned, BricxCC with NXC is also a great option.
And if you're having trouble with the Python implementation, it's definitely worth checking out LeJOS (Java for Mindstorms). While Java may not be the usual ...
I don't believe that a constant or macro is available in NXC for positive infinity. C99 defines INFINITY in math.h, but the math module in NXC does not appear to include this.
NXC uses IEEE 754 floating point, so something like this should give you the raw value of infinity cast to a float:
int raw_infinity = 0x7f800000;
const float INFINITY = *(float*)&...
I had the exact same problem when I built the tripod. This program is written in BrickCC, instead of the standard NXT-G. The way to solve this is to download and install the compiler for brickCC, which can be found by browsing the tripod section on robotsquare here.
Most probably the problem is that the array is declared, but not initialized. The program does not know how much memory to allocate for this specific array and so there is no allocated storage in RAM for this array.
To solve this, try initializing your array. You can either provide the starting dimensions during declaration, like in the last example here: ...
Since you are trying to solve a Rubik's cube, check out the source code for the MindCuber. The solution there is that the values are not actually converted into colors. Rather the raw values are converted to HSV and then sorted by hue. The actual value does not matter, just how close it is to the other values.
The Mindcuber also has a white calibration. ...
Control loops. The builtin RotateMotor commands are very imprecise. Have a look at this file for a nice library that makes skid steer vehicles turn very precisely:
You'll need to adjust the constants at the top of the file.
This depends on the exact configuration of your robot, including but not limited to the distance between the wheels (if it's a differential drive robot), the diameters of the wheels, the gearing (if any is used) between the motors and the wheels.
A simple solution would be to experiment with various parameters and making corrections based on the direction ...
NXC compiles to machine code that runs in a virtual machine running on the NXT. The EV3 has a completely different virtual machine that is not compatible. So, of course programs compiled for the NXT will not run on the EV3.
The developer of NXC and BrixCC started working on support for the EV3 when it first came out, but has not been actively working on it ...