I'm trying to utilize some of the unused servo ports on the NyBoard to add additional functionality to Bittle. I have one servo hooked up to port 0 (the head port), and one hooked up to port 2 (where the tail would be connected). I have two questions:
1)
For the servo connected to port 2, I have defined this skill: const int8_t pher[] PROGMEM = {
-2, 0, 0, 1,
0, 0, 0,
0, -80, -90, 0, 0, -3, 3, 3, 75, 75, 75, 75, -55, -55, -55, -55, 4, 0, 0, 0,
0, -80, 0, 0, 0, -3, 3, 3, 75, 75, 75, 75, -55, -55, -55, -55, 4, 0, 0, 0,
};
Which is located in InstinctBittle.h. The strange thing, is that when I call this new skill, sometimes the servo moves counter clockwise, and sometimes clockwise. Is there a way to ensure the servo moves in the same direction each time?
2)
For the servo connected to port 0, whenever Bittle does any other action such as walking, crawling, etc., the servo moves a few degrees back and forth. I have changed all the other skills in InstinctBittle.h to have 0 for the angle of port 0, however this didn't do anything. Is this oscillation defined somewhere else for this port that I can adjust to eliminate this behavior?
I think you modified the servo angle of the joint index 1(Pin 11 on the NyBoard) and 2(Pin 4 on the NyBoard), as following:
I'm glad to see you cracking the tricks in the code. The two are designed behaviors and can be modified.
The behavior is defined by src/skill.h => loadFrame() => mirror(). When calling a pre-defined skill in instinctBittle.h, it will randomly mirror the direction. It can be specified by adding an L or R suffix. For example, kpher may randomly pick a direction, but kpherL and kpherR will be certain.
The oscilation is defined in skill.h => perform():
if (!manualHeadQ && jointIndex < 4) { duty = (jointIndex != 1 ? offsetLR : 0) //look left or right + 10 * sin(frame * (jointIndex + 2) * M_PI / abs(period));
It can be disabled by entering 'i' or 'I' instructions. For example, after setting 'i0 0', human inputs will take over the auto oscillation. It's useful to control the camera while the robot is walking. It applies to the first four joint indexes. You may also disable the line with the sin() function. manualHeadQ is altered in reaction,h.