kauailabs / allwpilib

Fork of Official Repository of WPILibJ and WPILibC, which contain in addition a HAL for the KauaiLabs VMX-pi.
Other
1 stars 3 forks source link

SparkMax communication issues (with released version 1.4.0) #20

Closed kauailabs closed 5 years ago

kauailabs commented 5 years ago

From Driver station Logs:

CAN Spark when used together with TalonSRX indicates "Blackboard Entry Not Present", and firmware version is not retrieved as expected.

Reported by James Taylor by Email on 8/15/2019.

** Robot program starting ** [CAN SPARK MAX] WPILib or External HAL Error: CAN Blackboard Entry Not Present [CAN SPARK MAX] Unable to retrieve SPARK MAX firmware version for CAN ID: 42. Please verify the deviceID field matches the configured CAN ID of the controller, and that the controller is connected to the CAN Bus. Succesfully loaded vmxHaljni library. Received AHRS Configuration Data: 18 bytes. navX-Sensor startup initialization and startup calibration complete. navX-Sensor onboard startup calibration complete. navX-Sensor Yaw angle auto-reset to 0.0 due to startup calibration. TalonSRX (CAN DEVICE 10) has firmware 1046 TalonSRX (CAN DEVICE 11) has firmware 1046

kauailabs commented 5 years ago

The root cause is that the SparkMAX driver uses HAL_CAN_ReadPacketTimeout() to receive the response, it’s invoked multiple times. But these attempts occur before the response is received. It works on RoboRIO likely due to timing differences. There may be an assumption that HAL_CAN_ReadPacketTimeout() blocks for the timeout period, but it is not defined to do so - per Thad House it should return immediately whether a packet has been received or not.

kauailabs commented 5 years ago

This has been temporarily resolved with 2019.4.1 VMXpi Beta 16 Candidate (released 9/22/2019) and vmx-pi HAL version 1.1.207. The change to make this work is somewhat of a "hack", which behaves differently (with respect to timing) in the HAL_CAN_ReadPacketTimeout() function, when communicating with a REV Robotics Motor Controller. Hopefully we can work out a different solution that's cleaner from the VMX-pi HAL point-of-view.

amoose136 commented 5 years ago

What is the cleanest way to get the latest image? I downloaded the precompiled raspberry pi sd image and that doesn't appear to have the fix in place.

amoose136 commented 5 years ago

I ran sudo apt-get update && sudo apt-get upgrade and then also upgraded the firmware on the VMX-Pi to 3.0.410. Running dpkg -s vmxpi-hal returns Version: 1.1.207 and some other irrelevant info. dpkg -s vmxpi-frc returns the likewise with the same version number. I still get the original error.

Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -20044. CAN Blackboard Entry Not Present
   from: com.revrobotics.CANSparkMaxLowLevel.getFirmwareVersion(CANSparkMaxLowLevel.java:287)
     at: at edu.wpi.first.hal.CANAPIJNI.readCANPacketTimeout(Native Method)
     at: at edu.wpi.first.wpilibj.CAN.readPacketTimeout(CAN.java:135)
     at: at com.revrobotics.CANSparkMaxLowLevel.getFirmwareVersion(CANSparkMaxLowLevel.java:287)
     at: at com.revrobotics.CANSparkMaxLowLevel.<init>(CANSparkMaxLowLevel.java:239)
     at: at com.revrobotics.CANSparkMax.<init>(CANSparkMax.java:146)
     at: at frc.robot.DemoBot.robotInit(DemoBot.java:80)
     at: at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:63)
     at: at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:263)
     at: at frc.robot.Main.main(Main.java:27)

Error at com.revrobotics.CANSparkMaxLowLevel.getFirmwareVersion(CANSparkMaxLowLevel.java:287): Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -20044. CAN Blackboard Entry Not Present
at edu.wpi.first.hal.CANAPIJNI.readCANPacketTimeout(Native Method)
at edu.wpi.first.wpilibj.CAN.readPacketTimeout(CAN.java:135)
at com.revrobotics.CANSparkMaxLowLevel.getFirmwareVersion(CANSparkMaxLowLevel.java:287)
at com.revrobotics.CANSparkMaxLowLevel.<init>(CANSparkMaxLowLevel.java:239)
at com.revrobotics.CANSparkMax.<init>(CANSparkMax.java:146)
at frc.robot.DemoBot.robotInit(DemoBot.java:80)
at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:63)
at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:263)
at frc.robot.Main.main(Main.java:27)
Robots should not quit, but yours did!
Warning at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:274): Robots should not quit, but yours did!
The startCompetition() method (or methods called by it) should have handled the exception above.
Error at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:276): The startCompetition() method (or methods called by it) should have handled the exception above.
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x64868e7c, pid=2481, tid=2527
#
# JRE version: OpenJDK Runtime Environment (11.0.3+7) (build 11.0.3+7-post-Raspbian-5)
# Java VM: OpenJDK Server VM (11.0.3+7-post-Raspbian-5, mixed mode, serial gc, linux-)
# Problematic frame:
# C [libvmxpi_hal_cpp.so+0xa3e7c][thread 2534 also had an error]

