1、问题
在运行ROS by Example 2--Indigo版本中,运行 smach_viewer,再运行巡逻,命令如下:
$ rosrun smach_viewer smach_viewer.py
$ rosrun rbx2_tasks patrol_smach.py
出现如下错误:
xception in thread Thread-5: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.__target(*self.__args, **self.__kwargs) File "/opt/ros/indigo/lib/smach_viewer/smach_viewer.py", line 848, in _update_graph self.set_dotcode(dotstr,zoom=False) File "/opt/ros/indigo/lib/smach_viewer/smach_viewer.py", line 866, in set_dotcode if self.widget.set_dotcode(dotcode, None): File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/wxxdot.py", line 455, in set_dotcode self.set_xdotcode(xdotcode) File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/wxxdot.py", line 483, in set_xdotcode self.graph = parser.parse() File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 1146, in parse DotParser.parse(self) File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 951, in parse self.parse_graph() File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 960, in parse_graph self.parse_stmt() File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 993, in parse_stmt self.parse_subgraph() File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 974, in parse_subgraph self.parse_stmt() File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 993, in parse_stmt self.parse_subgraph() File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 974, in parse_subgraph self.parse_stmt() File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 1009, in parse_stmt self.handle_node(id, attrs) File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 1120, in handle_node shapes.extend(parser.parse()) File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 608, in parse points = self.read_polygon() File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 503, in read_polygon x, y = self.read_point() File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 486, in read_point x = self.read_number() File "/opt/ros/indigo/lib/python2.7/dist-packages/xdot/xdot.py", line 480, in read_number return int(self.read_code()) ValueError: invalid literal for int() with base 10: '402.67'
2、解决方案
将文件的480行的代码:
return int(self.read_code())
改成:
return int(float(self.read_code()))
来解决方案的来源:
1、ROS Indigo :Cannot show Graph View on smach_viewer
出来的效果图:
smach在机器人控制中太重要了,PR2开发中,发现如果不用一套完整的框架去执行任务,会导致代码的维护特别的繁杂,所以大佬们才开发这套smach状态机功能包,既然要用到,就不要走弯路了,最近试了几个任务的执行,深切体会,知道碰壁不如早点用起来它吧。