I’ve been try to figure out why my autonomous doesn’t work, I found out that it’s impossible to set motors while functions like printf still work. to make sure it isn’t something wrong with my own code, I made a new project that just runs a motor during autonomous and it doesn’t work.
Has anyone else experienced this issue? If so have you figured out how to solve the problem or work around it?
Seeing your code would help. Obviously you CAN program an autonomous in PROS (source: I have), though I don’t think you are doubting that. But yes, post your code and mention me and I’ll try to help.
Sorry that I was unclear. Could you post it here with the “code” tag? I don’t have PROS on my home computer (it’s Linux). Just post the auto.c portion.
/** @file auto.c
* @brief File for autonomous code
*
* This file should contain the user autonomous() function and any functions related to it.
*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*
* PROS contains FreeRTOS (http://www.freertos.org) whose source code may be
* obtained from http://sourceforge.net/projects/freertos/files/ or on request.
*/
#include "main.h"
/*
* Runs the user autonomous code. This function will be started in its own task with the default
* priority and stack size whenever the robot is enabled via the Field Management System or the
* VEX Competition Switch in the autonomous mode. If the robot is disabled or communications is
* lost, the autonomous task will be stopped by the kernel. Re-enabling the robot will restart
* the task, not re-start it from where it left off.
*
* Code running in the autonomous task cannot access information from the VEX Joystick. However,
* the autonomous function can be invoked from another task if a VEX Competition Switch is not
* available, and it can access joystick information if called in this way.
*
* The autonomous task may exit, unlike operatorControl() which should never exit. If it does
* so, the robot will await a switch to another mode or disable/enable cycle.
*/
void autonomous() {
motorSet(2, 127);
}
Well that’s a head-scratcher. I don’t see any problems here. You haven’t messed up anything in init.c have you? I’m not looking at init.c right now so I can’t remember if you could possibly mess anything up from there that would cause this, but maybe it would.
I assume this motor works in opcontrol.c?
Looking at the PROS kernel source code answers why the above code does not work. Here is an excerpt.
// Invoke autonomous
static void autonomous_task(void *ignore) {
autonomous();
_enterCritical();
{
// Clean up
motorControlStop();
state &= ~AUTO_RUNNING;
taskAutonomous = NULL;
}
_exitCritical();
}
autonomous exits then motors are stopped.
wow, and this has been explained to me before. If my team makes it to quarter finals we may have an autonomous.
So put a delay after starting motors (or a while loop with a delay in it)
by the way, thank you, forgot to say that in my last post.