Is VMX-pi currently usable with a SparkMax on CAN?

kauailabs commented 5 years ago

Hi Amos,

The remaining update you need is to the WPI HAL for VMX-pi, which is now at beta-16.

To install beta-16, on your development you'll need to update the KadenK/GradleRIO code from the github repo. You'll then need to rebuild the KadenK GradleRIO, and publish it locally using the instructions on this page: https://pdocs.kauailabs.com/vmx-pi/advanced/vmx-pi-wpi-library-beta/ beta-documentation/development-computer/

This update fixes a crashing issue with the Java OpenJDK, and also fixes an issue with TimedRobot, and also contains an update that addresses the SparkMax firmware check warning message.

Note also that the SparkMax now uses the released version of 1.4 REV firmware and libraries - and you should use their production .json file ( https://www.revrobotics.com/content/sw/max/sdk/REVRobotics.json).

Lots of moving parts....

Cheers,

P.S. Thanks for your feedback on the installer (visual studio installer-related). We're working on releasing a rolled-up version of beta image soon, we'll keep you posted on that. However from what you've written, it appears you've got all the necessary updates.

On Thu, Oct 3, 2019 at 7:26 PM Amos Manneschmidt notifications@github.com wrote:

I ran sudo apt-get update && sudo apt-get upgrade and then also upgraded the firmware on the VMX-Pi to 3.0.410. Running dpkg -s vmxpi-hal returns Version: 1.1.207 and some other irrelevant info. dpkg -s vmxpi-frc returns the likewise with the same version number. I still get the original error.

`Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -20044. CAN Blackboard Entry Not Present from: com.revrobotics.CANSparkMaxLowLevel.getFirmwareVersion(CANSparkMaxLowLevel.java:287) at: at edu.wpi.first.hal.CANAPIJNI.readCANPacketTimeout(Native Method) at: at edu.wpi.first.wpilibj.CAN.readPacketTimeout(CAN.java:135) at: at com.revrobotics.CANSparkMaxLowLevel.getFirmwareVersion(CANSparkMaxLowLevel.java:287) at: at com.revrobotics.CANSparkMaxLowLevel.(CANSparkMaxLowLevel.java:239) at: at com.revrobotics.CANSparkMax.(CANSparkMax.java:146) at: at frc.robot.DemoBot.robotInit(DemoBot.java:80) at: at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:63) at: at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:263) at: at frc.robot.Main.main(Main.java:27)

Error at com.revrobotics.CANSparkMaxLowLevel.getFirmwareVersion(CANSparkMaxLowLevel.java:287): Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -20044. CAN Blackboard Entry Not Present at edu.wpi.first.hal.CANAPIJNI.readCANPacketTimeout(Native Method) at edu.wpi.first.wpilibj.CAN.readPacketTimeout(CAN.java:135) at com.revrobotics.CANSparkMaxLowLevel.getFirmwareVersion(CANSparkMaxLowLevel.java:287) at com.revrobotics.CANSparkMaxLowLevel.(CANSparkMaxLowLevel.java:239) at com.revrobotics.CANSparkMax.(CANSparkMax.java:146) at frc.robot.DemoBot.robotInit(DemoBot.java:80) at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:63) at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:263) at frc.robot.Main.main(Main.java:27) Robots should not quit, but yours did! Warning at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:274): Robots should not quit, but yours did! The startCompetition() method (or methods called by it) should have handled the exception above. Error at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:276): The startCompetition() method (or methods called by it) should have handled the exception above. A fatal error has been detected by the Java Runtime Environment: SIGSEGV (0xb) at pc=0x64868e7c, pid=2481, tid=2527 JRE version: OpenJDK Runtime Environment (11.0.3+7) (build 11.0.3+7-post-Raspbian-5) Java VM: OpenJDK Server VM (11.0.3+7-post-Raspbian-5, mixed mode, serial gc, linux-) Problematic frame: C [libvmxpi_hal_cpp.so+0xa3e7c][thread 2534 also had an error]

`

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/kauailabs/allwpilib/issues/20?email_source=notifications&email_token=ACXLTCABRUNZJFJVUXGES3LQM3HZPA5CNFSM4IQHLMWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAKORRA#issuecomment-538241220, or mute the thread https://github.com/notifications/unsubscribe-auth/ACXLTCHW2D4ZOEAZQXV2IS3QM3HZPANCNFSM4IQHLMWA .

-- Scott Libert - Founder, Kauai Labs [image: https://www.kauailabs.com] https://www.kauailabs.com/

amoose136 commented 5 years ago

No luck on that. I'm already on the latest API. Switching to the GradleRIO directory and running git fetch and git status shows I'm up to date. All 4 Spark Max's are on the latest 1.4.x firmware as well.

PS C:\Users\amoos\Code\VMX-Pi-Test-Programs\GradleRIO-FRCJ> gradle buildEnvironment

> Task :buildEnvironment

------------------------------------------------------------
Root project
------------------------------------------------------------

classpath
\--- edu.wpi.first.GradleRIO:edu.wpi.first.GradleRIO.gradle.plugin:2019.4.1-VMX
     \--- edu.wpi.first:GradleRIO:2019.4.1-VMX
          +--- com.google.code.gson:gson:2.2.4
          +--- edu.wpi.first:gradle-cpp-vscode:0.7.1
          |    \--- com.google.code.gson:gson:2.2.4
          +--- edu.wpi.first:ToolchainPlugin:2019.4.1
          |    +--- jaci.gradle:EmbeddedTools:2018.12.18
          |    |    \--- com.jcraft:jsch:0.1.53
          |    \--- de.undercouch:gradle-download-task:3.1.2
          |         \--- org.apache.httpcomponents:httpclient:4.5.2
          |              +--- org.apache.httpcomponents:httpcore:4.4.4
          |              +--- commons-logging:commons-logging:1.2
          |              \--- commons-codec:commons-codec:1.9
          \--- com.jcraft:jsch:0.1.53

Code:

/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-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 edu.wpi.cscore.CameraServerJNI;
import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Watchdog;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj.drive.MecanumDrive;
import edu.wpi.first.wpilibj.interfaces.Accelerometer.Range;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

import javax.swing.event.HyperlinkEvent;

import com.kauailabs.navx.frc.*;
import edu.wpi.first.wpilibj.Spark;
import com.ctre.phoenix.unmanaged.UnmanagedJNI; 

import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;

/**
 * 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 manifest file in the resource
 * directory.
 */
public class DemoBot extends TimedRobot {
    //private static final int leftDeviceID = 1; 
    private static final int rightDeviceID = 4;
    //private CANSparkMax m_leftMotor;
    private CANSparkMax m_rightMotor;

    // public Spark rightf;
    // public Spark rightb;
    // public Spark leftf;
    // public Spark leftb;

    // public Encoder fright;
    // public Encoder bright;
    // public Encoder fleft;
    // public Encoder bleft;

    private Joystick idkimnotsure;

    private AHRS navx;
    //\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/private MecanumDrive mcDrive;

  /**
   * This function is run when the robot is first started up and should be
   * used for any initialization code.
   */
  @Override
  public void robotInit() {

    // rightf = new Spark(0);
    // rightb = new Spark(3);
    // leftf = new Spark(1);
    // leftb = new Spark(2);
    // fright = new Encoder(0,1);
    // bright = new Encoder(6,7);
    // fleft = new Encoder (2,3);
    // bleft = new Encoder(4,5);
    // rightf.setInverted(true);
    // rightb.setInverted(true);
    //m_leftMotor = new CANSparkMax(leftDeviceID, MotorType.kBrushless);
    m_rightMotor = new CANSparkMax(rightDeviceID, MotorType.kBrushless);

    idkimnotsure = new Joystick(0);
    navx = new AHRS();

  }

  /**
   * This function is run once each time the robot enters autonomous mode.
   */
  @Override
  public void autonomousInit() {

  }

  /**
   * This function is called periodically during autonomous.
   */
  @Override
  public void autonomousPeriodic() {
    UnmanagedJNI.JNI_FeedEnable(100); // Enable Phoenix CAN Devices for 100 Milliseconds

  }
  /**
   * This function is called once each time the robot enters teleoperated mode.
   */
  @Override
  public void teleopInit() {
    //mcDrive = new MecanumDrive(leftf, leftb, rightf, rightb);

  }

  /**
   * This function is called periodically during teleoperated mode.
   */
  @Override
  public void teleopPeriodic() {
    UnmanagedJNI.JNI_FeedEnable(100); // Enable Phoenix CAN Devices for 100 Milliseconds (some vmx-pi requirement)

    double xdirect = idkimnotsure.getX();
    double ydirect = idkimnotsure.getY();
    double rotation = idkimnotsure.getRawAxis(4);
    /*if (idkimnotsure.getRawButton(2)) {
      navx.zeroYaw();
    }*/

    SmartDashboard.putNumber("Unmodified xdirect", xdirect);
    SmartDashboard.putNumber("Unmodified ydirect", ydirect);

    SmartDashboard.putNumber("rotation", rotation);

    double yaw = navx.getYaw();
    SmartDashboard.putNumber("yaw", yaw);
    //mcDrive.driveCartesian(ydirect, xdirect, rotation, yaw);
    /*double va = getAngle(xdirect, ydirect);
    double hype = hype(xdirect, ydirect);
    double cva = va - yaw;
    if (Math.abs(cva) > 180) {
      cva= va-360*Math.abs(va)/va;
    }
    double cx = hype * Math.cos(Math.toRadians(cva));
    double cy = hype * Math.sin(Math.toRadians(cva));

    xdirect = cx;
    ydirect = cy;

    SmartDashboard.putNumber("yaw", yaw);
    SmartDashboard.putNumber("xdirect", xdirect);
    SmartDashboard.putNumber("ydirect", ydirect);*/

    double rfPower = clip(ydirect + rotation + xdirect);
    double rbPower = clip(ydirect + rotation - xdirect);
    double lfPower = clip(ydirect - rotation - xdirect);
    double lbPower = clip(ydirect - rotation + xdirect);

    // rightf.set(rfPower);
    // rightb.set(rbPower);
    // leftf.set(lfPower);
    // leftb.set(lbPower);
    //m_leftMotor.set(lbPower);

  }

  /**
   * This function is called periodically during test mode.
   */
  @Override
  public void testPeriodic() {

  }

  private double clip (double value) {
    if (Math.abs(value)>1){
        value = value/Math.abs(value);
    }
    return value;
  }

  //fod test

     public double hype (double x, double y) {

      return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));

    }

    private double getAngle (double x, double y){

      double va = 0;

      if (y > 0) {
         va = Math.toDegrees(Math.asin(Math.abs(x)/hype(x,y)));
      }
      if (y < 0){
         va = (Math.toDegrees(Math.acos(Math.abs(x)/hype(x,y))) + 90);
      }

      if (x < 0){
        va = va*-1;
      }

      return va;

    }

    public void derivedis () {

    }

    public void powow (double pow) {
      // rightf.set(pow);
      // rightb.set(pow);
      // leftf.set(pow);
      // leftb.set(pow);
    }
    public double codeP (){
      // fright.setDistancePerPulse(1);
      // bright.setDistancePerPulse(1);
      // bleft.setDistancePerPulse(1);
      // fleft.setDistancePerPulse(1);

      // double codeP = (fright.getDistance() + bright.getDistance() + bleft.getDistance() + fleft.getDistance())/4;

      // return codeP;
      return 0.0; //override
    }

}

