Closed zzz622848 closed 1 year ago
hi @zzz622848
With https://github.com/jrl-umi3218/mc_rtc/commit/78861bd4b58d0693b2ff9172c477abe3e0bf66ee we now display exception that occurs at Python level which makes it possible to track what's wrong in Python code
In that particular example, we get:
[error] [PythonController] Fatal error in Python module
Traceback (most recent call last):
File "mc_control.pyx", line 262, in mc_control.mc_control.python_to_reset_callback
File "/home/gergondet/devel/sandbox/python_controllers/my_first_controller.py", line 14, in reset_callback
self.postureTask.target({"NECK_Y": self.robot().qu[self.jointIndex]})
File "mc_tasks.pyx", line 375, in mc_tasks.mc_tasks.PostureTask.target
File "stringsource", line 178, in map.from_py.__pyx_convert_map_from_py_std_3a__3a_string__and_std_3a__3a_vector_3c_double_3e___
File "stringsource", line 15, in string.from_py.__pyx_convert_string_from_py_std__in_string
TypeError: expected bytes, str found
So one can use:
self.postureTask.target({b"NECK_Y": self.robot().qu[self.jointIndex]})
to work-around the issue
print('{"NECK_Y": self.robot().qu[self.jointIndex]}', {"NECK_Y": self.robot().qu[self.jointIndex]}) output is: {"NECK_Y": self.robot().qu[self.jointIndex]} {'NECK_Y': [1.2217304764]}
self.postureTask.target({"NECK_Y": self.robot().qu[self.jointIndex]}) Code will stop running here and quit from function run_callback()
By the way,CoM task is tested successfully. I checked the function in cpp: void PostureTask::target(const std::map<std::string, std::vector> & joints), I guess this is the compatiblity problem between std::map in C++ with dict in Python.