Title: 线性化 · Issue #3 · TinyMPC/tinympc-python · GitHub
Open Graph Title: 线性化 · Issue #3 · TinyMPC/tinympc-python
X Title: 线性化 · Issue #3 · TinyMPC/tinympc-python
Description: 你好,我在作者给的非线性动力学模型 线性化 案例中,按照给的代码,运行总是会出现类型不匹配的错误,运行了作者的代码也是同样的问题,请问是为什么呢 作者代码如下: mc = 0.2 # mass of the cart (kg) mp = 0.1 # mass of the pole (kg) ℓ = 0.5 # distance to the center of mass (meters) g = 9.81 def cartpole_dynamics(x, u): r ...
Open Graph Description: 你好,我在作者给的非线性动力学模型 线性化 案例中,按照给的代码,运行总是会出现类型不匹配的错误,运行了作者的代码也是同样的问题,请问是为什么呢 作者代码如下: mc = 0.2 # mass of the cart (kg) mp = 0.1 # mass of the pole (kg) ℓ = 0.5 # distance to the center of mass (meters) ...
X Description: 你好,我在作者给的非线性动力学模型 线性化 案例中,按照给的代码,运行总是会出现类型不匹配的错误,运行了作者的代码也是同样的问题,请问是为什么呢 作者代码如下: mc = 0.2 # mass of the cart (kg) mp = 0.1 # mass of the pole (kg) ℓ = 0.5 # distance to the center of mass (meters) ...
Opengraph URL: https://github.com/TinyMPC/tinympc-python/issues/3
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"线性化","articleBody":"你好,我在作者给的非线性动力学模型 线性化 案例中,按照给的代码,运行总是会出现类型不匹配的错误,运行了作者的代码也是同样的问题,请问是为什么呢\r\n作者代码如下:\r\nmc = 0.2 # mass of the cart (kg)\r\nmp = 0.1 # mass of the pole (kg)\r\nℓ = 0.5 # distance to the center of mass (meters)\r\ng = 9.81\r\n# \r\n\r\ndef cartpole_dynamics(x, u):\r\n r = x[0] # cart position\r\n theta = x[1] # pole angle\r\n rd = x[2] # change in cart position\r\n theta_d = x[3] # change in pole angle\r\n F = u[0] # force applied to cart\r\n\r\n#问题出现处,显示np.sin(theta)中的theta不符合数据要求\r\n theta_dd = (g*np.sin(theta) + np.cos(theta) * ((-F - mp*l*(theta_d**2) * \\\r\n np.sin(theta))/(mc + mp))) / (l*(4/3 - (mp*(np.cos(theta)**2))/(mc + mp)))\r\n rdd = (F + mp*l*((theta_d**2)*np.sin(theta) - theta_dd*np.cos(theta))) / (mc + mp)\r\n\r\n return np.array([rd, theta_d, rdd, theta_dd])\r\ndef cartpole_rk4(x, u, dt):\r\n f1 = dt*cartpole_dynamics(x, u)\r\n f2 = dt*cartpole_dynamics(x + f1/2, u)\r\n f3 = dt*cartpole_dynamics(x + f2/2, u)\r\n f4 = dt*cartpole_dynamics(x + f3, u)\r\n return x + (1/6)*(f1 + 2*f2 + 2*f3 + f4)\r\nimport autograd as AG\r\n\r\nxgoal = np.array([0.0, np.pi, 0.0, 0.0])\r\nugoal = np.array([0.0])\r\n\r\ndt = 0.01\r\n\r\nA = AG.jacobian(lambda x_: cartpole_rk4(x_, ugoal))(xgoal)\r\nB = AG.jacobian(lambda u_: cartpole_rk4(xgoal, u_))(ugoal)","author":{"url":"https://github.com/fly-daiuser","@type":"Person","name":"fly-daiuser"},"datePublished":"2024-09-29T14:47:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/3/tinympc-python/issues/3"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c362c385-952c-747e-374a-6c9a57e89989 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C882:6A3E9:150D8C4:1D7996E:69821B89 |
| html-safe-nonce | ad655003d5fd76e94178a5f26193b09926f63482b1cbd875fe228d5c6f7fdb38 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODgyOjZBM0U5OjE1MEQ4QzQ6MUQ3OTk2RTo2OTgyMUI4OSIsInZpc2l0b3JfaWQiOiIxOTcxMTUyODM1NDI0OTUxMTc3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 88382b28e45413cb7a52c47a7ed816db38303ed57e6a0839b58a32ca5bcd2813 |
| hovercard-subject-tag | issue:2554971561 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/TinyMPC/tinympc-python/3/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7b8b010a8b343be786ace928797663d9a554993a319ed62e056a102c756c10c2/TinyMPC/tinympc-python/issues/3 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7b8b010a8b343be786ace928797663d9a554993a319ed62e056a102c756c10c2/TinyMPC/tinympc-python/issues/3 |
| og:image:alt | 你好,我在作者给的非线性动力学模型 线性化 案例中,按照给的代码,运行总是会出现类型不匹配的错误,运行了作者的代码也是同样的问题,请问是为什么呢 作者代码如下: mc = 0.2 # mass of the cart (kg) mp = 0.1 # mass of the pole (kg) ℓ = 0.5 # distance to the center of mass (meters) ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fly-daiuser |
| hostname | github.com |
| expected-hostname | github.com |
| None | c5d01132ac10b0b45b88f4c1c8790502d669eb065ff383dc5e4757c174f3380f |
| turbo-cache-control | no-preview |
| go-import | github.com/TinyMPC/tinympc-python git https://github.com/TinyMPC/tinympc-python.git |
| octolytics-dimension-user_id | 115185965 |
| octolytics-dimension-user_login | TinyMPC |
| octolytics-dimension-repository_id | 716276129 |
| octolytics-dimension-repository_nwo | TinyMPC/tinympc-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 716276129 |
| octolytics-dimension-repository_network_root_nwo | TinyMPC/tinympc-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0ac87bbde7c9f04b7ead5505c12f56048d89df09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width