Hi, my team wants to connect the pixy by UART. Can someone give me some guidelines and some example code? Also, you may show me other ways to connect the pixy with some code also. Is our first time using the pixy for a robot and also utilizing vision tracking, so the more the details the better.
Curious on this as well, we are trying through SPI and we can see data on our smart dashboard in X Y, Height, Width, but seems to have locked onto 1 signature meaning it jumps back and forth from the two images i Do not think its a average of the two.
Any ideas on how to use the pixy 2 cam to separate that data for 2 images as in the tape this year.
We haven’t tested it yet, but the pixy 2 has a compatibility mode that might work with code for the pixy one. You can activate it in one of the settings tabs in pixymon.
From the docs, " Note, this parameter only applies to SPI, UART, and I2C interfaces – not USB. Additionally, it only applies to the color_connected_components program."
I don’t think there is a way to directly connect the Pixy(or Pixy2) to the RoboRIO, at least with official libraries, in Java. I think most teams just plug the Pixy into the Arduino with the included cable and use the Arduino Pixy(or Pixy2) library to do the processing on the Arduino and then send the results to the RoboRIO. We have a repository that is just code to send data from a Pixy to robot using an Arduino and I2C. Our 2019 repo has code to communicate with the Pixy and Arduino in command based if that helps?
The code that was listed is only covering the response from the PIXY 1 but not the actual request for the data from the Roborio. Did the old pixy model not require two-way communication? Because the pixy 2 website requires that we send requests from the Roborio to the pixy and then capture the data back again from the pixy2.
Also, is the 0x55 0xaa on the old pixy the same as the 16-bit sequence and 0xc1af on the pixy 2 or is it using that for error-checking?
Hey, I’m trying to implement the API you listed in that post. Can you help me implementing it to a new FRC project? @dilanpace1496. This is what I have:
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package frc.robot;
import com.sun.org.apache.xpath.internal.Arg;
import edu.wpi.first.wpilibj.TimedRobot;
import io.github.pseudoresonance.pixy2api.Pixy2;
import sun.security.provider.ConfigFile.Spi;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the TimedRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the build.gradle file in the
* project.
*/
public class Robot extends TimedRobot {
/**
* This function is run when the robot is first started up and should be used
* for any initialization code.
*/
Pixy2 pixy = Pixy2.createInstance(Spi);
@Override
public void robotInit() {
pixy.init();
}
@Override
public void autonomousInit() {
}
@Override
public void autonomousPeriodic() {
}
@Override
public void teleopInit() {
}
@Override
public void teleopPeriodic() {
}
@Override
public void testInit() {
}
@Override
public void testPeriodic() {
}
}
And this is the gradle.build:
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2019.1.1"
}
def ROBOT_MAIN_CLASS = "frc.robot.Main"
// Define my targets (RoboRIO) and artifacts (deployable files)
// This is added by GradleRIO's backing project EmbeddedTools.
deploy {
targets {
roboRIO("roborio") {
// Team number is loaded either from the .wpilib/wpilib_preferences.json
// or from command line. If not found an exception will be thrown.
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
// want to store a team number in this file.
team = frc.getTeamNumber()
}
}
artifacts {
frcJavaArtifact('frcJava') {
targets << "roborio"
// Debug can be overridden by command line, for use with VSCode
debug = frc.getDebugOrDefault(false)
}
// Built in artifact to deploy arbitrary files to the roboRIO.
fileTreeArtifact('frcStaticFileDeploy') {
// The directory below is the local directory to deploy
files = fileTree(dir: 'src/main/deploy')
// Deploy to RoboRIO target, into /home/lvuser/deploy
targets << "roborio"
directory = '/home/lvuser/deploy'
}
}
}
// Set this to true to enable desktop support.
def includeDesktopSupport = false
// Maven central needed for JUnit
repositories {
mavenCentral()
maven { url 'https://nexus.otake.pw/repository/maven-public/' }
}
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 4.
dependencies {
compile 'pw.otake.pseudoresonance:pixy2-java-api:1.1'
compile wpi.deps.wpilib()
compile wpi.deps.vendor.java()
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
testCompile 'junit:junit:4.12'
}
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
}
Well first off, change the version number in the build.gradle since a recent release was published for the API on GitHub (You will have to keep up to date from time to time for these updates).
compile ‘pw.otake.pseudoresonance:pixy2-java-api:1.1’
to
compile ‘pw.otake.pseudoresonance:pixy2-java-api:1.3.1’
Are you planning on making a separate file to do the Pixy2 commands in? (Like in a Subsystem folder?)
We also are using a normal camera along with our Pixy 2 since the API for a video stream over USB to the RoboRIO does not exist yet. (We may look into that after Build Season but it isn’t important yet for us).