I am sorry if this is consider spamming, but I have posted before but I was not successful in getting a reply. We “Run as WPILib C++ deploy”, in the eclipse console it ran successfully, but the comm light on the RoboRio is still red, and no code is detected on the Driver Station. But here is our robot set up:
- 4 Talon Speed controllers wiring to pwm port 2-5 on the RoboRio
- Running on Eclipse Neon.3 Release (4.6.3)
- RoboRio is approximately 1~2 years old but the image is updated
and here is our code:
Robot.h :
#ifndef ROBOT_H
#define ROBOT_H
//Importing Liraries
#include <memory>
#include <Commands/Command.h>
#include <IterativeRobot.h>
#include <LiveWindow/LiveWindow.h>
//Importing OI and Subsystem file
#include "OI.h"
#include "Subsystems/DriveTrain.h"
//Creating the class robot, inherting from the class IterativeRobot
class Robot: public frc::IterativeRobot {
public:
//Creating public pointer to the drivetrain subsystem and the oi
static std::shared_ptr<DriveTrain> drivetrain;
static std::unique_ptr<OI> oi;
private:
//Creating a private instance of the live window
frc::LiveWindow* lw = frc::LiveWindow::GetInstance();
//Overidding all of the default method
void RobotInit() override;
void AutonomousInit() override;
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
};
#endif // ROBOT_H_
Robot.cpp:
#include "Robot.h"
#include <iostream>
#include <Commands/Scheduler.h>
//Setting up the share Subsystems and oi so that the commands can use it
std::shared_ptr<DriveTrain> Robot::drivetrain = std::make_shared<DriveTrain>();
std::unique_ptr<OI> Robot::oi = std::make_unique<OI>();
//Run once on robot start up
void Robot::RobotInit() {
//Putting the data of the drivetrain onto the smartdashboard
frc::SmartDashboard::PutData(drivetrain.get());
}
//Run once when robot is in autonomous mode
void Robot::AutonomousInit() {
//Put autonomous startup here
}
//Keep running when the robot is in autonomous mode
void Robot::AutonomousPeriodic() {
//Running an instance of the scheduler
frc::Scheduler::GetInstance()->Run();
}
//Run once when the robot go into teleoperated mode
void Robot::TeleopInit() {
//End autonomous code here
}
//Keep running while the robot is in Teleoperated mode
void Robot::TeleopPeriodic() {
//Running an instance of the scheduler
frc::Scheduler::GetInstance()->Run();
}
//Test Mode
void Robot::TestPeriodic() {
lw->Run();
}
//Start the robot?
START_ROBOT_CLASS(Robot)
OI.h:
#ifndef OI_H_
#define OI_H_
#include <Buttons/JoystickButton.h>
#include <Joystick.h>
//Creating the class operater Interface for inputs
class OI {
public:
//Public contructor
OI();
//Public method getJoystick that return the address of joystick
frc::Joystick* GetJoystick();
private:
//Private object joy of class joystick
frc::Joystick joy { 0 };
};
#endif // OI_H_
OI.cpp:
#include "OI.h"
#include <WPILib.h>
OI::OI() {
// Connect the buttons to commands
}
//Returning the address of the Joystick
frc::Joystick* OI::GetJoystick() {
return &joy;
}
Subsystems/DriveTrain.h:
#ifndef DriveTrain_H
#define DriveTrain_H
//Importing classes
#include <Commands/Subsystem.h>
#include <Talon.h>
#include <RobotDrive.h>
//Creating a class joystick under the namespace of FRC
namespace frc {
class Joystick;
}
//Creating a class Drivetrain inherting from the class Subsystem
class DriveTrain : public frc::Subsystem {
public:
//Public contructor
DriveTrain();
//overring the start up command
void InitDefaultCommand() override;
//Creating the Tank style drive method
/**
* Tank style driving for the DriveTrain.
* @param left Speed in range -1,1]
* @param right Speed in range -1,1]
*/
void Drive(double left, double right);
//creating an arcade style drive method
/**
* @param joy
*/
void Drive(frc::Joystick* joy);
private:
//Setting up the drive train
frc::Talon frontLeft { 2 };
frc::Talon rearLeft { 3 };
frc::Talon frontRight { 4 };
frc::Talon rearRight { 5 };
frc::RobotDrive driveTrain { frontLeft, rearLeft, frontRight, rearRight };
};
#endif // DriveTrain_H
Subsystems/DriveTrain.cpp:
//Including Files
#include "DriveTrain.h"
#include <Joystick.h>
#include <LiveWindow/LiveWindow.h>
//Including the command file
#include "Commands/ArcadeDriveWithJoystick.h"
//Creating the contructor
DriveTrain::DriveTrain()
: Subsystem("DriveTrain") {
//Inverting all of the motor because the motor are wired in reverse
driveTrain.SetInvertedMotor(RobotDrive::kFrontLeftMotor, true);
driveTrain.SetInvertedMotor(RobotDrive::kRearLeftMotor, true);
driveTrain.SetInvertedMotor(RobotDrive::kFrontRightMotor, true);
driveTrain.SetInvertedMotor(RobotDrive::kRearRightMotor, true);
}
//Run on robot start up
void DriveTrain::InitDefaultCommand (){
//Settting the default command to be drving this drive train with a Joystick
SetDefaultCommand(new ArcadeDriveWithJoystick());
}
//Setting up the drive method
void DriveTrain::Drive(double left, double right){
//Driving with the left and the right parameter
driveTrain.TankDrive(left, right);
}
//Setting up the arcadedrive method
void DriveTrain::Drive(frc::Joystick* joy){
//Driving with the Joystick address
driveTrain.ArcadeDrive(joy);
}
Commands/ArcadeDriveWithJoystick.h
#ifndef ArcadeDriveWithJoystick_H
#define ArcadeDriveWithJoystick_H
//Importing the command class
#include <Commands/Command.h>
//Creating the class inherting from the class command
class ArcadeDriveWithJoystick : public Command {
public:
//Calling public contructor
ArcadeDriveWithJoystick();
//Overidding methods
void Execute() override;
bool IsFinished() override;
void End() override;
};
#endif // ArcadeDriveWithJoystick_H
Commands/ArcadeDriveWithJoystick.cpp
//Including files
#include "ArcadeDriveWithJoystick.h"
#include "Robot.h"
//Calling the public contructor
ArcadeDriveWithJoystick::ArcadeDriveWithJoystick() :
frc::Command("ArcadeDriveWithJoystick") {
//Getting the DriveTrain subsystem.
Requires(Robot::drivetrain.get());
}
//Run continously while IsFinished return false
void ArcadeDriveWithJoystick::Execute() {
//Driving the drivetrain with the joystick)
Robot::drivetrain->Drive(Robot::oi->GetJoystick());
}
// Make this return true when this Command no longer needs to run execute()
bool ArcadeDriveWithJoystick::IsFinished() {
return false;
}
// Called once after isFinished returns true
void ArcadeDriveWithJoystick::End() {
}
And in the RioLog this is displaying over and over again:
execvp: Permission denied
➔ Launching «’/home/lvuser/FRCUserProgram’»
➔ Launching «’/home/lvuser/FRCUserProgram’»
➔ Launching «’/home/lvuser/FRCUserProgram’»
➔ Launching «’/home/lvuser/FRCUserProgram’»
➔ Launching «’/home/lvuser/FRCUserProgram’»
➔ Launching «’/home/lvuser/FRCUserProgram’»
➔ Launching «’/home/lvuser/FRCUserProgram’»
➔ Launching «’/home/lvuser/FRCUserProgram’»
➔ Launching «’/home/lvuser/FRCUserProgram’»
➔ Launching «’/home/lvuser/FRCUserProgram’»
➔ Launching «’/home/lvuser/FRCUserProgram’»
➔ Launching «’/home/lvuser/FRCUserProgram’»
And in the Driver Station, no code is detected, and on the RoboRio the communication light is red. We do not know why the code is not uploading to the RoboRio, please help, this is the only thing that are stopping us.
P.S: We confirmed that our electrical set up work because I deployed and ran this code on the RoboRio and everything work just fine (Code detected on the RoboRio, We can drive it in the teleoperated mode, and it run in Autonmous Mode):
//Importing all of the class file from FRC
#include <IterativeRobot.h>
#include <Joystick.h>
#include <LiveWindow/LiveWindow.h>
#include <RobotDrive.h>
#include <Timer.h>
//Creating a class robot inherting from the class IterativeRobot
class Robot: public frc::IterativeRobot {
public:
//Public Contructor
Robot() {
//Settting the drive expiration and the starting the timer
myRobot.SetExpiration(0.1);
timer.Start();
}
private:
//calling and intializing all of our objects
frc::RobotDrive myRobot { 2, 3, 4, 5 }; // Robot drive system
frc::Joystick stick { 0 }; // Only joystick
frc::LiveWindow* lw = frc::LiveWindow::GetInstance(); //Instance of the liveWindow
frc::Timer timer; //Timer
//Running once before the autonomous start
void AutonomousInit() override {
//Resetting the timer
timer.Reset();
timer.Start();
}
//Run while robot is in autonomous
void AutonomousPeriodic() override {
// Drive for 2 seconds
if (timer.Get() < 2.0) {
myRobot.Drive(-0.5, 0.0); // Drive forwards half speed
} else {
myRobot.Drive(0.0, 0.0); // Stop robot
}
}
//Run once before the teleoperated mode start
void TeleopInit() override {
//Reversing all the drive
myRobot.SetInvertedMotor(RobotDrive::kFrontLeftMotor, true);
myRobot.SetInvertedMotor(RobotDrive::kRearLeftMotor, true);
myRobot.SetInvertedMotor(RobotDrive::kFrontRightMotor, true);
myRobot.SetInvertedMotor(RobotDrive::kRearRightMotor, true);
}
//Run while the robot is in teleoperated mode
void TeleopPeriodic() override {
// Drive with arcade style (use right stick)
myRobot.ArcadeDrive(stick);
}
//Running while the robot is in test mode
void TestPeriodic() override {
//Running the instance of the live window
lw->Run();
}
};
//Starting the robot
START_ROBOT_CLASS(Robot)
I am really sorry for the long post.