More programming questions

Hi I’m here again with lots more questions. For other info I’m doing command based java code.

  • How exactly do I implement PID to a subsystem?

  • What are various ways to implement autonomous routines?

  • Where would I find out how a specific thing of code works so that I understand that for teaching?

  • Where can I find more information on inline commands along with best practices

  • What other best practices should I know for code?

  • How does soft limits work? I was able to fumble though making them work but I don’t understand it.

  • What would the best way to teach new people java be?

  • Is vision actually as simple as finding a target and making the angle of said target as close to 0 as possible? (assuming I’m using a limelight/phontonvision)

  • When does can bus overloading happen? (I’ve only heard of this) and how do I fix it if I run into it?

  • For button board programming, do I make an arduino act as a controller or does wpilib have something for that?

  • I a setpoint for a motor just PID in disguise?

  • What’s a good way to split up work in a division?

  • Where would I find answers for future questions? (besides docs.wpilib.org)

  • Where could I find a programming mentor?

gosh I love being programming lead.

1 Like

You would be better served breaking these questions down, searching for recent threads on here and if nothing comes up asking single questions that are much more pointed.

Programming can be overwhelming, so no shame in asking. There are often dozens of ways to go about things, some better suited for your specific needs.

2 Likes

A hard limit is a mechanical stop. Generally they are the end points of a mechanism (ie. top and bottom of an elevator). A soft limit is a limit enforced through software. With the elevator example, it would mean having say 2" above your lowest mechanical point and 2" below your top point be your soft stops. The elevator drives with a much lower speed in these regions (can’t be zero because if you overshoot into that region you wouldn’t be able to move out). This would need to be placed on top of any control loop you have to soften the blow from an overshooting PID.

From now till kickoff, may I highly suggest you take a breather before kickoff, it’s gonna be crazy, and a majority of your questions can be found in the “latest” installment of the wpilib docs (FIRST Robotics Competition Control System — FIRST Robotics Competition documentation)

I get the sense that ur trying to be the best informed programming lead you can be. But you don’t need to spend all ur waking hours on catching up. It’s like ur cramming for a test, and if this is indeed tru, ur on to burnout bud.

My abbreviated tips:

  1. Read read read the wpilib docs

  2. Look through all the open alliance for example command based code that you like this year. Topics tagged openalliance

  3. You won’t need to code a complete robot day 0, you may need to help your team prototype. So possibly learn how to spin a motor.

I’m only going to answer one question specifically:

Where would I find answers for future questions? (besides docs.wpilib.org)

Just google it.

I know this may come off as a little bit rude, but for most of your questions this can solve it. For example, googling “how to implement pid frc” gives at least 6 really good resources.

I will give a few more resources that will probably help though.

First, WPILib example projects are really helpful, just go to your WPILib VSCode installation, open the command palette (ctrl + shift + p), go to WPILib: Create a new project. Select example, your language of choice, then choose the example you want to look at.

The FRC 0 to Autonomous YouTube channel covers a lot of useful information as well.

Finally, to echo what @vargoose84 said, don’t worry about knowing everything there is to know about FRC programming. Learn what you need to learn, when you need to learn it.

3 Likes

A general checklist that applies for many of your questions:

  1. Read the WPILib Docs, https://docs.wpilib.org/

  2. Get familiar with reading/navigating the WPILib API Docs (javadocs), Overview (WPILib API 2023.4.3)

  3. Check out the Command Based Example Projects (many of your “How do I implement X” questions especially are likely covered here), WPILib Example Projects — FIRST Robotics Competition documentation

  4. Do 1-3 for each relevant Vendor Lib (REV, Phoenix, NavX, etc.). I know REV especially has a lot of good example projects for how to do things with the SparkMAX over CAN.

  5. Find code from other teams in GitHub, and check out what/how they are doing things

See above for where to learn about the things.

As for understanding the code you are reading, the more familiar and comfortable you get at programming and problem solving, the easier it gets to read and understand another’s code, making assumptions about library and function/method calls based on names and such, until you can go back and make sure those calls do what you assumed they did.

This has been the question I have been working on answering for the last 10+ years. I do not have a good answer, especially because I am not a good teacher. Specifically I am not good at presenting loads of information in a format that makes it easier to understand. I can however explain concepts and answer specific questions. So for 3468, its mostly come down to, those who are self-motivated will spend the time on their own figuring things out and asking questions, and the rest will either limp along until enough sinks in, or leave the programming department. I wish I could increase the retention of our rookie members, but sadly as a Mentor, I just do not have the time or resources to do so.

