Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The handling of the robot in the Controller should be revised #467

Open
TwistedSim opened this issue Jun 14, 2018 · 0 comments
Open

The handling of the robot in the Controller should be revised #467

TwistedSim opened this issue Jun 14, 2018 · 0 comments
Labels

Comments

@TwistedSim
Copy link
Member

We should make sure the following code is correct in the Controller:


if engine_cmds:
for robot in self.robots:
robot.engine_cmd = None
for cmd in engine_cmds:
self[cmd.robot_id].engine_cmd = cmd
self[cmd.robot_id].path = None

This cause the engine_command the be reset each time the ai send a command to any robots. The path is also reset every time and never kept in memory. This mean that the AI need to resend the path everytime for each robot that move.


robot.path, robot.target_speed = path_smoother(robot.raw_path, robot.cruise_speed, robot.end_speed)

The path_smoothing computing a smooth path and a target speed. The smoothed path should only be computed once if the AI resend the path every frame anyway. Also, since it affected directly the robot object, it could be a instance method.


if robot.distance_to_path_end < ROBOT_RADIUS and robot.end_speed == 0:
robot.velocity_regulator.reset()
commands[robot.id] = robot.position_regulator.execute(robot, self.dt)
else:
robot.position_regulator.reset()
commands[robot.id] = robot.velocity_regulator.execute(robot, self.dt)

The position regulator could possibly be remove since the velocity regulator has stopped shaking when arriving at the target (with the PID deadzone of the derivative gain). Also, each regulator are reset every frame, which is useless except on transition.

Also, commands[robot.id] = robot.position_regulator.execute(robot, self.dt) generate a command from to robot's regulator, which is already contains in the robot. the regulator can have a reference to the robot when create the robot object. This could be simplify to: commands[robot.id] = robot.controller.execute(self.dt). But, we need to take care since each call to this function will cause an updated of the PID state (integration of error). We also need to decide if each robot object control themselve or if an external class should modify their internal states.


The method _put_in_robots_referential could be in the robot object.


The dt should be given in the execute call, not the update call:

https://github.com/RoboCupULaval/StrategyAI/blob/dev/Engine/engine.py#L132-L133

became:

self.controller.update(self.game_state, engine_cmds)
        robot_state = self.controller.execute(self.dt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant