Go to Post The best [fundraiser] that we did was our various little things this year, such as calanders and other things. The worst is not doing one at all. - Joe Matt [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 09-02-2017, 20:14
MamaSpoldi's Avatar
MamaSpoldi MamaSpoldi is offline
Programming Mentor
AKA: Laura Spoldi
FRC #0230 (Gaelhawks)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Shelton, CT
Posts: 309
MamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant future
Re: Arduino, pixy, and RoboRio Communications

Noah,

You do not need to use an arduino to communicate with the Pixy cam. There multiple interface options from the Pixy that the roboRIO can connect to directly. Last year we used the simple digital\analog x interface which tells you if it sees a target or not (digital), and where within the frame the target is (analog). This interface connects directly to 1 digital input and 1 analog input on the roboRIO.

The C++ class we created for this is shown here:

Code:
/*
 * PixyCamera.cpp
 *
 *  Created on: Mar 30, 2016
 *      Author: Gaelhawks
 */
#include "WPILib.h"
#include "Common.h"
#include "PixyCamera.h"


PixyCamera::PixyCamera()
{
    goalLocator = new AnalogInput(PIXY_ANALOG_INPUT);
    goalDetector = new DigitalInput(PIXY_GOAL_DETECTOR);
}

bool PixyCamera::GoalDetected()
{
    if(goalDetector->Get())
    {
        return true;
    }
    else
    {
        return false;
    }
}

float PixyCamera::GoalLocation()
{
    float cameraVoltage;

    cameraVoltage = goalLocator->GetVoltage();
    return cameraVoltage;
}

bool PixyCamera::OKtoShoot(float desiredGoal)
{
    // use lateralTrimValue in here somehow???
    // like: (CENTERED_GOAL_VOLTAGE + lateralTrimValue*0.1)
    if(GoalDetected() && (fabs)(GoalLocation() - desiredGoal) < VOLTAGE_TOLERANCE)
    {
        return true;
    }
    else
    {
        return false;
    }
}

void PixyCamera::UpdateDash()
{
    SmartDashboard::PutBoolean("Pixy OK to Shoot: ", OKtoShoot(CENTERED_GOAL_VOLTAGE));
    SmartDashboard::PutBoolean("Pixy Goal Detected: ", GoalDetected());
    SmartDashboard::PutNumber("Pixy Camera Voltage: ", GoalLocation());
    SmartDashboard::PutNumber("Pixy Lateral Trim: ", lateralTrimValue);
}
This year we are using the I2C interface which provides more detailed data about multiple targets. This thread https://www.chiefdelphi.com/forums/showthread.php?t=154355& has C++ code that we have used to successfully communicate with the Pixy.

Hope this helps.
__________________
Reply With Quote
 


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


All times are GMT -5. The time now is 00:13.

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