Closed ShunjiHashimoto closed 3 years ago
返り値を増やすとエラー解消
ret, threshold_img = cv2.threshold(gray_img, 80, 255, cv2.THRESH_BINARY) # 2値化、
findContours()できない
contours_img, contours = cv2.findContours(threshold_img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ ./particle.py
Traceback (most recent call last):
File "./particle.py", line 71, in <module>
main()
File "./particle.py", line 67, in main
video.readVideo()
File "./particle.py", line 54, in readVideo
max_area_contour = self.maxContours(contours)
File "./particle.py", line 21, in maxContours
area = cv2.contourArea(contours[i])
cv2.error: OpenCV(4.5.3) /tmp/pip-req-build-tjxnaiom/opencv/modules/imgproc/src/shapedescr.cpp:315: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function 'contourArea'
出力の順番間違えてた
contours, hierarchy = cv2.findContours(threshold_img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
circle_img = cv2.circle(circle_img,center,radius,(0,255,0),2)
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ ./particle.py
Traceback (most recent call last):
File "./particle.py", line 74, in <module>
main()
File "./particle.py", line 70, in main
video.readVideo()
File "./particle.py", line 59, in readVideo
circle_img = cv2.circle(circle_img,center,radius,(0,255,0),2)
UnboundLocalError: local variable 'circle_img' referenced before assignment
第一引数は円を描きたい画像を選択する
cv2.circle(masked_img,center,radius,(0,255,0),2)
赤色がないとき、具体的にはmax_area_contoursが-1のときプログラムが終了する
前
if(max_area_contour == -1): return
後
if(max_area_contour == -1): continue
に変更した
大体はできたが、まだ処理が汚いので整理する必要がある
import ropkgができない
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ ./particle.py
Traceback (most recent call last):
File "./particle.py", line 6, in <module>
import rospy
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/__init__.py", line 49, in <module>
from .client import spin, myargv, init_node, \
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/client.py", line 52, in <module>
import roslib
File "/opt/ros/melodic/lib/python2.7/dist-packages/roslib/__init__.py", line 50, in <module>
from roslib.launcher import load_manifest # noqa: F401
File "/opt/ros/melodic/lib/python2.7/dist-packages/roslib/launcher.py", line 42, in <module>
import rospkg
ModuleNotFoundError: No module named 'rospkg'
python2からpython3に変更する必要がある
pythonと打ってpython3を使う方法 参考文献:https://mixcubenet.com/linux/change_default_python_version_to_python3_on_ubuntu/
import rospkgをできるようにする方法
⇒ シンプルにpython3用のrospkgが足りなかった説
sudo pip3 install rospkg catkin_pkg
参考文献:https://masato-ka.hatenablog.com/entry/2019/07/17/065000
その他のやり方
参考文献:https://qiita.com/jmtsn/items/866a601424131c923b75
hashimoto@hashimoto:~$ pip3 install numpy
Collecting numpy
Downloading https://files.pythonhosted.org/packages/45/b2/6c7545bb7a38754d63048c7696804a0d947328125d81bf12beaa692c3ae3/numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl (13.4MB)
100% |████████████████████████████████| 13.4MB 144kB/s
Installing collected packages: numpy
Successfully installed numpy-1.19.5
hashimoto@hashimoto:~$ pip3 show numpy
Name: numpy
Version: 1.19.5
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: /home/hashimoto/.local/lib/python3.6/site-packages
Requires:
hashimoto@hashimoto:~$ export PYTHONPATH=/home/hashimoto/.local/lib/python3.6/site-packages
hashimoto@hashimoto:~$ echo $PYTHONPATH
/home/hashimoto/.local/lib/python3.6/site-packages
hashimoto@hashimoto:~$ cm
Traceback (most recent call last):
File "/opt/ros/melodic/bin/catkin_make", line 13, in <module>
from catkin.builder import apply_platform_specific_defaults # noqa: E402
ModuleNotFoundError: No module named 'catkin'
hashimoto@hashimoto:~/catkin_ws$ catkin clean
catkin: コマンドが見つかりません
hashimoto@hashimoto:~/catkin_ws$ catkin clean
catkin: コマンドが見つかりません
hashimoto@hashimoto:~/catkin_ws$ ls
build devel src
hashimoto@hashimoto:~/catkin_ws$ cd ..
hashimoto@hashimoto:~$ catkin clean
catkin: コマンドが見つかりません
hashimoto@hashimoto:~$ cs
hashimoto@hashimoto:~/catkin_ws/src$ catkin clean
catkin: コマンドが見つかりません
hashimoto@hashimoto:~/catkin_ws/src$ source ~/.bashrc
hashimoto@hashimoto:~/catkin_ws/src$ catkin clean
catkin: コマンドが見つかりません
hashimoto@hashimoto:~/catkin_ws/src$ catkin clean
catkin: コマンドが見つかりません
hashimoto@hashimoto:~/catkin_ws/src$ echo $PYTHONPATH
/home/hashimoto/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist-packages:/home/hashimoto/.local/lib/python3.6/site-packages
hashimoto@hashimoto:~/catkin_ws/src$ cm
Base path: /home/hashimoto/catkin_ws
Source space: /home/hashimoto/catkin_ws/src
Build space: /home/hashimoto/catkin_ws/build
Devel space: /home/hashimoto/catkin_ws/devel
Install space: /home/hashimoto/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/hashimoto/catkin_ws/build"
####
####
#### Running command: "make -j8 -l8" in "/home/hashimoto/catkin_ws/build"
####
[ 1%] Built target utils
[ 1%] Built target sensor_base
[ 1%] Built target configfile
[ 1%] Built target geometry_msgs_generate_messages_nodejs
[ 1%] Built target std_msgs_generate_messages_nodejs
[ 2%] Built target autoptr_test
[ 2%] Built target std_msgs_generate_messages_lisp
[ 2%] Built target std_msgs_generate_messages_eus
[ 2%] Built target geometry_msgs_generate_messages_lisp
[ 2%] Built target _costmap_cspace_msgs_generate_messages_check_deps_CSpace3DUpdate
[ 2%] Built target geometry_msgs_generate_messages_eus
[ 2%] Built target _costmap_cspace_msgs_generate_messages_check_deps_CSpace3D
[ 2%] Built target geometry_msgs_generate_messages_py
[ 2%] Built target std_msgs_generate_messages_py
[ 2%] Built target std_msgs_generate_messages_cpp
[ 2%] Built target _costmap_cspace_msgs_generate_messages_check_deps_MapMetaData3D
[ 2%] Built target geometry_msgs_generate_messages_cpp
[ 2%] Built target actionlib_msgs_generate_messages_cpp
[ 2%] Built target _move_base_msgs_generate_messages_check_deps_MoveBaseActionResult
[ 2%] Built target _move_base_msgs_generate_messages_check_deps_MoveBaseAction
[ 2%] Built target _move_base_msgs_generate_messages_check_deps_MoveBaseActionFeedback
[ 2%] Built target _move_base_msgs_generate_messages_check_deps_MoveBaseResult
[ 2%] Built target _move_base_msgs_generate_messages_check_deps_MoveBaseFeedback
[ 2%] Built target _move_base_msgs_generate_messages_check_deps_MoveBaseGoal
[ 2%] Built target _move_base_msgs_generate_messages_check_deps_MoveBaseActionGoal
[ 2%] Built target actionlib_msgs_generate_messages_py
[ 2%] Built target actionlib_msgs_generate_messages_lisp
[ 2%] Built target actionlib_msgs_generate_messages_eus
[ 2%] Built target actionlib_msgs_generate_messages_nodejs
[ 2%] Built target nav_msgs_generate_messages_nodejs
[ 2%] Built target nav_msgs_generate_messages_eus
[ 2%] Built target _move_base_msgs_generate_messages_check_deps_RecoveryStatus
[ 2%] Built target nav_msgs_generate_messages_py
[ 2%] Built target nav_msgs_generate_messages_lisp
[ 2%] Built target nav_msgs_generate_messages_cpp
[ 2%] Built target _map_organizer_msgs_generate_messages_check_deps_OccupancyGridArray
[ 2%] Built target _planner_cspace_msgs_generate_messages_check_deps_MoveWithToleranceFeedback
[ 2%] Built target _planner_cspace_msgs_generate_messages_check_deps_MoveWithToleranceResult
[ 2%] Built target _planner_cspace_msgs_generate_messages_check_deps_MoveWithToleranceGoal
[ 2%] Built target _planner_cspace_msgs_generate_messages_check_deps_MoveWithToleranceActionResult
[ 2%] Built target _planner_cspace_msgs_generate_messages_check_deps_MoveWithToleranceActionFeedback
[ 2%] Built target _planner_cspace_msgs_generate_messages_check_deps_PlannerStatus
[ 2%] Built target _planner_cspace_msgs_generate_messages_check_deps_MoveWithToleranceAction
[ 2%] Built target _planner_cspace_msgs_generate_messages_check_deps_MoveWithToleranceActionGoal
[ 2%] Built target _safety_limiter_msgs_generate_messages_check_deps_SafetyLimiterStatus
[ 2%] Built target _tf2_msgs_generate_messages_check_deps_LookupTransformActionResult
[ 2%] Built target _tf2_msgs_generate_messages_check_deps_LookupTransformResult
[ 2%] Built target _tf2_msgs_generate_messages_check_deps_FrameGraph
[ 2%] Built target _tf2_msgs_generate_messages_check_deps_LookupTransformFeedback
[ 2%] Built target _tf2_msgs_generate_messages_check_deps_LookupTransformAction
[ 2%] Built target _tf2_msgs_generate_messages_check_deps_TF2Error
[ 2%] Built target _tf2_msgs_generate_messages_check_deps_TFMessage
[ 2%] Built target _tf2_msgs_generate_messages_check_deps_LookupTransformGoal
[ 2%] Built target _tf2_msgs_generate_messages_check_deps_LookupTransformActionGoal
[ 2%] Built target _tf2_msgs_generate_messages_check_deps_LookupTransformActionFeedback
[ 2%] Built target _thouzer_msgs_generate_messages_check_deps_Battery
[ 2%] Built target _thouzer_msgs_generate_messages_check_deps_App
[ 2%] Built target _thouzer_msgs_generate_messages_check_deps_StringStamped
[ 2%] Built target _thouzer_msgs_generate_messages_check_deps_Vel
[ 2%] Built target _thouzer_msgs_generate_messages_check_deps_Odom
[ 2%] Built target cubase_generate_messages_eus
[ 2%] Built target cubase_generate_messages_nodejs
[ 2%] Built target cubase_generate_messages_lisp
[ 2%] Built target _thouzer_msgs_generate_messages_check_deps_Commander
[ 2%] Built target _turtlebot3_msgs_generate_messages_check_deps_VersionInfo
[ 2%] Built target _turtlebot3_msgs_generate_messages_check_deps_SensorState
[ 2%] Built target cubase_generate_messages_py
[ 2%] Built target cubase_generate_messages_cpp
[ 2%] Built target rosgraph_msgs_generate_messages_eus
[ 2%] Built target roscpp_generate_messages_py
[ 2%] Built target _turtlebot3_msgs_generate_messages_check_deps_Sound
[ 2%] Built target roscpp_generate_messages_eus
[ 2%] Built target roscpp_generate_messages_lisp
[ 2%] Built target roscpp_generate_messages_nodejs
[ 2%] Built target rosgraph_msgs_generate_messages_cpp
[ 2%] Built target roscpp_generate_messages_cpp
[ 2%] Built target rosgraph_msgs_generate_messages_nodejs
[ 2%] Built target rosgraph_msgs_generate_messages_lisp
[ 2%] Built target rosgraph_msgs_generate_messages_py
[ 2%] Built target _catkin_empty_exported_target
[ 2%] Built target gtest
[ 2%] Built target nav_bt
[ 3%] Built target joystick_mux
[ 3%] Built target sensor_msgs_generate_messages_lisp
[ 3%] Built target joystick_interrupt
[ 3%] Built target _map_msgs_generate_messages_check_deps_GetPointMap
[ 3%] Built target _map_msgs_generate_messages_check_deps_GetPointMapROI
[ 3%] Built target _map_msgs_generate_messages_check_deps_PointCloud2Update
[ 3%] Built target _map_msgs_generate_messages_check_deps_SetMapProjections
[ 3%] Built target _map_msgs_generate_messages_check_deps_GetMapROI
[ 3%] Built target _map_msgs_generate_messages_check_deps_OccupancyGridUpdate
[ 3%] Built target _map_msgs_generate_messages_check_deps_SaveMap
[ 3%] Built target sensor_msgs_generate_messages_py
[ 3%] Built target _map_msgs_generate_messages_check_deps_ProjectedMapsInfo
[ 3%] Built target sensor_msgs_generate_messages_cpp
[ 3%] Built target sensor_msgs_generate_messages_eus
[ 3%] Built target sensor_msgs_generate_messages_nodejs
[ 3%] Built target pcl_msgs_generate_messages_py
[ 3%] Built target pcl_msgs_generate_messages_nodejs
[ 3%] Built target pcl_msgs_generate_messages_lisp
[ 3%] Built target _map_msgs_generate_messages_check_deps_ProjectedMap
[ 3%] Built target object_detection
[ 3%] Built target _map_msgs_generate_messages_check_deps_ProjectedMapInfo
[ 3%] Built target pcl_msgs_generate_messages_eus
[ 3%] Built target pcl_msgs_generate_messages_cpp
[ 3%] Built target actionlib_generate_messages_eus
[ 3%] Built target actionlib_generate_messages_py
[ 3%] Built target actionlib_generate_messages_nodejs
[ 3%] Built target rt_usb_9axisimu_driver
[ 3%] Built target actionlib_generate_messages_lisp
[ 3%] Built target bond_generate_messages_lisp
[ 3%] Built target actionlib_generate_messages_cpp
[ 3%] Built target tf_generate_messages_lisp
[ 3%] Built target bond_generate_messages_nodejs
[ 3%] Built target nodelet_generate_messages_py
[ 3%] Built target tf_generate_messages_nodejs
[ 3%] Built target bond_generate_messages_eus
[ 3%] Built target tf_generate_messages_py
[ 3%] Built target nodelet_generate_messages_eus
[ 3%] Built target tf_generate_messages_cpp
[ 3%] Built target nodelet_generate_messages_lisp
[ 3%] Built target nodelet_generate_messages_nodejs
[ 3%] Built target bond_generate_messages_py
[ 3%] Built target tf_generate_messages_eus
[ 3%] Built target nodelet_generate_messages_cpp
[ 3%] Built target bond_generate_messages_cpp
[ 4%] Built target amcl_pf
[ 4%] Built target amcl_gencfg
[ 4%] Built target std_srvs_generate_messages_lisp
[ 6%] Built target amcl_map
[ 6%] Built target diagnostic_msgs_generate_messages_py
[ 6%] Built target std_srvs_generate_messages_nodejs
[ 6%] Built target std_srvs_generate_messages_eus
[ 6%] Built target std_srvs_generate_messages_cpp
[ 6%] Built target topic_tools_generate_messages_eus
[ 6%] Built target std_srvs_generate_messages_py
[ 6%] Built target topic_tools_generate_messages_lisp
[ 6%] Built target topic_tools_generate_messages_nodejs
[ 6%] Built target topic_tools_generate_messages_cpp
[ 6%] Built target topic_tools_generate_messages_py
[ 6%] Built target diagnostic_msgs_generate_messages_eus
[ 6%] Built target diagnostic_msgs_generate_messages_cpp
[ 6%] Built target dynamic_reconfigure_generate_messages_lisp
[ 6%] Built target dynamic_reconfigure_generate_messages_cpp
[ 6%] Built target dynamic_reconfigure_generate_messages_py
[ 6%] Built target diagnostic_msgs_generate_messages_nodejs
[ 6%] Built target diagnostic_msgs_generate_messages_lisp
[ 6%] Built target dynamic_reconfigure_generate_messages_eus
[ 6%] Built target dynamic_reconfigure_generate_messages_nodejs
[ 6%] Built target dynamic_reconfigure_gencfg
[ 6%] Built target Scan
[ 6%] Built target OdomModel
[ 6%] Built target LikelihoodFieldMap
[ 6%] Built target ParticleFilter
[ 7%] Built target Pose
[ 8%] Built target safety_limiter_gencfg
[ 8%] Built target Particle
[ 8%] Built target trajectory_msgs_generate_messages_py
[ 8%] Built target pcl_ros_gencfg
[ 8%] Built target nodelet_topic_tools_gencfg
[ 8%] Built target trajectory_msgs_generate_messages_lisp
[ 8%] Built target trajectory_msgs_generate_messages_nodejs
[ 8%] Built target trajectory_msgs_generate_messages_cpp
[ 8%] Built target trajectory_msgs_generate_messages_eus
[ 8%] Built target visualization_msgs_generate_messages_py
[ 8%] Built target visualization_msgs_generate_messages_nodejs
[ 8%] Built target visualization_msgs_generate_messages_cpp
[ 8%] Built target _trajectory_tracker_msgs_generate_messages_check_deps_TrajectoryTrackerStatus
[ 8%] Built target _trajectory_tracker_msgs_generate_messages_check_deps_TrajectoryServerStatus
[ 8%] Built target _trajectory_tracker_msgs_generate_messages_check_deps_PathWithVelocity
[ 8%] Built target _trajectory_tracker_msgs_generate_messages_check_deps_PoseStampedWithVelocity
[ 8%] Built target _trajectory_tracker_msgs_generate_messages_check_deps_ChangePath
[ 8%] Built target visualization_msgs_generate_messages_lisp
[ 8%] Built target visualization_msgs_generate_messages_eus
[ 8%] Built target turtlebot3_autorace_camera_gencfg
[ 8%] Built target trajectory_tracker_gencfg
[ 8%] Built target turtlebot3_autorace_detect_gencfg
[ 8%] Built target _turtlebot3_example_generate_messages_check_deps_Turtlebot3ActionFeedback
[ 8%] Built target gazebo_msgs_generate_messages_py
[ 8%] Built target _turtlebot3_example_generate_messages_check_deps_Turtlebot3Action
[ 8%] Built target _turtlebot3_example_generate_messages_check_deps_Turtlebot3Goal
[ 8%] Built target _turtlebot3_example_generate_messages_check_deps_Turtlebot3ActionGoal
[ 8%] Built target _turtlebot3_example_generate_messages_check_deps_Turtlebot3ActionResult
[ 8%] Built target gazebo_msgs_generate_messages_cpp
[ 8%] Built target _turtlebot3_example_generate_messages_check_deps_Turtlebot3Result
[ 8%] Built target gazebo_msgs_generate_messages_nodejs
[ 8%] Built target _turtlebot3_example_generate_messages_check_deps_Turtlebot3Feedback
[ 8%] Built target gazebo_msgs_generate_messages_eus
[ 8%] Built target gazebo_ros_gencfg
[ 8%] Built target gazebo_msgs_generate_messages_lisp
[ 9%] Built target flat_world_imu_node
[ 10%] Built target points_and_lines
[ 12%] Built target basic_shapes
[ 12%] Built target costmap_2d_gencfg
[ 12%] Built target voxel_grid
[ 12%] Built target base_local_planner_gencfg
[ 12%] Built target dwa_local_planner_gencfg
[ 12%] Built target move_base_gencfg
[ 13%] Built target global_planner_gencfg
[ 13%] Built target _base_local_planner_generate_messages_check_deps_Position2DInt
[ 13%] Built target _costmap_2d_generate_messages_check_deps_VoxelGrid
[ 13%] Built target turtlebot3_description_xacro_generated_to_devel_space_
[ 14%] Built target sensor_odometry
[ 14%] Built target costmap_cspace_msgs_generate_messages_nodejs
[ 14%] Built target sensor_range
[ 15%] Built target _navfn_generate_messages_check_deps_MakeNavPlan
[ 15%] Built target configfile_test
[ 15%] Built target _navfn_generate_messages_check_deps_SetCostmap
[ 15%] Built target costmap_cspace_msgs_generate_messages_eus
[ 16%] Built target costmap_cspace_msgs_generate_messages_lisp
[ 18%] Built target costmap_cspace_msgs_generate_messages_py
[ 18%] Built target costmap_cspace_msgs_generate_messages_cpp
[ 19%] Built target move_base_msgs_generate_messages_cpp
[ 22%] Built target move_base_msgs_generate_messages_lisp
[ 22%] Built target move_base_msgs_generate_messages_py
[ 24%] Built target move_base_msgs_generate_messages_eus
[ 24%] Built target map_organizer_msgs_generate_messages_nodejs
[ 24%] Built target move_base_msgs_generate_messages_nodejs
[ 25%] Built target map_organizer_msgs_generate_messages_eus
[ 25%] Built target map_organizer_msgs_generate_messages_py
[ 26%] Built target map_organizer_msgs_generate_messages_lisp
[ 26%] Built target map_organizer_msgs_generate_messages_cpp
[ 26%] Built target planner_cspace_msgs_generate_messages_lisp
[ 26%] Built target planner_cspace_msgs_generate_messages_nodejs
[ 28%] Built target planner_cspace_msgs_generate_messages_py
[ 30%] Built target planner_cspace_msgs_generate_messages_eus
[ 30%] Built target safety_limiter_msgs_generate_messages_eus
[ 31%] Built target planner_cspace_msgs_generate_messages_cpp
[ 31%] Built target safety_limiter_msgs_generate_messages_cpp
[ 31%] Built target safety_limiter_msgs_generate_messages_lisp
[ 31%] Built target safety_limiter_msgs_generate_messages_py
[ 31%] Built target safety_limiter_msgs_generate_messages_nodejs
[ 32%] Built target tf2_msgs_generate_messages_cpp
[ 34%] Built target tf2_msgs_generate_messages_nodejs
[ 36%] Built target tf2_msgs_generate_messages_py
[ 37%] Built target tf2_msgs_generate_messages_lisp
[ 38%] Built target tf2_msgs_generate_messages_eus
[ 39%] Built target thouzer_msgs_generate_messages_nodejs
[ 40%] Built target thouzer_msgs_generate_messages_cpp
[ 42%] Built target thouzer_msgs_generate_messages_eus
[ 43%] Built target thouzer_msgs_generate_messages_py
[ 43%] Built target thouzer_msgs_generate_messages_lisp
[ 43%] Built target turtlebot3_msgs_generate_messages_lisp
[ 44%] Built target turtlebot3_msgs_generate_messages_nodejs
[ 45%] Built target turtlebot3_msgs_generate_messages_cpp
[ 45%] Built target turtlebot3_msgs_generate_messages_eus
[ 45%] Built target cubase_generate_messages
[ 45%] Built target turtlebot3_msgs_generate_messages_py
[ 49%] Built target map_msgs_generate_messages_py
[ 49%] Built target map_msgs_generate_messages_lisp
[ 50%] Built target map_msgs_generate_messages_cpp
[ 51%] Built target map_msgs_generate_messages_eus
[ 53%] Built target map_msgs_generate_messages_nodejs
[ 53%] Built target amcl_sensors
[ 53%] Built target trajectory_tracker_msgs_generate_messages_nodejs
[ 54%] Built target trajectory_tracker_msgs_generate_messages_cpp
[ 54%] Built target trajectory_tracker_msgs_generate_messages_eus
[ 55%] Built target trajectory_tracker_msgs_generate_messages_py
[ 56%] Built target trajectory_tracker_msgs_generate_messages_lisp
[ 56%] Built target obj_to_pointcloud
[ 57%] Built target turtlebot3_example_generate_messages_nodejs
[ 59%] Built target turtlebot3_example_generate_messages_lisp
[ 60%] Built target turtlebot3_example_generate_messages_eus
[ 60%] Built target turtlebot3_example_generate_messages_cpp
[ 60%] Built target turtlebot3_diagnostics
[ 61%] Built target turtlebot3_example_generate_messages_py
[ 61%] Built target costmap_2d_generate_messages_eus
[ 61%] Built target costmap_2d_generate_messages_lisp
[ 62%] Built target costmap_2d_generate_messages_nodejs
[ 62%] Built target base_local_planner_generate_messages_eus
[ 62%] Built target costmap_2d_generate_messages_py
[ 62%] Built target costmap_2d_generate_messages_cpp
[ 62%] Built target base_local_planner_generate_messages_py
[ 62%] Built target base_local_planner_generate_messages_cpp
[ 63%] Built target base_local_planner_generate_messages_nodejs
[ 63%] Built target base_local_planner_generate_messages_lisp
[ 65%] Built target navfn_generate_messages_cpp
[ 65%] Built target navfn_generate_messages_eus
[ 65%] Built target navfn_generate_messages_lisp
[ 66%] Built target navfn_generate_messages_nodejs
[ 66%] Built target navfn_generate_messages_py
[ 67%] Built target log
[ 67%] Built target move_base_msgs_generate_messages
[ 67%] Built target map_organizer_msgs_generate_messages
[ 67%] Built target planner_cspace_msgs_generate_messages
[ 67%] Built target costmap_cspace_msgs_generate_messages
[ 67%] Built target safety_limiter_msgs_generate_messages
[ 67%] Built target tf2_msgs_generate_messages
[ 67%] Built target thouzer_msgs_generate_messages
[ 68%] Built target tf2
[ 68%] Built target map_msgs_generate_messages
[ 68%] Built target turtlebot3_msgs_generate_messages
[ 68%] Built target trajectory_tracker_msgs_generate_messages
[ 68%] Built target turtlebot3_example_generate_messages
[ 68%] Built target costmap_2d_generate_messages
[ 68%] Built target base_local_planner_generate_messages
[ 68%] Built target navfn_generate_messages
[ 68%] Built target scanmatcher
[ 68%] Built target log_test
[ 69%] Built target rdk2carmen
[ 69%] Built target scanstudio2carmen
[ 69%] Built target log_plot
[ 69%] Built target map_server-map_saver
[ 69%] Built target rtest
[ 71%] Built target map_server_image_loader
[ 71%] Built target tf2_py
[ 71%] Built target icptest
[ 71%] Built target gridfastslam
[ 71%] Built target scanmatch_test
[ 72%] Built target tf2_ros
[ 72%] Built target gfs2log
[ 72%] Built target map_server
[ 72%] Built target gfs2rec
[ 72%] Built target gfs2neff
[ 73%] Built target tf2_ros_static_transform_publisher
[ 73%] Built target tf2_ros_buffer_server
[ 73%] Built target slam_gmapping_nodelet
[ 74%] Built target slam_gmapping
[ 74%] Built target simple_marker
[ 74%] Built target basic_controls
[ 74%] Built target cube
[ 74%] Built target slam_gmapping_replay
[ 74%] Built target selection
[ 74%] Built target pong
[ 74%] Built target menu
[ 74%] Built target fake_localization
[ 74%] Built target point_cloud
[ 74%] Built target emcl_node
[ 74%] Built target amcl
[ 74%] Built target select_map
[ 75%] Built target pose_transform
[ 75%] Built target costmap_3d
[ 75%] Built target tie_maps
[ 77%] Built target save_maps
[ 77%] Built target pointcloud2_to_map
[ 77%] Built target laserscan_to_map
[ 77%] Built target pointcloud_to_maps
[ 77%] Built target largemap_to_map
[ 77%] Built target track_odometry
[ 78%] Built target tf_projection
[ 78%] Built target trajectory_saver
[ 78%] Built target trajectory_server
[ 78%] Built target trajectory_recorder
[ 80%] Built target trajectory_tracker
[ 80%] Built target planner_2dof_serial_joints
[ 80%] Built target safety_limiter
[ 80%] Built target turtlebot3_fake_node
[ 80%] Built target patrol
[ 80%] Built target dummy_robot
[ 81%] Automatic MOC for target myviz
[ 83%] Built target planner_3d
[ 83%] Automatic MOC for target rviz_plugin_tutorials
[ 83%] Automatic MOC for target thouzer_gui
[ 84%] Built target turtlebot3_drive
[ 84%] Automatic MOC for target trajectory_tracker_rviz_plugins
[ 84%] Built target myviz_autogen
[ 85%] Automatic MOC for target waypoint_gui
[ 85%] Built target rviz_plugin_tutorials_autogen
[ 85%] Built target thouzer_gui_autogen
[ 85%] Built target waypoint_gui_autogen
[ 85%] Built target trajectory_tracker_rviz_plugins_autogen
[ 86%] Built target costmap_2d
[ 86%] Built target myviz
[ 86%] Built target thouzer_gui
[ 87%] Built target rviz_plugin_tutorials
[ 87%] Built target costmap_2d_cloud
[ 87%] Built target costmap_2d_node
[ 87%] Built target waypoint_gui
[ 89%] Built target trajectory_tracker_rviz_plugins
[ 89%] Built target costmap_2d_markers
[ 90%] Built target layers
[ 90%] Built target clear_costmap_recovery
[ 90%] Built target move_slow_and_clear
[ 90%] Built target navfn
[ 92%] Built target base_local_planner
[ 92%] Built target navfn_node
[ 93%] Built target global_planner
[ 93%] Built target point_grid
[ 95%] Built target trajectory_planner_ros
[ 95%] Built target planner
[ 97%] Built target rotate_recovery
[ 97%] Built target carrot_planner
[ 98%] Built target dwa_local_planner
[100%] Built target move_base
[100%] Built target move_base_node
hashimoto@hashimoto:~/catkin_ws$ echo $PYTHONPATH
/home/hashimoto/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist-packages:/home/hashimoto/.local/lib/python3.6/site-packages
hashimoto@hashimoto:~/catkin_ws$
python2からpython3に変更する必要がある
pythonと打ってpython3を使う方法 参考文献:https://mixcubenet.com/linux/change_default_python_version_to_python3_on_ubuntu/
import rospkgをできるようにする方法 ⇒ シンプルにpython3用のrospkgが足りなかった説
sudo pip3 install rospkg catkin_pkg
参考文献:https://masato-ka.hatenablog.com/entry/2019/07/17/065000
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ sudo pip3 install rospkg catkin_pkg
[sudo] hashimoto のパスワード:
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
警告が出るが、そのまま待つとインストールが開始する
python3.6.9 -> python3.8に変更
参考文献:https://qiita.com/syu-kwsk/items/5ba485edabd19fb99d4d
python 3.8にすると、numpyがバグった
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ ./particle.py
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 16, in <module>
from . import multiarray
ImportError: cannot import name 'multiarray' from partially initialized module 'numpy.core' (most likely due to a circular import) (/usr/lib/python3/dist-packages/numpy/core/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./particle.py", line 4, in <module>
import numpy as np
File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/lib/python3/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python3/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/lib/python3/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: cannot import name 'multiarray' from partially initialized module 'numpy.core' (most likely due to a circular import) (/usr/lib/python3/dist-packages/numpy/core/__init__.py)
python 3.6.9に戻し、source /opt/ros/melodic/setup.bashするともとに戻った
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ sudo update-alternatives --config python3
[sudo] hashimoto のパスワード:
alternative python3 (/usr/bin/python3 を提供) には 2 個の選択肢があります。
選択肢 パス 優先度 状態
------------------------------------------------------------
0 /usr/bin/python3.6 2 自動モード
1 /usr/bin/python3.6 2 手動モード
* 2 /usr/bin/python3.8 1 手動モード
現在の選択 [*] を保持するには <Enter>、さもなければ選択肢の番号のキーを押してください: 0
update-alternatives: /usr/bin/python3 (python3) を提供するために自動モードで /usr/bin/python3.6 を使います
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ ./particle.py
Traceback (most recent call last):
File "./particle.py", line 6, in <module>
import rospy
ModuleNotFoundError: No module named 'rospy'
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ source ~/.bashrc
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ echo $PYTHONPATH
/home/hashimoto/.local/lib/python3.8/site-packages
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ source ~/.bashrc
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ ./particle.py
Traceback (most recent call last):
File "./particle.py", line 6, in <module>
import rospy
ModuleNotFoundError: No module named 'rospy'
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ python3 --version
Python 3.6.9
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ python3
Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rospy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'rospy'
>>>
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ pip3 show numpy
Name: numpy
Version: 1.19.5
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email:
License: BSD
Location: /home/hashimoto/.local/lib/python3.6/site-packages
Requires:
Required-by: scipy, opencv-python, opencv-contrib-python, matplotlib
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ export PYTHONPATH=/home/hashimoto/.local/lib/python3.6/site-packages
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ ./particle.py
Traceback (most recent call last):
File "./particle.py", line 6, in <module>
import rospy
ModuleNotFoundError: No module named 'rospy'
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ ./particle.py
Traceback (most recent call last):
File "./particle.py", line 4, in <module>
sys.append('/home/hashimoto/.local/lib/python3.6/site-packages')
AttributeError: module 'sys' has no attribute 'append'
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ ./particle.py
Traceback (most recent call last):
File "./particle.py", line 7, in <module>
import rospy
ModuleNotFoundError: No module named 'rospy'
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ ./particle.py
Traceback (most recent call last):
File "./particle.py", line 6, in <module>
import rospy
ModuleNotFoundError: No module named 'rospy'
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ source /opt/ros/melodic/setup.bash
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ ./particle.py
^CTraceback (most recent call last):
File "./particle.py", line 73, in <module>
video.readVideo()
File "./particle.py", line 66, in readVideo
if cv2.waitKey(delay) & 0xFF == ord('q'): # qが押されると終了
KeyboardInterrupt
hashimoto@desktop:~/catkin_ws/src/cugo/cugo_detection/scripts$ echo $PYTHONPATH
/opt/ros/melodic/lib/python2.7/dist-packages:/home/hashimoto/.local/lib/python3.6/site-packages
roscoreできなくなった
hashimoto@desktop:~/catkin_ws/src/cugo$ roscore
Traceback (most recent call last):
File "/opt/ros/melodic/bin/roscore", line 36, in <module>
from rosmaster.master_api import NUM_WORKERS
ModuleNotFoundError: No module named 'rosmaster'
hashimoto@desktop:~/catkin_ws/src/cugo$ sudo pip install defusedxml
hashimoto@desktop:~/catkin_ws/src/cugo$ source ~/.bashrc
hashimoto@desktop:~/catkin_ws/src/cugo$ source /opt/ros/melodic/setup.bash
hashimoto@desktop:~/catkin_ws/src/cugo$ roscore
roslaunch できなくなった
hashimoto@desktop:~/catkin_ws/src/cugo$ roslaunch cubase cubase.launch
RLException: [cubase.launch] is neither a launch file in package [cubase] nor is [cubase] a launch file name
The traceback for the exception was written to the log file
パスを通した
hashimoto@desktop:~/catkin_ws/src/cugo$ source ~/catkin_ws/devel/setup.bash
赤色のしきい値を自動で決めてくれる大津の手法
ret2, img_otsu = cv2.threshold(img, 0, 255, cv2.THRESH_OTSU)
ブロブ解析を使うことで赤色検出精度向上
参考文献:https://algorithm.joho.info/programming/python/opencv-color-tracking-py/
# 2値画像のラベリング処理
label = cv2.connectedComponentsWithStats(binary_img)
https://axa.biopapyrus.jp/ia/opencv/object-detection.html
https://imagingsolution.blog.fc2.com/blog-entry-193.html
cv2.connectedComponentsWithStatsの使い方
label[0] ・・・ ラベル数
label[1] ・・・ labelimages
label[2] ・・・ data(x,y,w,h,size)
label[3] ・・・ center
赤色をcv2.connectedComponentsWithStats使って、円を描画、近くなれば円が大きくなる
Opencv3で赤色検出が成功したため、Closedとする 次はパーティクルフィルタを用いる
2値化できない