12/02/2018 11:18am
Indeed! [LINK]
08/02/2018 4:07pm
The advert video for @iros_2018 is really good! I wish robots really served coffee at the conference [LINK]
07/02/2018 10:10am
RT @NatureEcoEvo: Cockroach and termite genomes reveal molecular basis of termite eusociality [LINK] [LINK]
06/02/2018 1:29pm
Robotics for Nuclear Environments - a really cool website for a really cool project that I am currently a part of a… [LINK]
02/02/2018 8:09pm
RT @RIFBristol: Everything you need to know about Bristol’s sci-tech scene [LINK] via @siliconrepublic [LINK]

[Developing in NXC using XCode]

Date: Jan 2012
Tags: robotics :: Mindstorms

There are a number of tools and IDEs you can use to create programs for the NXT Mindstorms. I would argue that the best tool should support most operating systems and involve C or a similar language (there is a limited memory on the brick so good memory management becomes an issue). While Robot-C is probably the best choice in terms of integration with the brick, it is a commercial tool and it only work on Windows so far. After comparing a number of options, I chose NXC as a pretty good alternative to Robot-C. It supports a lot of things like sensor and motor management, playing of sounds, basic 2D and 3D graphics, etc. Most importantly, you can compile your programs from the command line or from XCode. This tutorial assumes knowledge of XCode 4 and of C. The NXC programming guide is a good reference.

Setting up an XCode project

This blog by Mark C summarises the main points of NXC XCode development and provides a downloadable Hello World program. Rather than repeating what was said before, I would like to give a step-by-step guide to creating a project from scratch. The reason for that is that even if you download somebody else's HelloWorld program, XCode does not allow you to easily change the project name so it is always easier to create a new project.

1. Download

The first step is to download the latest nxc compiler and nxt firmware. Put the compiler on your disk, e.g. to the /Developer folder. Also, you might find the NeXT Tools useful.

Please read the tutorial Setting up NXC Development on a Mac if you are not sure about this step.

2. Create project

In XCode, choose 'Create new project' and select 'External Build System' under Mac OS X -> Other. This will take care of some basic build and target setup. In this example, we name our project 'MyProject'.

Creating a new XCode project step 1

Creating a new XCode project step 2


Hi Felix,

wow looks cool! Finally something specifically for NXC. And it's nice they include the latest compiler as well. Thanks a lot for sharing and have nice holidays too!

Hi Lenka!
It's me again. I more or less found a more specific IDE for mac! :D
With this bundle for Textmate you can have proper syntax highlighting and compile and download to the brick using cmd+R. It's great!
cheers and merry x-mas.
Sorry, I must have misunderstood you then. I thought you wanted to have different targets for different build settings, but with the same source. Your solution to the problem you mention is ok then.

Also thanks for the note about bluetooth - I am using USB so haven't encountered the problem yet.

Lenka, I think this is not enough. Think a Project "Tribot" where you have 2 bots, one called Tribot.nxc, the other Second.nxc. In your case PROGRAM=Tribot, and it builds Tribot.nxc. If you add a target "Second" it will not build(compile) the other source.

You can't simply add new source files for new robots in $(SOURCE) and compile them as you need them.

In order to do so, you would need to change the makefile to produce $(TARGET_NAME) executable from $(TARGET_NAME) source.

The sources location is just relative to the makefile and has afaik no problem in you change $(PROGRAM) to $(TARGET_NAME).

At least this is the regular setup I am using all the time to create different robots from different nxc sources in the same XCode Project (fired up by different XCode targets)

On the options side you are right... one should use -d. I just had issues with downloading over Bluetooth with nbc -d.... so I switched to nxtcom with worked for me perfectly.

Hi Shinfane and thanks for your comments. There a couple of things:

1. Starting from the original makefile, you cannot just change the value of program to $(TARGET_NAME) as PROGRAM is also used to access the source files. Therefore, you should leave program as it is but you can change the following in order for your executable name to be based on your target name:
$(NXC) -O=../$(BUILD)/$(TARGET_NAME).rxe \

I have changed the instructions on the top based on this.

2. I'm not sure about the advantage of using nxtcom. The compiler itself (nbc) downloads for you if you use the -d option. I see what you mean about the option of not deploying to the brick though, it which case I would suggest defining the OPTIONS on the top without the -d parameter and then having your if statement changing the OPTIONS:
ifeq ($(CONFIGURATION), Debug)
OPTIONS=-Z2 -I=../$(SOURCE)/ -EF -d

{Please enable JavaScript in order to post comments}

[You might also be intested in...]

NXC UserInteraction Library
The User Interaction (UIn) Library helps you create standard user interfaces (multi-line aligned texts, buttons, menus, etc.) and capture user actions on the NXT brick. The library works with the intelligent brick buttons and keeps all your sensor ports free for your program to use.
Setting up NXC Development on a Mac
This tutorial provides a step-by-step guide for setting up your Mac or Linux machine and your NXT brick for development with NXC. We will use the enhanced NXC firmware in order to enable extended functions for development.
ShooterBot spins around, looking for close targets to shoot at. Its proximity sensor starts firing signals when an object gets as close as about 20cm, at which point the robot gives a warning by showing blue instead of green light. The light turns red after about 2 seconds provided that the object does not move away and the robot shoots a ball at it.
Adaptive Robot Controller
A robot neural controller where obstacle-avoidance and random-walk neurons observe level of their irritation and randomly reconfigure their connections to motors when the irritation reaches a specified threshold is presented and tested.
Robot Flocking: Sensors and Control
This paper discusses various kinds of robot sensory input, approaches to motor control and ways they could be used for flocking. Focus is put on vision and Gibsonian optic flow that could be utilised by robots with advanced behaviour.
V-REP, Gazebo or ARGoS? A robot simulators comparison
Let’s have a look at three commonly used open-source simulators for robotics: V-REP, Gazebo and ARGoS, to find out which one suits your project the best.