To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 26693
26692  |  26694
Subject: 
Re: Drive types
Newsgroups: 
lugnet.robotics
Date: 
Mon, 8 Jan 2007 20:29:35 GMT
Viewed: 
3029 times
  
In lugnet.robotics, Jonathan Knudsen wrote:
Also, I'm looking for a lightweight programming alternative for OS X,
something like NQC. Any suggestions? I've done a little digging but
come back empty-handed.

NXC is something like NQC and it is available for Windows, Mac OS X, and Linux
platforms.  While NXC is not yet complete, it is very functional with a large
API for the NXT.

Not eXactly C (NXC) is currently available in the form of NBC beta 20.  If you
download the latest NBC beta and the latest test release of BricxCC then you can
easily write programs in NXC and compile and download them to your NXT brick.
On a non-Windows platform you currently need an external tool to download
compiled executables to the NXT.

The NXC language currently supports the following programming constructs:

if/else, while, do-while, repeat, for, goto, until, and asm {}

break and continue are both supported within looping constructs.  return may be
used to exit a subroutine at any point, optionally returning a value to the
calling routine.

I hope to have a "switch" construct working soon.

The NXC language supports global variables, local variables (which must be
declared prior to subroutine/task code), tasks with no parameters, and
subroutines with parameters and return values.  Currently supported variable
types are:

int, short, long, byte, char, bool, unsigned short, unsigned long, unsigned int,
mutex, string, and arrays of all these types except mutex.

Variables may be initialized at the point of declaration using constants or
constant expressions.  Support for struct declarations and variables of type
struct is coming soon.  Support for typdefs is coming soon.

NXC supports the following standard C (and NQC) operators:

+, -, *, /, %,  & (bitwise and), | (bitwise or), ^ (bitwise xor), ! (logical
not), ++ (post increment), -- (post decrement), <, <=, >, >=, ==, !=, =, *=, /=,
%=, +=, -=, &=, |=, ^=, &&, ||, <<, >>, <<=, >>=, ||=, and +-=.

The ?: operator is not currently supported but I hope to add it soon.

Here's the current list of API functions:

Acquire(mutex);
Release(mutex);
Precedes(task1, task2, ..., taskn);
Follows(task1, task2, ..., taskn);

val = ButtonCount(btn, reset);
val = ButtonPressed(btn, reset);
ReadButtonEx(btn, reset, pressed, count);

ClearSensor(port);
ResetSensor(port);
val = Sensor(port);
val = SensorUS(port);
SetSensorLight(port);
SetSensorSound(port);
SetSensorTouch(port);
SetSensorLowspeed(port);
SetSensorType(port, type);
SetSensorMode(port, mode);
SetInput(port, field, value);
val = GetInput(port, field);
val = SensorType(p);
val = SensorMode(p);
val = SensorRaw(p);
val = SensorNormalized(p);
val = SensorScaled(p);
val = SensorInvalid(p);


val = FirstTick();
val = CurrentTick();
Wait(ms);
ResetSleepTimer();

val = IOMA(num);
val = FreeMemory();
val = BatteryLevel();
PowerDown();
RebootInFirmwareMode();


NumOut(x, y, cls, number);
TextOut(x, y, cls, string);
GraphicOut(x, y, filename, cls);
CircleOut(x, y, radius, cls);
LineOut(x1, y1, x2, y2, cls);
PointOut(x, y, cls);
RectOut(x, y, width, height, cls);
ResetScreen();

Float(ports);
Off(ports);
OnFwd(ports, power);
OnRev(ports, power);
OnFwdReg(ports, power, regmode);
OnRevReg(ports, power, regmode);
OnFwdSync(ports, power, turnpct);
OnRevSync(ports, power, turnpct);
RotateMotor(ports, power, angle);
RotateMotorEx(ports, power, angle, turnpct, sync);

SetOutput(ports, field, value);
val = GetOutput(port, field);
val = MotorMode(p);
val = MotorPower(p);
val = MotorActualSpeed(p);
val = MotorTachoCount(p);
val = MotorTachoLimit(p);
val = MotorRunState(p);
val = MotorTurnRatio(p);
val = MotorRegulation(p);
val = MotorOverload(p);
val = MotorRegPValue(p);
val = MotorRegIValue(p);
val = MotorRegDValue(p);
val = MotorBlockTachoCount(p);
val = MotorRotationCount(p);
ResetMotor(ports);


PlayFile(filename);
PlayFileEx(filename, volume, loop);
PlayTone(frequency, duration);
PlayToneEx(frequency, duration, volume, loop);
val = SoundFlags()
val = SoundState()
StopSound();

val = Random(); // signed word value
val = Random(max); // unsigned word value

ExitTo(taskname);
Stop(bvalue);

val = abs(n);
val = sign(n);

