Go to Post Are people allowed to go to the roboprom, or just our robots? - AmoryG [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 28-02-2007, 19:56
lrantisi lrantisi is offline
Registered User
no team
 
Join Date: Feb 2007
Location: Canada
Posts: 2
lrantisi is an unknown quantity at this point
Question C code to get information from CMUcam2

Hello everybody
I am using CMUcam2 that is installed on a robot that uses an Altera Board.
The camera is connecting to the board using a UART port.

I am using Altera NIOS II IDE environment to do the C language to test and run the C code that communicates with the camera.

So it is a C code that runs on the Altera board.

Can anybody help me to know what's the basci C code that communicates with the camera.

I need to get color and light information from the camera.

Any help will be apreciated.
  #2   Spotlight this post!  
Unread 28-02-2007, 21:17
bear24rw's Avatar
bear24rw bear24rw is offline
Team 11 Programming Captain
AKA: Max T
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2005
Location: Flanders, NJ
Posts: 385
bear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to behold
Send a message via AIM to bear24rw
Re: C code to get information from CMUcam2

http://kevin.org/frc/

You will find the cmucam2 documentation there
  #3   Spotlight this post!  
Unread 28-02-2007, 22:12
jgannon's Avatar
jgannon jgannon is offline
I ᐸ3 Robots
AKA: Joey Gannon
no team
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Pittsburgh, PA
Posts: 1,467
jgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond repute
Re: C code to get information from CMUcam2

Hello and welcome to Chief Delphi. It sounds like you're using a different system than we all use in our competition, but it's likely that some people around here will still be able to help you.

If you use the documentation that Max linked to, you should be able to figure out a lot about the CMUcam2 protocol. From the work I've done with it, it's pretty simple. Send a few bytes out your UART, terminate it with a carriage return, and you'll get back an ACK and/or the data you requested. All of the commands are documented in the CMUcam2 manual, and on Kevin Watson's site. As for the actual code to read and write to your UART, that's beyond the scope of my knowledge. Somebody else around here may know, or you can poke around on Google. Once you've got that figured out, the CMUcam2 interface is pretty simple. (As somewhat of a side note, you can play around with the commands and see what they do by plugging the CMUcam2 into your computer, and then using a program like Hyperterminal to send and receive the data.)
__________________
Team 1743 - The Short Circuits
2010 Pittsburgh Excellence in Design & Team Spirit Awards
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2007 Pittsburgh Website Award
2006 Pittsburgh Regional Champions (thanks to 395 and 1038)
2006 Pittsburgh Rookie Inspiration & Highest Rookie Seed

Team 1388 - Eagle Robotics
2005 Sacramento Engineering Inspiration
2004 Curie Division Champions (thanks to 1038 and 175)
2004 Sacramento Rookie All-Star

_
  #4   Spotlight this post!  
Unread 01-03-2007, 15:23
lrantisi lrantisi is offline
Registered User
no team
 
Join Date: Feb 2007
Location: Canada
Posts: 2
lrantisi is an unknown quantity at this point
Wink Re: C code to get information from CMUcam2

Thanks for your reply
But what do you think about this code, any notes please.

Code:
/* A simple program that sends an order to the CMUcam2 camera and
 reads back from it*/
:confused: :rolleyes: :] 
#include <stdio.h>
#include <string.h>
int main ()
{
FILE* fp;
char prompt = 0;
int Written_Char;

fp = fopen ("/dev/uart1", "r+"); //Open the camera port for reading and writing.
if (fp)
{
Written_Char = fputc(":TC\r",fp); // writing a character to the UART.
prompt = getc(fp); // Get a character from the UART.
fprintf(fp, "Closing the UART file.\n");
fclose (fp);
}
return 0;
}
  #5   Spotlight this post!  
Unread 01-03-2007, 20:20
bear24rw's Avatar
bear24rw bear24rw is offline
Team 11 Programming Captain
AKA: Max T
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2005
Location: Flanders, NJ
Posts: 385
bear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to behold
Send a message via AIM to bear24rw
Re: C code to get information from CMUcam2

Written_Char = fputc(":TC\r",fp);

i think you want to take the : out of that.. you see a : before all the lines in the manual just because thats how hyperterm prompt is... take out the : and try that
  #6   Spotlight this post!  
Unread 20-03-2007, 18:16
Shinigami2057 Shinigami2057 is offline
Slackware Is Your New God (Mentor)
AKA: Harry Bock
FRC #1350 (Rambots)
Team Role: Programmer
 
Join Date: Oct 2006
Rookie Year: 2006
Location: Johnston, RI
Posts: 106
Shinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really nice
Re: C code to get information from CMUcam2

That works fairly well - it looks like you're using a UNIX-based system. I believe you'd be better off using the read/write syscalls for the UART interface on your device, i.e.:

Code:
#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

typedef struct track {
    uint8_t mx, my;
    uint8_t x1, y1;
    uint8_t x2, y2;
    uint8_t pixels, confidence;
} track_t;

int main()
{
    track_t camtrack;
    char buffer[64] = "tc\r";
    int fd = open("/dev/uart1", O_RDWR);
    if(fd == -1) {
        fprintf(stderr, "Error opening UART");
        /* do something */
    }

    write(fd, buffer, strlen(buffer));
    read(fd, &camtrack, sizeof(track_t));

    close(fd);
    return 0;
}
Or something like that.
__________________
One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2007 CMUcam2 Code Kevin Watson Programming 6 10-01-2009 14:06
2006 CMUcam2 Code Kevin Watson Programming 81 10-02-2007 20:17
CMUcam2 code for EDU-RC? Calvin Programming 19 27-01-2006 10:41
CMUCam2 code (FRC and EDU?) Amber Programming 0 15-02-2005 22:23
Where is the CMUcam2 code? Matthew_H Programming 1 14-01-2005 17:49


All times are GMT -5. The time now is 09:32.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi