python codegen is added
This commit is contained in:
parent
ee605b758b
commit
29a9d700d2
|
@ -2758,6 +2758,59 @@
|
||||||
"\n",
|
"\n",
|
||||||
"display_code_file(data.generated_files[0], \"C++\")\n"
|
"display_code_file(data.generated_files[0], \"C++\")\n"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 26,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"ename": "TypeError",
|
||||||
|
"evalue": "__init__() got an unexpected keyword argument 'func'",
|
||||||
|
"output_type": "error",
|
||||||
|
"traceback": [
|
||||||
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||||
|
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
|
||||||
|
"Cell \u001b[0;32mIn[26], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m namespace \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdouble_pendulum\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m----> 2\u001b[0m double_pendulum_python \u001b[38;5;241m=\u001b[39m \u001b[43mcodegen\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mCodegen\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mcompute_mean\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcodegen\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mPythonConfig\u001b[49m\u001b[43m(\u001b[49m\u001b[43muse_eigen_types\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5\u001b[0m \u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mdouble_pendulum\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 6\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_key\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mddang\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 7\u001b[0m \u001b[43m)\u001b[49m\n\u001b[1;32m 8\u001b[0m double_pendulum_python_data \u001b[38;5;241m=\u001b[39m double_pendulum_python\u001b[38;5;241m.\u001b[39mgenerate_function(\n\u001b[1;32m 9\u001b[0m namespace\u001b[38;5;241m=\u001b[39mnamespace,\n\u001b[1;32m 10\u001b[0m )\n\u001b[1;32m 12\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mFiles generated in \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(double_pendulum_python_data\u001b[38;5;241m.\u001b[39moutput_dir))\n",
|
||||||
|
"\u001b[0;31mTypeError\u001b[0m: __init__() got an unexpected keyword argument 'func'"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"namespace = \"double_pendulum\"\n",
|
||||||
|
"double_pendulum_python = codegen.Codegen.function(\n",
|
||||||
|
" func = compute_mean,\n",
|
||||||
|
" config=codegen.PythonConfig(use_eigen_types=False),\n",
|
||||||
|
" name=\"double_pendulum\",\n",
|
||||||
|
" return_key=\"ddang\",\n",
|
||||||
|
")\n",
|
||||||
|
"double_pendulum_python_data = double_pendulum_python.generate_function(\n",
|
||||||
|
" namespace=namespace,\n",
|
||||||
|
")\n",
|
||||||
|
"\n",
|
||||||
|
"print(\"Files generated in {}:\\n\".format(double_pendulum_python_data.output_dir))\n",
|
||||||
|
"for f in double_pendulum_python_data.generated_files:\n",
|
||||||
|
" print(\" |- {}\".format(f.relative_to(double_pendulum_python_data.output_dir)))\n",
|
||||||
|
"\n",
|
||||||
|
"display_code_file(\n",
|
||||||
|
" double_pendulum_python_data.function_dir / \"double_pendulum.py\",\n",
|
||||||
|
" \"python\",\n",
|
||||||
|
")\n",
|
||||||
|
"\n",
|
||||||
|
"codegen_with_jacobians = compute_mean_codegen.with_jacobians(\n",
|
||||||
|
" # Just compute wrt the pose and point, not epsilon\n",
|
||||||
|
" which_args=[\"state\"],\n",
|
||||||
|
" # Include value, not just jacobians\n",
|
||||||
|
" include_results=True,\n",
|
||||||
|
")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|
Loading…
Reference in New Issue