Toggling on and off m_rightMotor = new CANSparkMax(rightDeviceID, MotorType.kBrushless); on line 81 will cause the code to switch between crashing on the VMX-Pi or happily pushing gyro data to NetworkTables.

amoose136 commented 5 years ago

Wait scratch all of that. It was the REVRobotics JSON file. Motors work now.

kauailabs commented 5 years ago

Please send me the time stamp and size of the libwpiHal.so file in /usr/local/FRC/third-party/lib, so I can verify the correct version (beta-16)is being used. Also, wanted to check - did you rebuild and locally publish the KadenK GradleRIO after updating the github repo?

Also, I’d like to see to FRC_UserProgram.log file at /var/local/kauailabs/log. It’s the same data that goes to the drive station log.

Finally, I see talon libraries in the code, even though Phoenix motor controllers aren’t used. You’ll need to ensure you have updated to the latest Phoenix-vmx.json file (at https://www.kauailabs.com/dist/frc/2019). If you’ve got old vendordeps for Phoenix, that could be causing problems.

If we don’t find anything there I will setup a similar environment here and try to reproduce.

On Thu, Oct 3, 2019 at 9:19 PM Amos Manneschmidt notifications@github.com wrote:

No luck on that. I'm already on the latest API. Switching to the GradleRIO directory and running git fetch and git status shows I'm up to date. All 4 Spark Max's are on the latest 1.4.x firmware as well.

PS C:\Users\amoos\Code\VMX-Pi-Test-Programs\GradleRIO-FRCJ> gradle buildEnvironment

Task :buildEnvironment

Root project------------------------------------------------------------

classpath --- edu.wpi.first.GradleRIO:edu.wpi.first.GradleRIO.gradle.plugin:2019.4.1-VMX --- edu.wpi.first:GradleRIO:2019.4.1-VMX +--- com.google.code.gson:gson:2.2.4 +--- edu.wpi.first:gradle-cpp-vscode:0.7.1 | --- com.google.code.gson:gson:2.2.4 +--- edu.wpi.first:ToolchainPlugin:2019.4.1 | +--- jaci.gradle:EmbeddedTools:2018.12.18 | | --- com.jcraft:jsch:0.1.53 | --- de.undercouch:gradle-download-task:3.1.2 | --- org.apache.httpcomponents:httpclient:4.5.2 | +--- org.apache.httpcomponents:httpcore:4.4.4 | +--- commons-logging:commons-logging:1.2 | --- commons-codec:commons-codec:1.9 --- com.jcraft:jsch:0.1.53

Code:

/----------------------------------------------------------------------------// Copyright (c) 2017-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 edu.wpi.cscore.CameraServerJNI;import edu.wpi.first.cameraserver.CameraServer;import edu.wpi.first.wpilibj.Encoder;import edu.wpi.first.wpilibj.Joystick;import edu.wpi.first.wpilibj.TimedRobot;import edu.wpi.first.wpilibj.Timer;import edu.wpi.first.wpilibj.Watchdog;import edu.wpi.first.wpilibj.drive.DifferentialDrive;import edu.wpi.first.wpilibj.drive.MecanumDrive;import edu.wpi.first.wpilibj.interfaces.Accelerometer.Range;import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import javax.swing.event.HyperlinkEvent; import com.kauailabs.navx.frc.*;import edu.wpi.first.wpilibj.Spark;import com.ctre.phoenix.unmanaged.UnmanagedJNI; import com.revrobotics.CANSparkMax;import com.revrobotics.CANSparkMaxLowLevel.MotorType;

/* 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 manifest file in the resource directory. */public class DemoBot extends TimedRobot { //private static final int leftDeviceID = 1; private static final int rightDeviceID = 4; //private CANSparkMax m_leftMotor; private CANSparkMax m_rightMotor;

// public Spark rightf;
// public Spark rightb;
// public Spark leftf;
// public Spark leftb;

// public Encoder fright;
// public Encoder bright;
// public Encoder fleft;
// public Encoder bleft;

private Joystick idkimnotsure;

private AHRS navx;
//\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/private MecanumDrive mcDrive;

/* This function is run when the robot is first started up and should be used for any initialization code. / @Override public void robotInit() {

// rightf = new Spark(0);
// rightb = new Spark(3);
// leftf = new Spark(1);
// leftb = new Spark(2);
// fright = new Encoder(0,1);
// bright = new Encoder(6,7);
// fleft = new Encoder (2,3);
// bleft = new Encoder(4,5);
// rightf.setInverted(true);
// rightb.setInverted(true);
//m_leftMotor = new CANSparkMax(leftDeviceID, MotorType.kBrushless);
m_rightMotor = new CANSparkMax(rightDeviceID, MotorType.kBrushless);

idkimnotsure = new Joystick(0);
navx = new AHRS();

}

/* This function is run once each time the robot enters autonomous mode. */ @Override public void autonomousInit() {

}

/* This function is called periodically during autonomous. */ @Override public void autonomousPeriodic() { UnmanagedJNI.JNI_FeedEnable(100); // Enable Phoenix CAN Devices for 100 Milliseconds

} /* This function is called once each time the robot enters teleoperated mode. */ @Override public void teleopInit() { //mcDrive = new MecanumDrive(leftf, leftb, rightf, rightb);

}

/* This function is called periodically during teleoperated mode. */ @Override public void teleopPeriodic() { UnmanagedJNI.JNI_FeedEnable(100); // Enable Phoenix CAN Devices for 100 Milliseconds (some vmx-pi requirement)

double xdirect = idkimnotsure.getX();
double ydirect = idkimnotsure.getY();
double rotation = idkimnotsure.getRawAxis(4);
/*if (idkimnotsure.getRawButton(2)) {      navx.zeroYaw();    }*/

SmartDashboard.putNumber("Unmodified xdirect", xdirect);
SmartDashboard.putNumber("Unmodified ydirect", ydirect);

SmartDashboard.putNumber("rotation", rotation);

double yaw = navx.getYaw();
SmartDashboard.putNumber("yaw", yaw);
//mcDrive.driveCartesian(ydirect, xdirect, rotation, yaw);
/*double va = getAngle(xdirect, ydirect);    double hype = hype(xdirect, ydirect);    double cva = va - yaw;    if (Math.abs(cva) > 180) {      cva= va-360*Math.abs(va)/va;    }    double cx = hype * Math.cos(Math.toRadians(cva));    double cy = hype * Math.sin(Math.toRadians(cva));    xdirect = cx;    ydirect = cy;    SmartDashboard.putNumber("yaw", yaw);    SmartDashboard.putNumber("xdirect", xdirect);    SmartDashboard.putNumber("ydirect", ydirect);*/

double rfPower = clip(ydirect + rotation + xdirect);
double rbPower = clip(ydirect + rotation - xdirect);
double lfPower = clip(ydirect - rotation - xdirect);
double lbPower = clip(ydirect - rotation + xdirect);

// rightf.set(rfPower);
// rightb.set(rbPower);
// leftf.set(lfPower);
// leftb.set(lbPower);
//m_leftMotor.set(lbPower);

}

/* This function is called periodically during test mode. */ @Override public void testPeriodic() {

}

private double clip (double value) { if (Math.abs(value)>1){ value = value/Math.abs(value); } return value; }

//fod test

 public double hype (double x, double y) {

  return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));

}

