Go to Post I wouldn't want to face THAT bad boy in competition... - Iain McLeod [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 09-02-2016, 23:20
Kevin K Kevin K is offline
Registered User
FRC #4541 (CAV-ineers)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2013
Location: Severn, MD
Posts: 6
Kevin K is an unknown quantity at this point
GRIP and NetworkTables settings for use with a co-processor

My team has successfully written an algorithm to consistently find this year's targets in GRIP. However, for whatever reason we are unable to transmit contour information to our program on the roboRIO. I essentially copied our code line for line from the Java examples on ScreenstepsLive and the GRIP github page, with minor tweaks in order to access the variables we care about. Our GRIP related code is as follows:
In constructor:
table = NetworkTable.getTable("GRIP/myContoursReport");
In operatorControl:
targetWidth = table.getNumber("width", 0);
When we run our program, the default value of zero is always returned. We run GRIP on a separate laptop(we eventually hope to use a Kangaroo on our robot, but it has not arrived yet). In GRIP I have set the NetworkTables server address as roborio-4541-frc.local, and we can view all of the contour information on our main laptop using OutlineViewer in client mode with the server at the same address. I tried running our code as a client as well, but recieved an error stating that there was already an instance of NetworkTables running. This is our first year using NetworkTables, so I do not have the required knowledge to troubleshoot this problem any further on my own(I've already spent a good 2-3 meetings working on this). Any help or advice anyone could give would be much appreciated.
  #2   Spotlight this post!  
Unread 10-02-2016, 01:30
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 243
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: GRIP and NetworkTables settings for use with a co-processor

The robot is always the NetworkTables server. Do you see "client connected" messages on the robot? Are you sure you have the table name / value name correct? A screenshot of what OutlineViewer is showing you would be helpful in debugging.
__________________
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
  #3   Spotlight this post!  
Unread 10-02-2016, 09:13
Kevin K Kevin K is offline
Registered User
FRC #4541 (CAV-ineers)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2013
Location: Severn, MD
Posts: 6
Kevin K is an unknown quantity at this point
Re: GRIP and NetworkTables settings for use with a co-processor

I cannot get to our laptop to take a screenshot at the moment, but I remember that OutlineViewer showed all of the contour information as well as the values being sent to the SmartDashboard. I am positive we have typed in all of the paths correctly. Where might we see this "client connected" message? In the riolog?
  #4   Spotlight this post!  
Unread 10-02-2016, 10:49
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 243
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: GRIP and NetworkTables settings for use with a co-processor

Quote:
Originally Posted by Kevin K View Post
I cannot get to our laptop to take a screenshot at the moment, but I remember that OutlineViewer showed all of the contour information as well as the values being sent to the SmartDashboard. I am positive we have typed in all of the paths correctly. Where might we see this "client connected" message? In the riolog?
Correct, in riolog (or the driver station console if you turn on prints), you should see "NT: server: client CONNECTED: <ip> port <port>" printed for each NT client that has connected.
__________________
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
  #5   Spotlight this post!  
Unread 10-02-2016, 15:05
Kevin K Kevin K is offline
Registered User
FRC #4541 (CAV-ineers)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2013
Location: Severn, MD
Posts: 6
Kevin K is an unknown quantity at this point
Re: GRIP and NetworkTables settings for use with a co-processor

I just tried it, the correct message displayed in the riolog.
  #6   Spotlight this post!  
Unread 10-02-2016, 15:53
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 243
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: GRIP and NetworkTables settings for use with a co-processor

Quote:
Originally Posted by Kevin K View Post
I just tried it, the correct message displayed in the riolog.
Ok, there's no reason you shouldn't be able to read the table then. Can you post or PM me a more complete snippet of your code?
__________________
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
  #7   Spotlight this post!  
Unread 10-02-2016, 15:59
Kevin K Kevin K is offline
Registered User
FRC #4541 (CAV-ineers)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2013
Location: Severn, MD
Posts: 6
Kevin K is an unknown quantity at this point
Re: GRIP and NetworkTables settings for use with a co-processor

This is our entire Robot.java class. NetworkTables related code is bolded.


package org.usfirst.frc.team4541.robot;


import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.SPI;

import com.kauailabs.navx.frc.AHRS;

import edu.wpi.first.wpilibj.CANTalon;
import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.I2C;
import edu.wpi.first.wpilibj.I2C.Port;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.networktables.NetworkTable;
import edu.wpi.first.wpilibj.smartdashboard.SendableChoos er;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboar d;

public class Robot extends SampleRobot {
Joystick stick;
TankDrive drive;
CANTalon t1, t2, t3, t4, t5, t6, t7, t8, t9;
MotorManip m1, m2, m3, m4, m5;
Shooter shooter;
Intake intake;
Climber climber;

LIDAR lidar;
final String defaultAuto = "Default";
final String customAuto = "My Auto";
SendableChooser chooser;
AHRS gyro;
NetworkTable table;
CameraServer server;
double targetWidthPx;
double targetDistanceIn;
double desiredX;
double targetOffsetIn;
double targetOffsetDegrees;
// Port port = I2C.Port.kOnboard;

public Robot() {
stick = new Joystick(0);
t1 = new CANTalon(0);
t2 = new CANTalon(1);
t3 = new CANTalon(2);
t4 = new CANTalon(3);
t5 = new CANTalon(4);
t6 = new CANTalon(5);
t7 = new CANTalon(6);
t8 = new CANTalon(7);
t9 = new CANTalon(8);
m1 = new MotorManip(t5);
m2 = new MotorManip(t6);
m3 = new MotorManip(t7);
m4 = new MotorManip(t8);
climber = new Climber(t9);
drive = new TankDrive(t1,t2,t3,t4);
shooter = new Shooter(m1, m2);
intake = new Intake(m3, m4);
// lidar = new LIDAR(port);
gyro = new AHRS(SPI.Port.kMXP);
server = CameraServer.getInstance();
server.setQuality(50);
server.startAutomaticCapture("cam0");
}

public void robotInit() {
chooser = new SendableChooser();
chooser.addDefault("Default Auto", defaultAuto);
chooser.addObject("My Auto", customAuto);
SmartDashboard.putData("Auto modes", chooser);
table = NetworkTable.getTable("GRIP/myContoursReport");
}

public void autonomous() {

// String autoSelected = (String) chooser.getSelected();
// String autoSelected = SmartDashboard.getString("Auto Selector", defaultAuto);
// System.out.println("Auto selected: " + autoSelected);
//
// switch(autoSelected) {
// case customAuto:
// break;
// case defaultAuto:
// default:
// break;
// }
}

public void operatorControl() {
gyro.reset();
while (isOperatorControl() && isEnabled()) {
// lidar.begin(100, 0xff);
// lidar.start(100);
// SmartDashboard.putNumber("Distance", lidar.getDistance());
targetWidthPx = table.getNumber("width", 0);
targetDistanceIn = 3200/(2 * targetWidthPx * Math.tan(25));
desiredX = 0;
targetOffsetIn = (desiredX -table.getNumber("centerX", 0)) * 20/targetWidthPx;
targetOffsetDegrees = Math.tan(targetOffsetIn/targetDistanceIn);

SmartDashboard.putNumber("angle", gyro.getAngle());
SmartDashboard.putNumber("output", Math.abs(.0035*(90-gyro.getAngle())));
SmartDashboard.putNumber("target width", targetWidthPx);
SmartDashboard.putNumber("target distance", targetDistanceIn);
drive.arcadeDrive(drive.modStickIn(stick,1),drive. modStickIn(stick, 4));
if(stick.getRawButton(1)){
drive.rotateToAngle(90, gyro);
}
else if(stick.getRawButton(5)){
drive.speedUp();
}
else if(stick.getRawButton(6)){
drive.slowDown();
}
// else if(stick.getRawButton(2)){
// drive.rotateToAngle(targetOffsetDegrees, gyro);
// shooter.shoot(1,1);
// }
// else if(stick.getRawButton(4)){
// intake.pickUp(1);
// }
//
// else if(stick.getRawButton(5)){
// climber.extend(.5);
// }
//
// else if(stick.getRawButton(6)){
// climber.retract(.5);
// }

}
}


public void test() {
}

}
  #8   Spotlight this post!  
Unread 10-02-2016, 16:03
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 243
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: GRIP and NetworkTables settings for use with a co-processor

Since you're running it now, could you post a screenshot of what OutlineViewer is showing?

My guess is that the data type being put by GRIP is an array rather than a single number?

Edit: yes, looks like it is. See http://wpilib.screenstepslive.com/s/...-networktables
__________________
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
  #9   Spotlight this post!  
Unread 10-02-2016, 16:14
Kevin K Kevin K is offline
Registered User
FRC #4541 (CAV-ineers)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2013
Location: Severn, MD
Posts: 6
Kevin K is an unknown quantity at this point
Re: GRIP and NetworkTables settings for use with a co-processor

I had tried changing it to an array, but I can give it another shot. Here is the screenshot from OutlineViewer
Attached Thumbnails
Click image for larger version

Name:	outlineviewer.PNG
Views:	41
Size:	16.3 KB
ID:	20033  
  #10   Spotlight this post!  
Unread 10-02-2016, 16:17
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 243
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: GRIP and NetworkTables settings for use with a co-processor

Yep, those are definitely arrays (albeit 1-element ones).

So you should use getNumberArray() instead, check the size of the result, and get the 0th element.
__________________
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
  #11   Spotlight this post!  
Unread 10-02-2016, 16:24
Kevin K Kevin K is offline
Registered User
FRC #4541 (CAV-ineers)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2013
Location: Severn, MD
Posts: 6
Kevin K is an unknown quantity at this point
Re: GRIP and NetworkTables settings for use with a co-processor

I just tried it again using getNumberArray(); and it still only returns the default value.
Edit: Actually, it turns out that I forgot to recompile. I am getting the data now, thank you so much for all of your help.

Last edited by Kevin K : 10-02-2016 at 16:34.
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


All times are GMT -5. The time now is 21:51.

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