PROS Example Project

#1

Would anyone be willing to post an example project of how to set up a pros project? I’ve scoured the forums and github and I haven’t found anything useful in terms of setting up a simple project. This is mainly for reference, I just want to see how you would set up motors and methods in a header file so you can call and access those in any source files you create.

I’ve been struggling to get working code on my chassis because I have an entangled mess with all my files and it would be very helpful to base my project off of something simple.

P.S. I’ve had my project reviewed by various people and their explanations haven’t been helpful, I’m more of a visual learner.

0 Likes

#2

add config.hpp in include folder and add following line to i src/initialize.cpp

#include “main.h”
#include “config.hpp”

pros::Controller master (pros::E_CONTROLLER_MASTER);
pros::Controller partner (pros::E_CONTROLLER_PARTNER);
pros::Motor leftfront (6, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor leftback (7, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor rightfront (9, pros::E_MOTOR_GEARSET_18, true, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor rightback (10, pros::E_MOTOR_GEARSET_18, true, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor lift (20, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor claw (14, pros::E_MOTOR_GEARSET_18, true, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor ballintake (19, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor catapult (13, pros::E_MOTOR_GEARSET_36, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::ADIDigitalIn limitswitch (1);
pros::ADIAnalogIn potentiameter (2);
pros::ADIGyro gyro (3);
pros::ADIDigitalIn limitswitchball(4);

0 Likes

#3

config.hpp

#ifndef CONFIG_H
#define CONFIG_H

extern pros::Motor leftfront ;
extern pros::Motor leftback ;
extern pros::Motor rightfront ;
extern pros::Motor rightback ;
extern pros::Motor lift ;
extern pros::Motor claw ;
extern pros::Motor ballintake ;
extern pros::Motor catapult ;
extern pros::Motor flipper ;
extern pros::Controller master; // master control
extern pros::Controller partner; //partner control
extern pros::ADIAnalogIn bumper; // not use yet
extern pros::ADIAnalogIn potentiameter; //potentiameter for claw
extern pros::ADIGyro gyro;
extern pros::ADIDigitalIn limitswitch ; //limitswitch for arm lift
extern pros::ADIDigitalIn limitswitchball ; //limitswitch for ball shoot

#endif

0 Likes

#4

Would this give you access to call motors and methods in all other files just by #include “main.h”? (Since main.h and initialize are linked together)

0 Likes

#5

you will need to #include “config.hpp” in all other files.

0 Likes

#6

If you want to draw to the screen and learn how to use LVGL here is a tutorial.

0 Likes

#7

I still get an error when I do that.

This code I have to is all on this repository on GitHub. I’m still getting an error when I call the motor in the autonomous.cpp file even though I included it.

0 Likes

#8

I think my computer may be glitching out or something because now it recognizes the motor exists. I’m not 100% sure it will work since I haven’t uploaded it to the brain. Hopefully it does. Regardless, it would be nice if someone could review it.

0 Likes

#9

You never include anything in that code. You also have no code in autonomous.cpp. Maybe you have not pushed recently?

0 Likes

#10

I’ve been working on an example project it’s still a WIP but here it is hope it helps.

2 Likes

#11

I’ve updated the repository, for some reason it didn’t update the files when I uploaded them. Anyways, will putting method headers in the config.hpp of methods created in source files (.cpp) allow me to access those methods by #include the header file in other source files? (wording of question is a bit confusing)

0 Likes

#12

the autonomous has a motor moving for an indefinite amount of time. Again, the purpose of this project is sort of a proof of concept as I’m switching from VCS, I just need to understand how linking files works with this IDE and pros API.

0 Likes

#13

you should keep
#ifndef CONFIG_H

#endif

0 Likes

#14

#pragma once does the same thing, no?

0 Likes

#15

When I downloaded the program on the v5 brain, nothing happens, as in, no motors move. And I get a JSON error but it doesn’t indicate what’s causing that.16%20AM

0 Likes

#16

We’ve gotten a couple reports from various folks using macOS. We haven’t been able to reproduce the issue and are looking for someone to help us do some troubleshooting on our Slack or on GitHub. If you could join and help us do some diagnosis so we can fix the issue, that would be appreciated.

I’m on my phone right now - I will share the Slack invitation/GH issues when I get home if someone doesn’t beat me to it.

1 Like

#17

Here it is =)
https://github.com/purduesigbots/pros-cli/issues
and
https://pros-development.slack.com
Do you need an invitation?

1 Like

#18

#pragma once does the same thing, no?

Yes. It should.

0 Likes

#19

Yeah I’d be willing to, what I am supposed to do to assist?

0 Likes

#20

This is the issue tracking what you’re experiencing - it has some instructions there.

0 Likes