Align Nav2 with physics time and preserve complete simulation scenes
This commit is contained in:
@@ -75,7 +75,8 @@ class Navigation:
|
||||
return self.node.native_command()
|
||||
|
||||
def tick(self, value):
|
||||
self.node.observe_pose(value['pose'], float(value['pose_age_seconds']), value['measured_twist'])
|
||||
self.node.observe_pose(value['pose'], float(value['pose_age_seconds']), value['measured_twist'],
|
||||
value.get('pose_simulation_time_ns'))
|
||||
with self.owner_lock:
|
||||
owner = self.command_generation
|
||||
result = self.control.tick(value)
|
||||
@@ -149,7 +150,8 @@ class Navigation:
|
||||
return self.reply('stale-observation')
|
||||
self.control.observe(value)
|
||||
if self.node.pose is None:
|
||||
self.node.observe_pose(value['pose'], age) # TF only; no invented velocity.
|
||||
self.node.observe_pose(value['pose'], age, None,
|
||||
round(value['simulation_time_seconds']*1e9)) # TF only.
|
||||
if not self.activating:
|
||||
self.activating = True
|
||||
threading.Thread(target=self.activate, daemon=True).start()
|
||||
@@ -321,11 +323,11 @@ def main():
|
||||
inputs = json.loads(Path(os.environ['MISSIONCORE_RUN_INPUTS']).read_text())
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
robot = json.loads((root/'robots'/ (inputs['robot']['robot_id']+'.json')).read_text())
|
||||
config = observed_configuration(inputs, robot, 2) # Mounted K1 and depth origins.
|
||||
config = observed_configuration(inputs, robot, 2, use_sim_time=True) # Mounted K1 and depth origins.
|
||||
parameters = Path('/tmp/missioncore-nav2.yaml')
|
||||
parameters.write_text(yaml.safe_dump(config, sort_keys=False))
|
||||
rclpy.init()
|
||||
node = RosNavigation()
|
||||
node = RosNavigation(simulation_clock=True)
|
||||
navigation = Navigation(node, inputs, robot)
|
||||
thread = threading.Thread(target=rclpy.spin, args=(node,), daemon=True); thread.start()
|
||||
terrain_reset = node.create_client(Trigger, '/terrain/reset')
|
||||
|
||||
Reference in New Issue
Block a user