|
50 | 50 | #
|
51 | 51 | # The fitter will randomly sample around the coordinate values provided in the
|
52 | 52 | # table to generate model configurations for which to compute path lengths and
|
53 |
| -# moment arms. This table has many more rows than are needed for the fitter to |
54 |
| -# generate a good fit, so we will remove some of the rows to speed up the |
55 |
| -# fitting process. |
| 53 | +# moment arms. In general, it is up to the user to decide how many sample points |
| 54 | +# are needed to adequately cover the range of motion of the model's coordinates. |
| 55 | +# In this case, the table has many more rows than are needed for the fitter to |
| 56 | +# generate a good fit, so we will remove some of the rows to speed up the fitting |
| 57 | +# process. |
56 | 58 | values = osim.TimeSeriesTable('coordinates.sto')
|
57 | 59 | times = values.getIndependentColumn()
|
58 | 60 | for i in range(len(times)):
|
59 | 61 | if i % 10 != 0:
|
60 | 62 | values.removeRow(times[i])
|
61 | 63 |
|
| 64 | +# Add columns for the toe joints. Use a sine function to generate the |
| 65 | +# coordinate values. An amplitude of 0.5 keeps the values within the coordinate |
| 66 | +# range of the MTP joints in the model. |
| 67 | +amplitude = 0.5 |
| 68 | +angular_frequency = 10.0 # rad/s |
| 69 | +phase = 0.0 |
| 70 | +sine = osim.Sine(amplitude, angular_frequency, phase) |
| 71 | +mtp_values = osim.Vector(values.getNumRows(), 0.0) |
| 72 | +times = values.getIndependentColumn() |
| 73 | +time = osim.Vector(1, 0.0) |
| 74 | +for i in range(values.getNumRows()): |
| 75 | + time.set(0, times[i]) |
| 76 | + mtp_values.set(i, sine.calcValue(time)) |
| 77 | + |
| 78 | +values.appendColumn('/jointset/mtp_r/mtp_angle_r/value', mtp_values) |
| 79 | +values.appendColumn('/jointset/mtp_l/mtp_angle_l/value', mtp_values) |
62 | 80 | fitter.setCoordinateValues(osim.TableProcessor(values))
|
63 | 81 |
|
64 | 82 | # Configure optional settings
|
|
0 commit comments