Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Fabien-B/robotSim
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien-B committed Jan 11, 2021
2 parents 74783c0 + 6745f0a commit ba372bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion ivy_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
POS_REPORT = "PosReport {} {} {} {}"
ACTUATOR_REPORT = "ActuatorReport {} {} {}"

KILL_CMD = "Shutdown {}"


class IvyInterface(Interface):

Expand All @@ -23,10 +25,12 @@ def __init__(self, robot_name, bus=BUS):
IvyInit(robot_name, robot_name + " ready!")
self.rid = robot_name
self.bus = bus
self.running = True
IvyBindMsg(self.on_speed_cmd, SPEED_REG.format(self.rid))
IvyBindMsg(self.on_pos_cmd, POS_REG.format(self.rid))
IvyBindMsg(self.on_pos_orient_cmd, POS_ORIENT_REG.format(self.rid))
IvyBindMsg(self.on_actuator_cmd, ACTUATOR_CMD.format(self.rid))
IvyBindMsg(self.on_kill_cmd, KILL_CMD.format (self.rid))

def start(self):
IvyStart(self.bus)
Expand Down Expand Up @@ -76,4 +80,5 @@ def on_pos_orient_cmd(self, sender, x, y, theta):
pos.theta = float(theta)
for cb in self.cbs.get(m.PosCommand, []):
cb(pos)

def on_kill_cmd (self,*args):
self.running = False
4 changes: 2 additions & 2 deletions simu_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def update_actuators(self, dt):
self.com.report_actuator(ac)

def run(self):
while True:
while self.com.running :
self.update()
time.sleep(0.01)

self.com.stop ()

if __name__ == '__main__':
if len(sys.argv) != 2:
Expand Down

0 comments on commit ba372bd

Please sign in to comment.