Devices on a CAN Bus take turns sending and receiving data. When you are sending so much data that not everything can be transmitted in a timely manner, you are saturating the bus. You can also negatively impact this phenomenon if your bus isn’t properly biased (missing the terminating resistors), is extremely long, or has long extensions off the “main bus” that can introduce signal reflections which slows how quickly data can be sent because extra effort is spent understanding the data.

Physically, making sure your CAN Bus is properly terminated, is as short as is reasonable, and any stubs/extensions off the main bus are as short as possible can all improve the overall performance of the bus. In Software, limiting the amount of CAN Data send can alleviate an overload. Common examples include sending the same setpoint over and over every loop, or reading sensor data every loop. Slowing those actions down can greatly reduce the load on the Bus.

There are several ways this can be done. The way I’ve always done is using a Library like GitHub - MHeironimus/ArduinoJoystickLibrary at version-2.0 to make an Arduino emulate a HID Joystick with code like this from 3468’s 2020 code InfiniteRecharge/arduino_gamepad/InfiniteRechargeOperatorConsoleGamepad/InfiniteRechargeOperatorConsoleGamepad.ino at master · frc3468/InfiniteRecharge · GitHub

Just make sure you are using the correct type of Arduino for the Library. Usually you need one of the ATMega32U4 based board like the Leonardo or Pro Micro.

PID/F is just a control loop system for attempting to reach a setpoint. There are other algorithms that attempt the same thing such as bang-bang. The term “setpoint” is independent of PID, though within FRC, I’ve only once seen anyone using any control loop mechanism that wasn’t PID or Bang-Bang. If you are talking about giving a motor a setpoint over CAN, then generally in that case you are using a PID Controller that is running on the Motor Controller itself, refer to the docs for the relevant Motor Controller.

I assume you mean splitting up the coding work? A Kanban board can be a good way to split up tasks for the robot/code and keep each person working on one thing at a time. Think like a bunch of sticky notes, one for each task, with columns for TODO, IN PROGRESS, and DONE that you move the sticky notes between as they are worked.

This tends to be very difficult unless you happen to have the parent of a member who is a programmer. You could try reaching out to any local companies that you know would do some amount of programming and ask them if they’d ask if any of their employees would be interested.

I have been the sole Programming Mentor in Northeast Louisiana for the last 9 years, which at one point consisted of 5 teams, of which I tried to help all as much as I could. This is the first year I have a second Programming Mentor on 3468, but I am also working equally with another Rookie team in the region, and she will be moving out of state after this year. After which point, we’ll be back to one. I’ve tried inviting and even guilting co-workers and friends into joining, but most just aren’t interested either because they don’t want to work with kids, or they don’t want to put in the time investment.

2 Likes

Looks like this should have been listed as your first question.

You have an overwhelming number of good questions and a couple of responders have spent a lot of time with thoughtful answers. You can use a lot more help than can be expected from this forum. You need a mentor and both you and the mentor should start reading, at least skimming, the WPILib/FRC from 0 to robot documentation as suggested.

This is where you get mentors:
Ecolab/Caztek Engineering/BigR Stores/Leidos/MetroSpec/Cray/LCS Company/BW Systems/Vic & Mary Holec/Diesel Dogs/ICS Consulting & Henry Sibley High School

I assume some or all are located near you and could help in-person. Take your list of questions and practiced speech of what you are asking for to whomever sponsored you. I’ve seen monetary sponsors step up to help teams that are struggling with lack of expertise.

I recognize one of the sponsor’s name as one of the most famous super performance computer companies. Maybe they are related and still can help you with control engineering and programming.

Maybe Caztek Engineering, for example or another sponsor, would spend 4 hours with you one day soon and go over your questions and what’s presented in the WPILib/FRC documentation. Maybe one will even mentor your team for the build season.


This was answered herein but I’ll use it as an illustration. Fumbling through and making them work is how I do most of the robotics learning. My team has a couple of plastic tubs with basic components of roboRIO, radio, VRM, motor controllers, camera, gyro, PDP, relay, potentiometer, limit switch, power supply, pneumatics controller sometimes. We do a lot of “experimentation” by writing a line of code and seeing it work or respond to the electromechanical components.

You say. “I fumbled and got something to work” - that’s at least 99% of the process. A few more seconds of explanation and you’ve completed that lesson.