val = StrToNum(str);
val = StrLen(str);
val = StrIndex(str, idx);

str = NumToStr(num);
str = StrCat(str1, str2, ..., strN);
str = SubStr(string, idx, len);
str = StrReplace(string, idx, strnew);
str = Flatten(num);

ByteArrayToStr(a, s);
StrToByteArray(s, a);
num = ArrayLen(a);
ArrayInit(a, val, cnt);

GetLSInputBuffer(p, offset, cnt, data);
GetLSOutputBuffer(p, offset, cnt, data);
GetDisplayNormal(x, line, cnt, data);
GetDisplayPopup(x, line, cnt, data);
GetBTInputBuffer(offset, cnt, data);
GetBTOutputBuffer(offset, cnt, data);
GetHSInputBuffer(offset, cnt, data);
GetHSOutputBuffer(offset, cnt, data);
GetUSBInputBuffer(offset, cnt, data);
GetUSBOutputBuffer(offset, cnt, data);
GetUSBPollBuffer(offset, cnt, data);

str = BTDeviceName(p);
str = BTConnectionName(p);
str = BTConnectionPinCode(p);
str = BrickDataName();

GetBTDeviceAddress(p, data);
GetBTConnectionAddress(p, data);
GetBrickDataAddress(data);

val = SoundFrequency();
val = SoundDuration();
val = SoundSampleRate();
val = SoundMode();
val = SoundVolume();

val = ButtonPressCount(b);
val = ButtonLongPressCount(b);
val = ButtonShortReleaseCount(b);
val = ButtonLongReleaseCount(b);
val = ButtonReleaseCount(b);
val = ButtonState(b);

val = CommandFlags();
val = UIState();
val = UIButton();
val = VMRunState();
val = BatteryState();
val = BluetoothState();
val = UsbState();
val = SleepTimeout();
val = SleepTimer();
val = RechargeableBattery();
val = Volume();
val = OnBrickProgramPointer();

val = CustomSensorZeroOffset(p);
val = CustomSensorPercentFullScale(p);
val = CustomSensorActiveStatus(p);
val = SensorBoolean(p);
val = SensorDigiPinsDirection(p);
val = SensorDigiPinsStatus(p);
val = SensorDigiPinsOutputLevel(p);

val = MotorPwnFreq();

val = LSInputBufferInPtr(p);
val = LSInputBufferOutPtr(p);
val = LSInputBufferBytesToRx(p);
val = LSOutputBufferInPtr(p);
val = LSOutputBufferOutPtr(p);
val = LSOutputBufferBytesToRx(p);
val = LSMode(p);
val = LSChannelState(p);
val = LSErrorType(p);
val = LSState();
val = LSSpeed();

val = DisplayEraseMask();
val = DisplayUpdateMask();
val = DisplayDisplay();
val = DisplayFlags();
val = DisplayTextLinesCenterFlags();

val = BTDeviceClass(p);
val = BTDeviceStatus(p);
val = BTConnectionClass(p);
val = BTConnectionHandleNum(p);
val = BTConnectionStreamStatus(p);
val = BTConnectionLinkQuality(p);
val = BrickDataBluecoreVersion();
val = BrickDataBtStateStatus();
val = BrickDataBtHardwareStatus();
val = BrickDataTimeoutValue();
val = BTInputBufferInPtr();
val = BTInputBufferOutPtr();
val = BTOutputBufferInPtr();
val = BTOutputBufferOutPtr();
val = HSInputBufferInPtr();
val = HSInputBufferOutPtr();
val = HSOutputBufferInPtr();
val = HSOutputBufferOutPtr();
val = USBInputBufferInPtr();
val = USBInputBufferOutPtr();
val = USBOutputBufferInPtr();
val = USBOutputBufferOutPtr();
val = USBPollBufferInPtr();
val = USBPollBufferOutPtr();
val = BTDeviceCount();
val = BTDeviceNameCount();
val = HSFlags();
val = HSSpeed();
val = HSState();
val = USBState();

SetSoundFrequency(n);
SetSoundDuration(n);
SetSoundSampleRate(n);
SetSoundFlags(n);
SetSoundState(n);
SetSoundMode(n);
SetSoundVolume(n);

SetButtonPressCount(b, n);
SetButtonLongPressCount(b, n);
SetButtonShortReleaseCount(b, n);
SetButtonLongReleaseCount(b, n);
SetButtonReleaseCount(b, n);
SetButtonState(b, n);

SetCommandFlags(n);
SetUIState(n);
SetUIButton(n);
SetVMRunState(n);
SetBatteryState(n);
SetBluetoothState(n);
SetUsbState(n);
SetSleepTimeout(n);
SetSleepTimer(n);
SetVolume(n);
SetOnBrickProgramPointer(n);
ForceOff(n);

