We can build, deploy and run the BuiltinDefault project and it works as expected. The SimpleTemplate project does not run the motors. We printed out the joystick inputs and they look correct. Anyone else have the same issue?
Are the motor ports correctly set to match your robot?
Brad
Left and right are connected to PWM 1 & 2 - the BuitinDefault example project works w/o touching the hardware.
Would you mind posting the SimpleTemplate-based code which does not work?
I’ll post the code when I get back to our lab. But it is the SimpleTemplate example with NO alterations.
I know this sounds weird. We must be missing something simple. I did not beleive the students when they first asked for my help. But I’m an expert with Workbench and VxWorks and I can’t see why it should not work. The BuiltinDefaultCode project works but the SimpleTemplate does not. We can load one right after the other and reproduce this every time so we KNOW there are no hardware configuration issues.
Could it be the safety functions? That is the only real difference in the 2 examples.
Thanks
The SimpleRobotTemplateProject does not include any code to read sensors, drive wheels, etc. It’s only a template for a project, not an example. It will do nothing.
To make this do something, you will need to create your own motor objects and joystick objects. There’s a method called operatorControl() in the code included within the SimpleRobotTemplateProject; this will be called when the robot enters teleoperated mode. Put your code there.
Take a look inside the sample projects or look at the documentation for WPILib to see how this works.
Paul,
The C++ simple Template code does indeed contain code for doing arcade drive of a two motor robot.
Keith,
Are you seeing any errors in the Messages box on the Driver Station Diagnostics tab?
My apologies, I mostly work with the Java branch of WPILib, and nothing is included in the equivalent SimpleRobotTemplateProject in that world. Ignore my previous post.
Have you tried using the NetConsole to look for errors? You can enable this from the FRC cRIO Imaging Tool, and then run the NetConsole on your laptop. In some cases error messages will appear there.
Thanks for the input guys. There are no messages coming from the console after the code starts up (but I have not run it from the debugger yet) . I am thinking it has something to do with the safety functions but have not gotten back to the lab to try anything new.
We do not use SimpleTemplate for anything on the competition robot. Our “real” code is built directly on the RobotBase classes and uses multi-tasking and a message system (using VxWorks msqQLib) to implement all the competition features. Our rookies built the kitbot at a QuickBuild session and were trying to practice some programming skills.
This the code for the simple robot template project.
#include “WPILib.h”
/**
- This is a demo program 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.
*/
class RobotDemo : public SimpleRobot
{
RobotDrive myRobot; // robot drive system
Joystick stick; // only joystick
public:
RobotDemo(void):
myRobot(1, 2), // these must be initialized in the same order
stick(1) // as they are declared above.
{
myRobot.SetExpiration(0.1);
}
/**
* Drive left & right motors for 2 seconds then stop
*/
void Autonomous(void)
{
myRobot.SetSafetyEnabled(false);
myRobot.Drive(0.5, 0.0); // drive forwards half speed
Wait(2.0); // for 2 seconds
myRobot.Drive(0.0, 0.0); // stop robot
}
/**
* Runs the motors with arcade steering.
*/
void OperatorControl(void)
{
myRobot.SetSafetyEnabled(true);
while (IsOperatorControl())
{
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
Wait(0.005); // wait for a motor update time
}
}
};
START_ROBOT_CLASS(RobotDemo);
A couple of things to check:
In the code, make sure your speed controller declarations match the speed controllers your using. (Victor, Jaguar)
Make sure the digital side car shows 3 green lights in the area that shows 5v.
If it does not then your missing the digital side car power.
Make sure the side car cable is tight on both sides.
Make sure the modules are in the correct slot.
If you tried the above then try a new side car.
If still having problems then try changing the actual module.
Also check side car data cable to see if you got one of the ones that need the rework:
http://www.usfirst.org/sites/default/files/uploadedFiles/Robotics_Programs/FRC/Game_and_Season__Info/2012_Assets/DB37%20Ribbon%20Cable%20Assembly%20-%20Rework%20Instructions.pdf
Thanks for the advice! But note from comments above that the BuiltinDefaultCode project works w/o any hardware changes. It can’t possibly be a simple hardware issue.
Yes, you are correct, but my suggestions are based on common mistakes putting together the hardware. And the second post is based on a mistake from whom ever put the data cables together for First. The default project would work the first time every single time if humans never made mistakes.
Except for the declarations part and dout that is a problem.