Exercise: Sensors and Feedback¶
The main objective of this exercise is to explore feedback control. We will use both proprioceptive sensing that measures the internal state of a robot and exterioceptive sensors which measure a property of the environment. The emphasis is on applying essential control principles to individual joints and then empirically tuning parameters to observe system behaviors.
Control theory is a vast body of work concerned with stabilizing dynamic systems. Familiar applications range from a home thermostat regulating temperature to a rocket nozzle actuator stabilizing and steering a launch.
In general, a system (also called a plant or process) is stabilized by adding sensing, actuation, and a control system with either analog or digital computation. The general idea is that an unstable system can be stabilized by adding a control loop to create a composite system with new dynamics. The control system is parameterized with gains to allow tuning the controlled dynamics.
Most common definitions of robot include some element of sensing and responding to the world. In many actual robots, this sensing is purely internal in the form of control feedback which regulates movement to achieve a specified position goal, target velocity, or trajectory. This feedback uses proprioceptive sensors to measure joint positions, applies a control model to compute appropriate actuator commands for a known physical system, and then applies force via the actuators. If it works, the mechanism moves closer to the goal state and errors are reduced. If the disturbances are too great, the process can fail to achieve the target or become unstable.
The ideas behind feedback predate robotics: a classic example is the flyball governor, invented in 1788 to regulate steam engine speed. The ideas have been generalized broadly beyond mechanical systems in the study of cybernetics.
A controller ‘closes the loop’ by creating a cyclical energetic and informational pathway including both a process and a representation of that process in the controller. In this view, cause and effect is not well-defined: if the mechanism encounters a disturbance, then the controller will respond with increased torque. Likewise, if the program chooses a new position target, the controller will respond with torque. In equilibrium, both disturbances and goals affect the balance of the system, with the intent of converging in a stable way toward an objective. But the resulting behavior is the composite of both ‘intent’ and ‘reaction’.
One outcome is that even simple feedback-controlled devices can be easily interpreted as ‘alive’ or having ‘purpose’ in the right context, and this effect is what this exercise is intended to explore.
Relevant terms: proportional control, PID control, degree of freedom (DOF), closed-loop control, position target, goal, disturbance, error signal, stability, bandwidth, lag, set point.
Contents
Objectives¶
After this exercise, you should be able to:
Tune the gains of a single-axis PD servo.
Attach a simulated external range sensor to a simulated robot.
Formulate a set of single-axis control functions to produce reactive behavior.
Reference Guides
Please review the following reference guides as needed:
Assigned video lecture clips.
Documentation on the sample robots:
Resources
The sample Webots project is a package of files and folders provided as a zip file controls.zip.
The course Piazza is a good place to collect and answer questions.
Part 1: Setting Clock Gains¶
The objective is to experiment with a single-axis controller and discover the relationship between proportional and derivative gains. This isn’t meant to take more than a few minutes.
Please follow these steps:
Open the controls-sample.wbt world file.
Focus your attention on the clock. Please note you can right-click it and select “Move Viewpoint to Object.”
Run the simulation once: you should see the hands slowly converge to the current wall clock time after a lot of oscillation.
Open the controller code. Please note you may right-click on the clock in the scene tree and select “Edit Controller Code.”
Find the initialization of the P_gain and D_gain variables.
Try a damping (D_gain) of 0.05, restarting the simulator to observe the start-up transient.
Experiment a bit with both P and D gains to see the outcome, restarting the simulator each time. E.g., what happens with a negative D_gain?
What P and D would you choose, and for what effect?
Part 2: Adding a Sensor and Environment¶
The objective is instrument a robot for a chosen task and implement a switching or linear controller. You may either use the provided models or add instrumentation to your own. You may also add fixed or movable objects or other robots to create the task.
The ultimate objective is to create a situation with rich enough dynamics both in terms of the device physics and the control programs that surprising behavior may naturally emerge. This can take some experimentation.
Please follow these steps to start:
Open the controls-sample.wbt world file.
Examine the left two-link robot in the scene tree. It was generated using the two-link.proto file, so the structure is not shown, just the user-accessible parameters.
Try right-clicking the robot and selecting ‘Convert to Base Node(s)’. The robot should be expanded into a full node tree.
Locate the DistanceSensor node. It is one of the children of the link2 Solid node, as it is attached to the link2 body; you’ll need to walk out through kinematics tree to find it.
The yellow cone representing the sensor is a Shape node that is a child of the DistanceSensor node.
The maximum range of the sensor is expressed via its lookupTable property.
If you wish to add a sensor to your own robot, the simplest way would be to copy and paste this DistanceSensor node as a child of a Solid in your own model.
After setting up the sensor, you may add additional Solid nodes at top level to represent other props. With top-level solids, if the boundingObject is set but not the physics, it will be immovable but still participate in collisions.
Part 3: Feedback Control using an External Sensor¶
The objective is to set up a control process which responds to external objects or other robots via distance sensor readings. There are endless possibilities, from linear regulation feedback up to world mapping; a full treatment is beyond the scope of this course.
To start, I suggest a focus on switching functions rather than linear feedback. The essential idea is that different states of the robot and world are mapped to different discrete control outputs. These solutions can be hard to treat analytically and are prone to defects such as instability or getting stuck, but can be intuitive to formulate and suited for empirical development.
The two_link_sensor.py script in the sample world contains one such controller. It implements a heuristic switching controller which locates nearby obstacles for short intervals. It has a ‘hunt’ mode in which it scans for range readings, and a ‘track’ mode where it attempts to oscillate around a local minimum of the distance function.
Deliverables¶
This assignment has two parts:
Experimenting with the provided single-axis clock controller to find new gains.
Extending a simulation with external sensing and constructing a controller for it. You may use your own previous model, modify the two-link model, or create a new one.
For submitted files, please add your name (either preferred or last) as a prefix on the filename, e.g. “Garth-sim.zip” or “Zeglin-sensors.zip”.
Please submit the following files to Canvas:
A text file with two paragraphs briefly describing:
Your final gain settings on the one-axis simulator and your criteria for the selection.
Your behavioral objectives and outcomes using external sensing.
Zip file of your Webots project.
Short video clip (under one minute) of simulated behavior, submitted to Canvas either as a video file or a link to a third-party streaming service. If a file, please add a similar name prefix.
N.B. it appears Canvas is treating the submission criteria as exclusive-or, e.g. it doesn’t seem to accept direct text submission along with files.