Skip to content

Instantly share code, notes, and snippets.

@doudou
Created April 6, 2016 11:57
Show Gist options
  • Save doudou/1357178a2262c5d85ec31e2b21562611 to your computer and use it in GitHub Desktop.
Save doudou/1357178a2262c5d85ec31e2b21562611 to your computer and use it in GitHub Desktop.
How to get a manual control definition take over any other form of control in Syskit
module Tasks
# Make sure that no control layer but ManualControl are running
class MaintainManualControl < Roby::Task
terminates
poll do
control_tasks = plan.find_tasks(Services::Control).not_finished
ready = true
control_tasks.each do |t|
next if t.fullfills?(Compositions::ManualControl)
ready = false
if !t.finishing? && t.running?
t.stop!
end
end
if ready
ready_event.emit
end
end
end
end
module Actions
class Control < Roby::Actions::Interface
use_profile Profiles::Control
describe "get manual control"
def manual_control
maintain = Tasks::MaintainManualControl.new
control = manual_control_def
maintain.depends_on(control, role: 'control_chain')
control.should_start_after maintain.ready_event
maintain
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment