Not sure, it may depend on a couple of different things like:
Where you call it in the setup() function. It for sure would need to be called after g_ServoDriver.Init(); call.
But I think it probably is because when the robot first starts, we have g_InControlState.fHexOn having a false value, so the code toward the end of the main loop function will end up calling g_ServoDriver.FreeServos(); which for the SSC-32 blindly tells all 32 servos to move to 0 (or stop sending signals…) , which defeats your call in setup.
In that case, it should be working I think, but none of the head servos seem to be engaged at all. Do I have to add them to the config file somewhere?
EDIT: Putting the code at the end of setup() seems to have worked, but I’m still not sure how to actually set the head up as a leg so that it will move with the body as mentioned before.
As I was mentioning, when the Hex is logically turned off (which is the case at startup), the code tells the SSC-32 to release all of the servos and it keeps doing so, until you hit the start button. The idea is sort of two fold, one is if you hit the start button to stop the robot, it may be doing something bad, like leg crashing into something, and so you want the robot to stop. Also it releases the servos as to conserve battery power. However this does not work for most digital servos. That is a hitec digital servo will continue to hold the position of the last valid pulse even after the pulses are removed.
So the question is do you want the head servos going somewhere or holding somewhere when none of the other servos are active. If so would need to probably modify the FreeServos function. Could probably hack in a FreeServos exclude mask that is optionally added to config file. Where if a bit is set or not set in this mask, the corresponding servo is not freed.
Alternatively you could not have these servos do something at this point, but instead have them activate like the other servos when the start button is pressed.
Having them activate when the start button is pressed just like all the others is just fine, but where would I set that up? It appears to lock them in place when I do a moveSingleServo() in the setup method. Before it did nothing, they remained at 0 with no power no matter what I did to the bot. Is there a registry of servos somewhere that they have to be entered in?
Completely separate question: earlier someone mentioned setting up the head as another coxa joint so that it would turn while the bot turns. Any ideas how that might be accomplished?
[/code]
Note: Should update this slightly as redundant check of fHexOn… However this is where in the code that starts the update for servos where it detects that the robot is on, but was not on before… So could add call out to your head stuff…
As for Head as other coxa? Not sure, I know in the A-Pod code there is code to position the code to position head depending on where the body is… But I have not merged any of Zentas A-Pod (BAp code) into the C code base yet. Did not have test setup for it. Although I could now potentially build a version that would run on the Fire-Ant, but currently running their stuff on it.
Yes you could do it that way but again we don’t really want the head to act the same as a leg.
I would just simply define the two servos in the code and then have them read the joystick inputs then write that to each servo.
Would you mind giving me an example of writing the joystick inputs to each servo? I’ve been digging through the code all day and I’ve got a little fog-of-brain
As far as I can tell, PSS_RX is the left/right motion of the right stick, and PSS_LY is the up/down motion of the left stick. Might have to tweak these so the tilt servo comes into play on the translate mode only.
Yes looks good.
Its jittery like that because we are using the ps2 and its resolution is not very good. But its the quickest way to integrate that kind of control to a pan and tilt.
The best way is to have the ik involved. Once i get setup ill try inputting that into your code.
Its quite simple. And uses the first method i mentioned.