I and others, I’m sure, would be happy to help you more but I can’t figure out how to interact with students remotely and maintain the Youth Protection Program guidelines. Another significant problem is we’re starting from 0 rather late as have some other teams that have posted on CD recently. I have my team meetings starting tomorrow and that will certainly conflict with your team meetings. But again, 4 hours with an expert can go a long way to helping you understand.

Good Luck this season. You’ve made a great first step in defining your needs and asking for help. A budding engineering manager for sure!

Its less that I need to know this before kickoff but more that these are questions I have and I’ve just got around to asking them now. I’m mostly just trying to take the next step for my learning

I’ve watched the 0 to autonomous (that’s why I’m not asking how PID works). I’m mostly just asking questions that have slowly piled up over last year. (either about things that I have implemented or at least looked at)

1 Like

Great thanks for the info but I do have to ask, when you say Henry Sibley High School do you mean getting a programming teacher to be a mentor? (so basically see if you can get the school to help out?) also we are already sponsored by Ecolab so I could go ask some of our mechanical Ecolab mentors to see if they could find a programming one

I just copy/pasted your sponsors I see from following the links associated with your name. I don’t know anything about those organizations except Cray is famous but likely now nothing like the Cray of yesteryear. I did Google Caztek Engineering and it looks like a small company that is willing to get into anything. Teachers are a great resource - they already know the material, the students, and how to teach!

If the answering posts here still leave you with some open questions, I suggest listing your questions in your priority order and maybe we all can pick off a few more of them soon enough for you.

I know someone suggested taking a break from this until kick off but I’ll point out to any highly motivated student that spending 2 or 3 4-hour days reading the WPILib documentation will get you very immersed into the subject matter and especially when you can then try out some code on a roboRIO or old robot.

My team’s software group knows very little and needs all the programming practice they can get, however, I suggest the priority for the whole team including software is everybody works on the game analyses, design ideas, prototypes, etc., the first week. The software team has good ideas to contribute and can help design the robot and strategy. If you don’t have a robot to compete with you won’t need the software team.

2 Likes

Ah that’s fair! Although I think that once you get into the actual game your programming questions will be less hypothetical and more applicable to the robot you want to build. So questions like PID, and soft limits and autonomous are game specific and I believe once you know WHAT you want to do, you’ll be able to ask specific questions that the community can answer.

If you haven’t already, and you have the time, implement a source control method for your team (i.e. github) so that the online virtual community can help you out.

This is a long shot, but have you perused this, for mentors? I honestly don’t know if it’s effective or not.

I promise, even when the season starts, if you have code that is posted we can help you debug!

huh not sure why some of those are on there so far as I know not all of those are current sponsors… part of why I was confused

Right.
And the answers will be better and faster coming if these guidelines are followed.
Sorry, the long thread chockful of great suggestions has not been edited.
https://www.chiefdelphi.com/t/how-to-ask-questions-about-programming/415365

@vargoose84 prompted this edit:
When it first came out I tried the Mentor Network. It didn’t work out well for me for a few reasons. Others have had some success. (Very few interested in remote help and none locally; only serious request of me expected to violate YPP guidelines to provide remote help directly to one student; terrible message management system that didn’t notify you if there was a message on their private system (no interface at all to email, etc.)

There is also the Senior Mentor Program . Their mission doesn’t seem to precisely fit the situation but I’m for asking anyone for help and you might get some valuable hints on how to proceed.

1 Like

image
I followed the link from your S SammyPants icon

1 Like

ah I see. but as I said I know we have Ecolab, maybe some others I would be completely unsurprised if that page was out of date

yeah looking at this some of my questions could probably be improved…
looking at that post there it seems to boil down to:

give all the info possible just asking “help me this motor won’t run” won’t get an answer (and at this point with my experience I really should know better than to do that)

you aren’t the king of the world other people are smarter than you

actually try stuff before you go ask here (I have somewhat done stuff with these questions but some of them I can’t try things for or any searching I have done just gets me flame resistant clothing (dangit frc)

1 Like

oh and I guess I should expand upon this… basically last year’s lead programmer made soft limits in this file and when I originally copied it the motors would try to run but something was stopping them (I’m wondering now if the two motors running it were going in opposite directions) so I just commented it out. Eventually I came back to this and found absolutely nothing on the wpilib docs about it so I basically just tried to understand it given the parameters and it worked. Again this is more of I want to understand how something works instead of how to make something work.

Third Party Vendors have their own documentation and own syntax and extensions to the basics. Check out the CTRE or Rev or whatever your vendor is of your motor controller.

ohhh right those soft limits are part of the talon library so ofc it wouldn’t be on the wpilib docs… and this is why I asked where to find info