x[s_] := s; y[s_] := Cos[s + 1/10];

ParametricPlot[{x[s], y[s]}, {s, 0, 2  π -  .2}, 
      AspectRatio -> Automatic]

track[s_] := {x[s], y[s]}

tan[
        s_] := track'[s]/(Sqrt[track'[s] . track'[s]])

n[s_]:=tan[s].(({{0, 1}, {-1, 0}}))

L[s_, 
        ds_] := (1/2) 
          m (x'[s]^2 + y'[s]^2) (((ds))^2) + (1/5) m*
          ((R^2)/(b^2))*(x'[s]^2 + y'[s]^2) (((ds))^2) - 
        m*g*y[s]

Solve[p == (∂_ds) L[s, ds], ds]

FullSimplify[ds /. %[[1]]]

sdot[p_, s_] := 
        FullSimplify[-((10 (b^2) p)/(m (5 (b^2) + 
                      2 (R^2)) (-3 + 
                      Cos[(1/5) + 2 s])))];

H[p_, s_] := p*sdot[p, s] - L[s, sdot[p, s]]

k = 20.5; dk =  .1; m = 1; g = 9.8; R =  .3; b =  .5*R;

solution = 
      NDSolve[{s'[t] == (∂_(p[t]))H[p[t], s[t]], p'[
              t] == -(∂_(s[t]))H[p[t], s[t]], 
          s[0] == 0, p[0] == 0}, {s, p}, {t, 0, k}]

Plot[s[t] /. solution[[1]], {t, 0, k}]

MatrixForm[Table[s[a] /. solution[[1]], {a, dk, k, dk}]]

A = Join[{0}, %];

B = 
        MatrixForm[
          Table[(((∫_0^(A[[a]]))(Sqrt[x'[s]^2 + y'[s]^2]) \[DifferentialD]s)/b), {a, 1, k/dk + 1}]];

F = 
        MatrixForm[
          Table[{n, A[[IntegerPart[((n + dk)/dk)]]], 
              B[[1, IntegerPart[((n + dk)/dk)]]]}, {n, 0, k, 
              dk}]];

G = 
        Table[{x[F[[1, IntegerPart[((t + dk)/dk)], 2]]], 
              y[F[[1, IntegerPart[((t + dk)/dk)], 2]]]} + 
            b*n[F[[1, IntegerPart[((t + dk)/dk)], 2]]], {t, 0, k, 
            dk}];

dir[θ_]:={1, 0}.(({{Cos[θ], -Sin[θ]}, {Sin[θ], Cos[θ]}}))

spoke[θ_, t_] := 
      Graphics[Line[{G[[t]], G[[t]] + dir[θ]*R}]]

g1 = 
      ParametricPlot[{x[s], y[s]}, {s, - .1, 2  π}, 
        AspectRatio -> Automatic]

Table[
      Show[{g1, 
          Graphics[{PointSize[ .05], 
              Circle[{x[F[[1, IntegerPart[((t + dk)/dk)], 2]]], 
                    y[F[[1, IntegerPart[((t + dk)/dk)], 2]]]} + 
                  b*n[F[[1, IntegerPart[((t + dk)/dk)], 2]]], R]}], 
          spoke[F[[1, IntegerPart[((t + dk)/dk)], 3]] + π/2, 
            IntegerPart[((t + dk)/dk)]], 
          spoke[F[[1, IntegerPart[((t + dk)/dk)], 3]] + π, 
            IntegerPart[((t + dk)/dk)]], 
          spoke[F[[1, IntegerPart[((t + dk)/dk)], 3]] - π/2, 
            IntegerPart[((t + dk)/dk)]], 
          spoke[F[[1, IntegerPart[((t + dk)/dk)], 3]], 
            IntegerPart[((t + dk)/dk)]]}, 
        PlotRange -> {{-2 R, 2  π + 2  R}, {-1 - 2  R, 
              1 + 2  R}}
]
, {t, 0, k, 
        dk}]

Export["Roll_Cosine2.GIF", %, 
      AnimationDisplayTime -> dk]