NXTCam image capture

Post your NXJ projects, project ideas, etc here!

Moderators: roger, 99jonathan, imaqine

Re: NXTCam image capture

Postby gloomyandy » Tue Jan 15, 2013 10:56 am

Sorry it is a long time since I did any work on that and the code that you are looking at is pretty old. I'm not sure if I even have the source around any more. If I get chance I will try and dig it out but I'm pretty busy at the moment. I certainly am not in a position to help you debug any problems you may hit with the firmware, or with anything else connected with this project. I assume you also understand that to use the firmware you have been looking at you will need to update the PIC code on the NXTCam using the generic PIC firmware from Mindsensors, have you done this yet?
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: NXTCam image capture

Postby robotnik » Tue Jan 15, 2013 11:40 am

Hi, thanks for your answer.

I updated with the generic firmware (just to check how it goes) before trying with something "stronger", the point is that I'm trying to understand how you send and receive the commands (i guess with lejos.nxt.I2CSensor class, which has both getData and sendData commands already implemented, so you don't need to create another nxtcam class).

You (should) send DF to put the nxtcam in DF mode, but I don't find what register you are supoused to read with getData... I mean, something like:

byte = getData(0x??, buf, len);

I don't find what is the register to read...

Thanks again!
robotnik
New User
 
Posts: 4
Joined: Tue Jan 15, 2013 10:33 am

Re: NXTCam image capture

Postby skoehler » Tue Jan 15, 2013 1:14 pm

robotnik wrote:I updated with the generic firmware (just to check how it goes) before trying with something "stronger", the point is that I'm trying to understand how you send and receive the commands (i guess with lejos.nxt.I2CSensor class, which has both getData and sendData commands already implemented, so you don't need to create another nxtcam class).


With I2C, you can send and receive strings of bytes. Whether these are interpreted as commands is entirely hardware dependent.
The I2CSensor class is intended as a super-class for I2C based sensors and thus has some convenience methods for hardware that has a common register based layout. If you want to access the I2C hardware of the NXT, use SensorPort.S1 etc. directly. They all have a i2cTransaction method, that allows you to send bytes and retrieve anything sent by the sensor in response.
skoehler
leJOS Team Member
 
Posts: 1110
Joined: Thu Oct 30, 2008 4:54 pm

Re: NXTCam image capture

Postby gloomyandy » Tue Jan 15, 2013 2:08 pm

The generic firmware I'm talking about is the firmware required for the second processor on the NXTCam (the PIC16F88 processor). This is what handles none standard communications with the NXT via i2c and is required if you want to use the image capture firmware for the NXTCam. All of the details are provided in this doc:
http://www.mindsensors.com/index.php?mo ... ile_id=941

I'm not sure what you mean by the DF command in your above post.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: NXTCam image capture

Postby robotnik » Tue Jan 15, 2013 3:09 pm

gloomyandy wrote:The generic firmware I'm talking about is the firmware required for the second processor on the NXTCam (the PIC16F88 processor). This is what handles none standard communications with the NXT via i2c and is required if you want to use the image capture firmware for the NXTCam. All of the details are provided in this doc:
http://www.mindsensors.com/index.php?mo ... ile_id=941

I'm not sure what you mean by the DF command in your above post.


Hi again, Andy, the DF command is the command that makes the AVRcam dump frames, in your code I think it's ID (incremental)

Code: Select all
else if ( (asciiTokenBuffer[0] == 'D') &&
            (asciiTokenBuffer[1] == 'F') )
   {
      /* we should go into frame dump mode */
      receivedCmd = dumpFrameCmd;   
   }
   else if ( (asciiTokenBuffer[0] == 'I') &&
            (asciiTokenBuffer[1] == 'D') )
   {
      /* we should go into frame dump mode */
      receivedCmd = incrementalDumpFrameCmd;   
   }


Code: Select all
else if (receivedCmd == incrementalDumpFrameCmd)
   {
      /* publish the event that will indicate that
      a request has come to dump a frame...this will
      be received by the FrameMgr, which will begin
      dumping the frame...a short delay is needed
      here to keep the Java demo app happy (sometimes
      it wouldn't be able to receive the serial data
      as quickly as AVRcam can provide it). */
      //Utility_delay(100);
      PUBLISH_EVENT(EV_DUMP_PARTIAL);
   }


in AVRCam:
Command Dump a Frame
Code DF
Parameters -
Response ACK – if command successfully received
NCK – if command not successfully received
Additional Response Packet Raw Frame dump.

Byte 0: 0x0B – indicating the start of raw color data line
Byte 1: line number in hex, indicating which line number is being sent
Byte 2-178: 176 hex pixel stacks, where a pixel stack is structured as follows:
Each pixel stack consists of a one-byte value, where the high nibble represents one color value (green), and the low nibble represents another color value (either red or blue). The pixels on the camera are arranged in Bayer format.
High nibble: Green pixel value of the even rows
Low nibble: Red or Blue pixel value of the odd rows
Byte 179: 0x0F – indicating an end of line
Example -


I see in the code some lines for sending the data (UIMgr_txBuffer and UartInt_txByte), but I still don't know how you can access this buffer from lejos... maybe like skoheler suggested?

whith SensorPort I could do nxtcam.readRawValue() to get the response of the NXTCam without specifying what register I want to read?

Thanks in advance to everyone
robotnik
New User
 
Posts: 4
Joined: Tue Jan 15, 2013 10:33 am

Re: NXTCam image capture

Postby gloomyandy » Tue Jan 15, 2013 3:12 pm

Please read the doc I pointed you at. There are several levels to this. At the I2C level you need to use the registers documented in the the doc above, these allow you to transfer data to and from the AVR processor on the NXTCam, it is withing this data transfer that you can use commands like "DF" etc. As I said before using this device is not easy...
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Previous

Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 0 guests

cron
more stuff