Skip to content

Commit

Permalink
rebuild bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Oct 18, 2024
1 parent cf3fec8 commit c4c2f40
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion actuator/rust/bindings/bindings.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PyRobstrideMotorsSupervisor:
total_commands: int
actual_update_rate: float
serial: bool
def __new__(cls,port_name,motor_infos,verbose = ...,target_update_rate = ...): ...
def __new__(cls,port_name,motor_infos,verbose = ...,target_update_rate = ...,zero_on_init = ...): ...
def set_position(self, motor_id:int, position:float) -> float:
...

Expand Down
23 changes: 21 additions & 2 deletions examples/wasd_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@ def main(stdscr: curses.window) -> None:
parser.add_argument("--motor-type", type=str, default="04")
parser.add_argument("--second-motor-id", type=int, default=2)
parser.add_argument("--second-motor-type", type=str, default="01")
parser.add_argument("--zero-on-init", action="store_true")
parser.add_argument("--max-update-rate", type=float, default=1000.0)
parser.add_argument("--kd", type=float, default=1.0)
parser.add_argument("--kp", type=float, default=10.0)
args = parser.parse_args()

motor_infos = {args.motor_id: args.motor_type, args.second_motor_id: args.second_motor_type}
supervisor = RobstrideMotorsSupervisor(args.port_name, motor_infos)
supervisor = RobstrideMotorsSupervisor(
port_name=args.port_name,
motor_infos={
args.motor_id: args.motor_type,
args.second_motor_id: args.second_motor_type,
},
target_update_rate=args.max_update_rate,
zero_on_init=args.zero_on_init,
)
supervisor.add_motor_to_zero(args.motor_id)
supervisor.add_motor_to_zero(args.second_motor_id)

Expand All @@ -30,6 +41,11 @@ def main(stdscr: curses.window) -> None:
stdscr.nodelay(True) # Make getch non-blocking
stdscr.clear()

supervisor.set_kd(args.motor_id, args.kd)
supervisor.set_kp(args.motor_id, args.kp)
supervisor.set_kd(args.second_motor_id, args.kd)
supervisor.set_kp(args.second_motor_id, args.kp)

try:
while True:
time.sleep(0.01)
Expand All @@ -45,6 +61,9 @@ def main(stdscr: curses.window) -> None:
position_motor_2 += normal_step_size # Move motor 2 clockwise
elif key == ord("s"):
position_motor_2 -= normal_step_size # Move motor 2 counter-clockwise
elif key == ord("q"):
supervisor.stop()
break

# Set target position for both motors
supervisor.set_position(args.motor_id, position_motor_1)
Expand Down

0 comments on commit c4c2f40

Please sign in to comment.