@Chaotic Squirrel posted this in the official Q&A not realizing only certain people can answer so I thought I would re-post his question here. I am the mentor but know nothing about coding. I know he is using RobotC.
Squirrel here! just wondering if anyone can help we (621C,B)have been trying to code for a partner controller and it is being really crappy but I believe we have a good start here is the code:
@Chaotic Squirrel if it’s “being really crappy” could you specify what the issues are? I’m not a good programmer but if I know what to look for I can find basic issues sometimes
LOL. He was not too descriptive. As I recall, he was wanting to be able to have one controller do everything unless the partner controller is plugged in and then he wanted the partner controller to control the claw and the chainbar. The chainbar is on ports 5 and 6 and the claw is port 7.
He does not get to get online much at home so I thought I would stand in for him to get his question answered. I am not a programmer and am too old to learn. As the mentor, I basically heard cats.
The code looks OK to me, what kind of problem do you see? Also, it helps if the code is posted as a c o d e ] section, so it becomes more readable. I have reformatted it here for reference:
As I said, the code as such looks good, though you may want to allow both the driver and the partner to operate those mechanisms, not exclusively hand it over to the partner.
As I recall, the issue was that when the partner controller was plugged in, the master/main controller controlled things and not the partner, but when the partner controller was not plugged in, nothing controlled the arm and intake (ports 5,6,7).
I will try to find out if there was anything else. I am guessing it is something very simple.
At one point, I think they had it where either could control it, but it made the arm very jittery. It was like it was going back and forth between what the two controllers were saying. One would have zero values and the other higher values and it was like it was going back and forth and a very high frequency.
The conditions, as they are written look fine for 2nd transmitter controlling ports 5, 6 & 7.
You could also try adding some debugging code at the start (before the loop), such as:
As for both controlling it concurrently, yeah, you’d need to handle collisions and only set the motor control value once per loop iteration. Perhaps like:
This is optimized for only one of the drivers touching relevant controls, but avoids conflicts and has reasonable conflict resolution - Up (open?) on claw has precedence over down (close?), chainbar allows countering the analog value or speeding up when working in agreement.