private double getAngle (double x, double y){

  double va = 0;

  if (y > 0) {
     va = Math.toDegrees(Math.asin(Math.abs(x)/hype(x,y)));
  }
  if (y < 0){
     va = (Math.toDegrees(Math.acos(Math.abs(x)/hype(x,y))) + 90);
  }

  if (x < 0){
    va = va*-1;
  }

  return va;

}

public void derivedis () {

}

public void powow (double pow) {
  // rightf.set(pow);
  // rightb.set(pow);
  // leftf.set(pow);
  // leftb.set(pow);
}
public double codeP (){
  // fright.setDistancePerPulse(1);
  // bright.setDistancePerPulse(1);
  // bleft.setDistancePerPulse(1);
  // fleft.setDistancePerPulse(1);

  // double codeP = (fright.getDistance() + bright.getDistance() + bleft.getDistance() + fleft.getDistance())/4;

  // return codeP;
  return 0.0; //override
}

}

Toggling on and off m_rightMotor = new CANSparkMax(rightDeviceID, MotorType.kBrushless); on line 81 will cause the code to switch between crashing on the VMX-Pi or happily pushing gyro data to NetworkTables.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/kauailabs/allwpilib/issues/20?email_source=notifications&email_token=ACXLTCETCWL3SMNEWKDDDILQM3VA5A5CNFSM4IQHLMWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAKXIIY#issuecomment-538276899, or mute the thread https://github.com/notifications/unsubscribe-auth/ACXLTCCLP3Y6T3LWRFFNVL3QM3VA5ANCNFSM4IQHLMWA .

-- Scott Libert - Founder, Kauai Labs [image: https://www.kauailabs.com] https://www.kauailabs.com/

kauailabs commented 5 years ago

Oops missed this before I sent my mail reply. Keep an eye on the Phoenix vendordeps, I’m concerned that might cause problems, too.

On Oct 3, 2019, at 9:30 PM, Amos Manneschmidt notifications@github.com wrote:

Wait scratch all of that. It was the REVRobotics JSON file. Motors work now.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.