Welcome to Bricks.SE. Yes, you can use the Power Functions equipment to teach robotics. I would recommend you stick with the original PF instead of PoweredUp, as the latter has more complicated electronics and control schemes, however, others have already built custom control software for PUp so tinkering with software is definitely possible.
Regarding Power Functions, the components have a 4 wire cable with 2 providing a constant 9V and ground, and 2 that are used for sending control signals (fluctuating values between 9V and 0V). Device identification is done through resistors, which is easy to mimick should you want to build your own motors, but this might not even be necessary as you want to build and configure your own controller. And the cable is easy to split and modify.
@Philo who is a regular here maintains a site (www.philohome.com) on which you can find a wealth of information regarding PF. This would be the best place to start.
If you are planning to use an RPi, make sure you get a suitable motor driver. You can power the motors via the driver at 9V, and use a buck converter to give your RPi 5V directly via the GPIO, just be careful because there is no overvoltage protection if used this way. Powering an Arduino or compatible microprocessor is also an option.
One word of warning: Power Functions components are retiring this year, so make sure you get your component order in from LEGO ASAP.