anthony
USA
Asked
— Edited
I am trying to move my servos for my head on my robot. I read that I have to release the servos before allowing them to move. I did exactly that and nothing appears to happen. I played with the position and speed and it still does not work. The robot is laid out like a Roli without the arms. THe servos are the ones for the neck. I am wondering if there is anything I did not see or failed to see.
using System;
using EZ_B;
public class HelloWorld {
static EZB _ezb;
public static void Main() {
_ezb = new EZB("Test");
Console.WriteLine("Connecting to EZ-B v4...");
_ezb.Connect("192.168.1.1");
if (!_ezb.IsConnected) {
Console.WriteLine("Unable to connect to EZ-B v4");
return;
}
else{
_ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D9, Servo.SERVO_CENTER);
}
Console.WriteLine("Hello World, I am moving servo d0 to position 90!");
_ezb.Servo.ReleaseAllServos();
_ezb.Servo.SetServoPosition(Servo.ServoPortEnum.D9, 140);
_ezb.Servo.ReleaseAllServos();
Console.WriteLine(_ezb.Servo.IsServoReleased(Servo.ServoPortEnum.D9));
Console.WriteLine(_ezb.Servo.GetServoPosition(Servo.ServoPortEnum.D9));
Console.WriteLine(_ezb.HC_SR04.GetValue(Digital.DigitalPortEnum.D21,Digital.DigitalPortEnum.D22));
_ezb.Movement.MovementType=EZ_B.Movement.MovementTypeEnum.HBridge;
_ezb.Movement.HBridgeLeftWheelTriggerA=EZ_B.Digital.DigitalPortEnum.D1;
_ezb.Movement.HBridgeLeftWheelTriggerB=EZ_B.Digital.DigitalPortEnum.D2;
_ezb.Movement.HBridgeRightWheelTriggerA=EZ_B.Digital.DigitalPortEnum.D3;
_ezb.Movement.HBridgeRightWheelTriggerA=EZ_B.Digital.DigitalPortEnum.D4;
_ezb.Movement.GoForward(254);
}
}
The WriteLines say that the servos did move and are released.
On a side note, how do I get the robot to move via the motor controller, Am I heading in the right Direction.
There's no thread sleeps to give the servos time to move. Remember, you're code is software but you are controlling hardware. The hardware exists in the physical world and therefore you will need to compensate for the time it takes to move.
Lastly, you must move/initialize a servo into position before the servospeed command can be used. You can't move a servo at a specific speed if it doesn't have an original position. It's a chicken and the egg scenario... which came first? In this case, the position must always come first.