|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
This is the newbie alert for anyone who is very knowledgeable in C++. ANY C++ PROGRAMMERS ARE ENCOURAGED TO VISIT AND REPLY IN THIS THREAD. IF YOU ARE A PROGRAMMER FOR C++ AND CAN HELP, PLEASE DO SO
I was kind of thrust into the job of programmer for this year's 2012 FRC. Things worked out pretty well for the FTC because we were using ROBOTC and I could therefore use shortcuts like "catalysts" to take care of everything an experienced programmer can usually do, but because FRC robots don't use ROBOTC as a programmable language, I have to start from scratch and get a workable program set up before mid-March, preferably before the end of February. I think I can officially say I have no idea what I'm doing. If anyone who knows a lot about Wind River and C++ is within the sight of my text, I implore you to help a fellow programmer figure out what to do.A simple program to run arcade mode and a couple of motors on a Logitech controller for the Teleop program, basic robot-programming related Wind River info (such as where the compiler is and where I go in the program to see my lines of code)... Anything would be extremely helpful right now, preferably an arcade tank drive program at least. Many thanks from Team 1691, --Gondorf5-- The ultimate swordsmaster is NOT the ultimate programmer for C++ ![]() |
|
#2
|
|||
|
|||
|
Re: Newbie Alert. Our robot is competing, and I can't program it.
If you have installed the software (in KOP) properly you should find a very simple drive template. GoTo (from the main compiler screen): "File -> New -> Example... ->-> VxWorks Downloadable Kernel Module Sample Project -> -> FRC Simple Robot Template.
This demonstrates declaring 1 joystick and driving forward during Autonomous and driving Arcade for Teleop. That can get you started. |
|
#3
|
||||
|
||||
|
Re: Newbie Alert. Our robot is competing, and I can't program it.
Start with a sample program that's provided with WindRiver (assuming you have installed the workbench update for FIRST). I don't have WindRiver in front of me, so I am reciting from memory. Do File->New->Example Program then something about kernel module example, FIRST or something like that. There are many sample programs. You may want to try the "SimpleRobot" template. It should contain basic teleop code. I think it might even has a couple lines in autonomous driving the robot forward for 2 seconds or something like that.
|
|
#4
|
|||
|
|||
|
Re: Newbie Alert. Our robot is competing, and I can't program it.
Quote:
What kind of end effectors do you need to control? Considering ship is tomorrow, if you want to get anything beyond the basic drivetrain working, you'll need to test it. If you explain, I can give you some examples to help. Also, if you have an extra cRIO, you can test your vision processing between ship and your first competition. Not so with anything mechanical on the robot. Just saying, make sure you're smart about what you prioritize. Finally, if you need a reference of WPILib, I have one posted here: http://rbmj.github.com/612-code/doc/html/classes.html Last edited by rbmj : 20-02-2012 at 21:55. |
|
#5
|
||||
|
||||
|
Re: Newbie Alert. Our robot is competing, and I can't program it.
If you are not careful writing your code, you can stuck in a loop using the IterativeRobot template too. If you manage to prevent AutonomousPeriodic from returning, that's how you get stuck.
|
|
#6
|
|||
|
|||
|
Re: Newbie Alert. Our robot is competing, and I can't program it.
Thanks everyone for your help, which I will probably continue to ask for on this thread.
First off, I just searched Wind River like you guys suggested to try and find the Sample Robot Template, but I couldn't find it in the Kernel File. You guys mentioned a FIRST update for Wind River, and I don't think I've updated it past the initial installation. If one of you could post a link to the update, I'd be grateful. Also, I believe that I've found the Getting Started Guide for C/C++. It looks promising and I'll have to read it and try to learn more about how to use Wind River FRC-wise. So thanks again and I'll probably be asking for help again soon. --Gondorf5-- The ultimate swordsmaster is NOT the ultimate programmer. Maybe now he can get somewhere. |
|
#7
|
|||
|
|||
|
Re: Newbie Alert. Our robot is competing, and I can't program it.
When you installed WindRiver, did you install both of the CD's I believe that only installing the first causes problems.
Install instructuctions are here: http://www.usfirst.org/sites/default...bench3%203.pdf And Updates here: http://firstforge.wpi.edu/sf/frs/do/...2_update_for_c Both are found on the KOP -> Control System: http://www.usfirst.org/roboticsprogr...control-system Good Luck Programming! |
|
#8
|
|||
|
|||
|
Re: Newbie Alert. Our robot is competing, and I can't program it.
Thanks for the links, Davis. I found the update that put on the FRC templates.
And rbmj, I'm not sure what effectors are in relation to FRC robots, but right now we have 5 motors we want to run during the competition: two motors are the drive motors for arcade mode, another will rotate a "conveyor belt," a fourth will operate a ball launcher (1 direction, set to a button as a continuous loop until the button is not pressed), and the fifth will also go in one direction (I don't know exactly what it will do, it is the one part the engineers are unclear to me about. I do know it will somehow pick up the basketballs from the ground, but that's a bit irrevelant from a programming aspect). If this is unclear, ask me about it and I will do the best I can. Again, thank you all for your cooperation. My team is grateful for your help. --Gondorf5-- The ultimate swordsmaster is finally beginning to take C++ lessons. |
|
#9
|
|||
|
|||
|
Re: Newbie Alert. Our robot is competing, and I can't program it.
You'll need to ask your Electrical team if your motors are wired on Spikes or on Jaguars.
If they're on Spikes, then the relevant class is the Relay class. For Jaguars, see this. You would add motors like this: Code:
class myRobot : public IterativeRobot { //or SimpleRobot
public:
//your constructor
myRobot();
//the methods you're overriding go here
private:
Relay motor1;
Jaguar motor2;
};
//then in your constructor implementation
myRobot::myRobot() :
motor1(1), //on relay port 1
motor2(1) //on pwm port 1
{
//initialization
}
//then when you want to use them
//to set a spike:
motor1.Set(Relay::kForward); //or Relay::kReverse, or Relay::kOff
//to set a Jaguar
motor1.Set(1.0); //1.0 is full forward, 0.0 is off, -1.0 is full reverse
Plenty of teams have also open-sourced their code as well if you need to see examples. We have a huge code base, but if you're feeling ambitious, you can look at it here. And http://cplusplus.com/doc/tutorial/ is a go-to reference. As always, if you need help, you can post ![]() Oh yeah, @mickets, yes, it is possible, but you're saved from yourself a little bit more ![]() |
|
#10
|
|||
|
|||
|
Sorry it took so long to respond I've been all over the place.
Our motors are wired to a Jaguar, thank you rbmj (will the code you've provided set the extra motors to run on certain buttons? that would be very helpful to know and could you elaborate on what the constructor line of code is for? I'd like to know if the code you've provided will stand on its own or if it's algebraic, if you know what I mean). I'll do my best to make light of the code and links you've generously provided, but in case I can't find what I'm looking for, I need to set up the three extra motors to activate when a button is pressed and deactivate when the button is released. I'm probably leaving something important out, I KNOW IT, but I'm suffering from a major brain fart, so thanks again for your valuable assistance! --Gondorf5-- Restoration at: -10% :-( |
|
#11
|
|||
|
|||
|
Re: Newbie Alert. Our robot is competing, and I can't program it.
Quote:
Quote:
Code:
//put this inside your while(IsOperatorControl()) {} loop in SimpleRobot
//or your TeleopContinuous function in IterativeRobot:
drive.ArcadeDrive(my_joystick);
if (my_joystick.GetRawButton(1)) {
my_jag.Set(1.0);
}
else {
my_jag.Set(0.0);
}
|
|
#12
|
|||
|
|||
|
Re: Newbie Alert. Our robot is competing, and I can't program it.
Thanks for making that first part clear, rbmj; I wasn't sure whether or not the "myRobot();" constructor line of coding was a little confusing. It still is, but that was the one major question I can safely ask without getting to critical about your methods.
So granted that I know which joystick button goes with what button (I'm assuming that because I'm using a Logitech controller from the FTC and was using ROBOTC, the buttons should coincide with the same numeric value for C++ because C++ is a less user-friendly version of ROBOTC... I am really good at sounding like I know more than I know, I know. I know little.), I can use the command "joystick.GetRawButton(Button# here)" to tell the action motors to activate until the button is released, when which you use the "else" to command the motor to stop. Did I translate that correctly? Also, a quick question about one of your earlier posts; when using the "Jaguar.set" command, do I use "my_jag.Set(value.0);", or "motorX.Set(value.0);"? Of course, I would have to declare each motor that I plan on using under something like a void command (tell me when, where, and how I am wrong 'cause I know I'm bound to be somewhere), so motorX would be a motor that I've already declared and set aside to be the motor to suit that one purpose. ...I hope you understand at least half of this because I'm surprised to find that I don't. Oh, and to answer your question, yes; I believe something like that should do the trick. If not, I know where to find you. --Gondorf5-- Message to the forum visitors and those who've posted: Big thanks to everyone who participates on this forum page! Tell your friends who want to learn the FRC C++ essentials. I'd like to try and make this a forum page where programmer-wannabe's for FIRST can come to learn without having to wade through chest-high waves of seemingly complicated terms like "void" and "Jaguar" and "semicolon," while at the same time teaching them what they need to know to end their robot's endless-eternal-yet-inaudible-screams-of-relentless-torment... |
|
#13
|
||||
|
||||
|
Re: Newbie Alert. Our robot is competing, and I can't program it.
Find a quiet place to sit down and read this document thoroughly:
GettingStartedWithC.pdf It's located in this directory path in your C++ installation: WorkbenchUpdate20120204rev3111\docs\extensions\FRC \GettingStartedWithC.pdf Attached is the Table of Contents. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|