SetCustomSensorZeroOffset(p, n);
SetCustomSensorPercentFullScale(p, n);
SetCustomSensorActiveStatus(p, n);
SetSensorBoolean(p, n);
SetSensorDigiPinsDirection(p, n);
SetSensorDigiPinsStatus(p, n);
SetSensorDigiPinsOutputLevel(p, n);

SetMotorPwnFreq(n);

SetLSInputBuffer(p, offset, cnt, data);
SetLSInputBufferInPtr(p, n);
SetLSInputBufferOutPtr(p, n);
SetLSInputBufferBytesToRx(p, n);
SetLSOutputBuffer(p, offset, cnt, data);
SetLSOutputBufferInPtr(p, n);
SetLSOutputBufferOutPtr(p, n);
SetLSOutputBufferBytesToRx(p, n);
SetLSMode(p, n);
SetLSChannelState(p, n);
SetLSErrorType(p, n);
SetLSState(n);
SetLSSpeed(n);

SetDisplayEraseMask(n);
SetDisplayUpdateMask(n);
SetDisplayDisplay(n);
SetDisplayFlags(n);
SetDisplayTextLinesCenterFlags(n);
SetDisplayNormal(x, line, cnt, data);
SetDisplayPopup(x, line, cnt, data);

SetBTDeviceName(p, str);
SetBTDeviceAddress(p, addr);
SetBTConnectionName(p, str);
SetBTConnectionPinCode(p, code);
SetBTConnectionAddress(p, addr);
SetBrickDataName(str);
SetBrickDataAddress(p, addr);
SetBTDeviceClass(p, n);
SetBTDeviceStatus(p, n);
SetBTConnectionClass(p, n);
SetBTConnectionHandleNum(p, n);
SetBTConnectionStreamStatus(p, n);
SetBTConnectionLinkQuality(p, n);
SetBrickDataBluecoreVersion(n);
SetBrickDataBtStateStatus(n);
SetBrickDataBtHardwareStatus(n);
SetBrickDataTimeoutValue(n);
SetBTInputBuffer(offset, cnt, data);
SetBTInputBufferInPtr(n);
SetBTInputBufferOutPtr(n);
SetBTOutputBuffer(offset, cnt, data);
SetBTOutputBufferInPtr(n);
SetBTOutputBufferOutPtr(n);
SetHSInputBuffer(offset, cnt, data);
SetHSInputBufferInPtr(n);
SetHSInputBufferOutPtr(n);
SetHSOutputBuffer(offset, cnt, data);
SetHSOutputBufferInPtr(n);
SetHSOutputBufferOutPtr(n);
SetUSBInputBuffer(offset, cnt, data);
SetUSBInputBufferInPtr(n);
SetUSBInputBufferOutPtr(n);
SetUSBOutputBuffer(offset, cnt, data);
SetUSBOutputBufferInPtr(n);
SetUSBOutputBufferOutPtr(n);
SetUSBPollBuffer(offset, cnt, data);
SetUSBPollBufferInPtr(n);
SetUSBPollBufferOutPtr(n);
SetBTDeviceCount(n);
SetBTDeviceNameCount(n);
SetHSFlags(n);
SetHSSpeed(n);
SetHSState(n);
SetUSBState(n);

val = CreateFile(fname, fsize, handle);
val = OpenFileAppend(fname, fsize, handle);
val = OpenFileRead(fname, fsize, handle);
val = CloseFile(handle);
val = ResolveHandle(fname, handle, writeable);
val = RenameFile(oldname, newname);
val = DeleteFile(fname);

val = SendMessage(queue, msg);
val = ReceiveMessage(queue, clear, msg);

val = LowspeedStatus(port, bready);
val = LowspeedWrite(port, retlen, buffer);
val = LowspeedRead(port, buflen, buffer);

val = BluetoothStatus(conn);
val = BluetoothWrite(conn, buffer);


You can find NXC at http://bricxcc.sourceforge.net/nxc/.

John Hansen



Message has 2 Replies:
  Re: Drive types
 
(...) Hello John, Could you comment a little the use of Precedes/Follows for task switching? I have trouble figuring when to use one or the other (or both?) Thanks in advance, Philo (18 years ago, 9-Jan-07, to lugnet.robotics)
  Re: Drive types
 
(...) Ok, I'll bite: which external tools work well on OS X and Linux? Thanks, -Tim (18 years ago, 9-Jan-07, to lugnet.robotics)

Message is in Reply To:
  Drive types
 
Hello, I'm just getting started with NXT and was wondering if anyone has successfully built a car-type robot. By this I mean a robot that uses one motor to drive the rear wheels and one motor to operate the front steering. The NXT kit does not (...) (18 years ago, 8-Jan-07, to lugnet.robotics)

14 Messages in This Thread:





Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR