Go to Post Data is never ugly. It is only how you use it that can be. - Ed Law [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 23-01-2017, 17:30
loganzip loganzip is offline
Registered User
FRC #2838
 
Join Date: Feb 2014
Location: USA
Posts: 10
loganzip is an unknown quantity at this point
Programming Help

I keep getting errors in my programming.Would someone be willing to help me?
Thank you
Reply With Quote
  #2   Spotlight this post!  
Unread 23-01-2017, 18:10
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 509
Hitchhiker 42 has a reputation beyond reputeHitchhiker 42 has a reputation beyond reputeHitchhiker 42 has a reputation beyond reputeHitchhiker 42 has a reputation beyond reputeHitchhiker 42 has a reputation beyond reputeHitchhiker 42 has a reputation beyond reputeHitchhiker 42 has a reputation beyond reputeHitchhiker 42 has a reputation beyond reputeHitchhiker 42 has a reputation beyond reputeHitchhiker 42 has a reputation beyond reputeHitchhiker 42 has a reputation beyond repute
Re: Programming Help

Could you post the errors you are getting? And exactly what you are trying to do? More information would be helpful for people to help you.
__________________



2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award
Reply With Quote
  #3   Spotlight this post!  
Unread 24-01-2017, 08:09
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 375
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Programming Help

Quote:
Originally Posted by loganzip View Post
I keep getting errors in my programming.Would someone be willing to help me?
Thank you
No.

No one would be willing to help you if you don't provide any details about what you need help with
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #4   Spotlight this post!  
Unread 24-01-2017, 14:36
loganzip loganzip is offline
Registered User
FRC #2838
 
Join Date: Feb 2014
Location: USA
Posts: 10
loganzip is an unknown quantity at this point
Re: Programming Help

Here is my program so far
.hpp File
#ifndef __EagleRobot_HPP__
#define __EagleRobot_HPP__
/**
* This is Team 2838 Eaglebots 2017 Robot Base Class based on
* the Simple Robot Class.
*/
#include <iostream>
#include <memory>
#include <string>

#include <Joystick.h>
#include <SampleRobot.h>
#include <SmartDashboard/SendableChooser.h>
#include <SmartDashboard/SmartDashboard.h>
#include <RobotDrive.h>
#include <Timer.h>

// New 3rd Party API
#include "CANTalon.h"

// Debug Flags
#define DEBUG_ON 1
#define DEBUG_OFF 0

class EagleBotRobot : public frc::SampleRobot
{

private:

// Robot Drive System
CANTalon drvLF, drvRF; // Drive Motor Left/Right Front Motor
CanTalonSRX drvLB, drvRB; // Drive Motor Left/Right Back Motor -
// Had to change to SRX for proper inverse following.

CANTalon drvSF, drvSB; // Drive Motor Left/Right Sideways Motor

// Robot Control
frc::Joystick DriveStickLeft; // Driver Left Joystick
frc::Joystick DriveStickRight; // Driver Right Joystick
frc::Joystick SpecialOps; // Special Operator Joystick

// Team Functions
void EagleRobotDrive(void); // Drive the robot

// Dashboard Control - from 2017 example code.
// frc::SendableChooser<std::string> chooser;
// const std::string autoNameDefault = "Default";
// const std::string autoNameCustom = "My Auto";

public:

// Constructor;
EagleBotRobot();

/**
* Ran once to initialize the robot before competition start
*/
void RobotInit();

/**
* Drive left & right motors for 2 seconds then stop
*/
void Autonomous();
/**
* Runs the motors with arcade steering.
*/
void OperatorControl() override;


/**
* Runs during test mode
*/
void Test() override;
};


// Utility Functions

#endif // __EagleRobot_HPP__

.cpp FIle
/**
* This is Team 2838 Eaglebots 2017 Robot Base Class based on
* the Simple Robot Class.
*/
#include "EagleRobot.hpp"

const static int EAGLE_DRIVE_R_MASTER = 7;
const static int EAGLE_DRIVE_L_MASTER = 9;

EagleBotRobot::EagleBotRobot() :
drvLF(EAGLE_DRIVE_L_MASTER), // CAN Bus - NEED TO SET
drvRF(EAGLE_DRIVE_R_MASTER),
drvLB(10),
drvRB(8),
drvSF(11),
drvSB(12),
DriveStickLeft(0), // USB
DriveStickRight(1),
SpecialOps(2) //,
// chooser() // New Autonomous Control.
{

}


void EagleBotRobot::RobotInit()
{
// Setup motor followers
drvLF.SetInverted(false);
drvLB.SetModeSelect(CanTalonSRX::kMode_SlaveFollow er);
drvLB.SetDemand(EAGLE_DRIVE_L_MASTER);
drvLB.SetRevMotDuringCloseLoopEn(false);
drvRF.SetInverted(true);
drvRB.SetModeSelect(CanTalonSRX::kMode_SlaveFollow er);
drvRB.SetDemand(EAGLE_DRIVE_R_MASTER);
drvRB.SetRevMotDuringCloseLoopEn(false);


// chooser.AddDefault(autoNameDefault, autoNameDefault);
// chooser.AddObject(autoNameCustom, autoNameCustom);
// frc::SmartDashboard:utData("Auto Modes", &chooser);

}

void EagleBotRobot::Autonomous()
{
#if 0
auto autoSelected = chooser.GetSelected();
// std::string autoSelected = frc::SmartDashboard::GetString("Auto Selector", autoNameDefault);
std::cout << "Auto selected: " << autoSelected << std::endl;

if (autoSelected == autoNameCustom)
{
// Custom Auto goes here
std::cout << "Running custom Autonomous" << std::endl;
}
else
{
// Default Auto goes here
std::cout << "Running default Autonomous" << std::endl;
}
#endif
}


void EagleBotRobot::OperatorControl()
{
while (IsOperatorControl() && IsEnabled())
{
// drive with arcade style (use right stick)
EagleRobotDrive();

// wait for a motor update time
frc::Wait(0.005);
}
}

/**
* Runs during test mode
*/
void EagleBotRobot::Test()
{
std::cout << "Test Code" << std::endl;
}



// Original Baseline
#if 0
/**
* This is a demo program showing the use of the RobotDrive class.
* The SampleRobot class is the base of a robot application that will
* automatically call your Autonomous and OperatorControl methods at the right
* time as controlled by the switches on the driver station or the field
* controls.
*
* WARNING: While it may look like a good choice to use for your code if you're
* inexperienced, don't. Unless you know what you are doing, complex code will
* be much more difficult under this system. Use IterativeRobot or Command-Based
* instead if you're new.
*/
class Robot: public frc::SampleRobot {
frc::RobotDrive myRobot { 0, 1 }; // robot drive system
frc::Joystick stick { 0 }; // only joystick
frc::SendableChooser<std::string> chooser;
const std::string autoNameDefault = "Default";
const std::string autoNameCustom = "My Auto";

public:
Robot() {
//Note SmartDashboard is not initialized here, wait until RobotInit to make SmartDashboard calls
myRobot.SetExpiration(0.1);
}

void RobotInit() {
chooser.AddDefault(autoNameDefault, autoNameDefault);
chooser.AddObject(autoNameCustom, autoNameCustom);
frc::SmartDashboard:utData("Auto Modes", &chooser);
}

/*
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* GetString line to get the auto name from the text box below the Gyro.
*
* You can add additional auto modes by adding additional comparisons to the
* if-else structure below with additional strings. If using the
* SendableChooser make sure to add them to the chooser code above as well.
*/
void Autonomous() {
auto autoSelected = chooser.GetSelected();
// std::string autoSelected = frc::SmartDashboard::GetString("Auto Selector", autoNameDefault);
std::cout << "Auto selected: " << autoSelected << std::endl;

if (autoSelected == autoNameCustom) {
// Custom Auto goes here
std::cout << "Running custom Autonomous" << std::endl;
myRobot.SetSafetyEnabled(false);
myRobot.Drive(-0.5, 1.0); // spin at half speed
frc::Wait(2.0); // for 2 seconds
myRobot.Drive(0.0, 0.0); // stop robot
} else {
// Default Auto goes here
std::cout << "Running default Autonomous" << std::endl;
myRobot.SetSafetyEnabled(false);
myRobot.Drive(-0.5, 0.0); // drive forwards half speed
frc::Wait(2.0); // for 2 seconds
myRobot.Drive(0.0, 0.0); // stop robot
}
}

/*
* Runs the motors with arcade steering.
*/
void OperatorControl() override {
myRobot.SetSafetyEnabled(true);
while (IsOperatorControl() && IsEnabled()) {
// drive with arcade style (use right stick)
myRobot.ArcadeDrive(stick);

// wait for a motor update time
frc::Wait(0.005);
}
}

/*
* Runs during test mode
*/
void Test() override {

}
};

#endif

START_ROBOT_CLASS(EagleBotRobot)

drive.cpp
/**
* This is Team 2838 Eaglebots 2016 Robot Drive Class Functions
*
* showing the use of the RobotBase class.
* The SimpleRobot class is the base of a robot application that will automatically call your
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
* the driver station or the field controls.
*/
#include "EagleRobot.hpp"

// Gains to control robot drive movement
float Kdf = 1.0; // Forward Robot Gain
float Kds = 1.0; // Strafe Robot Gain
float Kdt = 1.0; // Rotate Robot Gain

// Individual drive wheel gains
float Kfl = 1.0; // Front Left Motor Gain
float Kfr = 1.0; // Front Right Motor Gain
float Krl = 1.0; // Rear Left Motor Gain
float Krr = 1.0; // Rear Right Motor Gain

// Drives the Robot
void EagleBotRobot::EagleRobotDrive(void)
{
// The following calculations are done to drive the mercanum wheels
// Calculate the following using tank drive
//
// Variables
// Yl Joystick Left Y Axis (-1.0 - +1.0)
// Yr Joystick Right Y Axis (-1.0 - +1.0)
// Xl Joystick Left X Axis (-1.0 - +1.0)
// Yf Combined Y Forward
// Yt Compined Y Turn
// Kdf Gain - Forward
// Kdt Gain - Turn
// Kds Gain - Strafe
// Kfl, Kfr,
// Krl, Krr Gains - Wheel Gains
// FL, FR, RL, RR Front/Rear Left/Right Wheel Speeds
//


#define TANK_DRIVE

#ifdef TANK_DRIVE
float Yl = -DriveStickLeft.GetY(); // Invert Y axis
float Yr = -DriveStickRight.GetY(); // Invert Y axis
#else // Arcade
// Arcade Drive using joystick rotate.
float Yf = -DriveStick.GetY(); // Invert Fwd
float Xs = DriveStick.GetX(); // Strafe
float Zr = DriveStick.GetTwist(); // Rotate
#endif

// Add Deadband
const float Deadband = 0.2;
if (fabs(Yl) < Deadband)
Yl = 0.0;
if (fabs(Yr) < Deadband)
Yr = 0.0;


// Calculate Motor Speeds -- Need to update
float LF = Yl;
float RF = Yr;

float FS = 0.0; // Need to add link to joysticks
float RS = 0.0;


// Actually set the motor controller
drvRF.Set(LF); // Note R/L back motors are followers
drvLF.Set(RF);
drvSF.Set(FS);
drvSF.Set(RS);


}


I am having errors with the joystick declaration and the GetY function and there are pother errors, I forget what they are at the moment
Reply With Quote
  #5   Spotlight this post!  
Unread 24-01-2017, 16:16
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 375
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Programming Help

Quote:
Originally Posted by loganzip View Post
I am having errors with the joystick declaration and the GetY function and there are other errors, I forget what they are at the moment
Error details (compiler/log output) would be really helpful. Also, you can use [code] tags
Code:
like this
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
Reply


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 23:52.

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