Ask Your Question

ounsworth's profile - activity

2020-10-28 22:51:44 -0600 received badge  Nice Question (source)
2016-02-23 03:35:03 -0600 received badge  Taxonomist
2014-06-17 20:35:46 -0600 commented answer Should i be able to set the current pose for amcl?

Thank you! Running rviz on the same machine as the master fixed it for me!

2014-03-07 11:25:15 -0600 received badge  Famous Question (source)
2014-03-07 11:25:15 -0600 received badge  Notable Question (source)
2013-12-21 05:12:28 -0600 received badge  Notable Question (source)
2013-12-21 05:12:28 -0600 received badge  Famous Question (source)
2013-12-04 13:44:46 -0600 received badge  Popular Question (source)
2013-12-04 12:38:02 -0600 received badge  Famous Question (source)
2013-12-04 08:33:30 -0600 commented answer rospy and Tkinter - spin() and mainloop()

Amazing, that works. Thanks.

2013-12-03 18:58:11 -0600 received badge  Student (source)
2013-12-03 14:47:43 -0600 asked a question rospy and Tkinter - spin() and mainloop()

I want to write a rospy node that uses Python's GUI toolkit Tkinter, problem is that rospy.spin() and top.mainloop() are both blocking calls.

I thought of starting one and setting an interrupt to start the other, like:

top.after(50, rospy.spin )
top.mainloop()

This successfully starts both loops, but once rospy.spin() starts it completely takes control from Tkinter (until I hit ctrl+c, then Tkinter resumes). What I really want is a rospy.spinOnce() that I can call on Tkinter's repaint cycle, but I gather there isn't such a thing.

Is there a good way to have both top.mainloop() and rospy.spin() running in the same thread? Or at least a work-a-round?

Edit: I found a work-a-round by forking rospy.spin() into it's own thread and protecting all my variables inside the ros callbacks with mutexes like so:

from threading import Thread, Lock

mutex = Lock()

def rosClbk(data) :
    mutex.aquire()
    _var = var
    mutex.release()
    # do processing on _var

def main() :
    ...
    t = Thread(target = rospy.spin )
    t.start()
    top.mainloop()

This makes the program a bit hard to kill (since ros no longer responds to ctrl+c), but otherwise seems to work fine. Is this too dirty? Is there a better way?

2013-11-20 17:51:15 -0600 received badge  Notable Question (source)
2013-10-30 08:22:43 -0600 received badge  Popular Question (source)
2013-10-29 08:21:41 -0600 commented answer What is the cmake catkin variable for the workspace root dir?

Wow, ok. Problem fixed. Thank you very much!!

2013-10-29 08:06:29 -0600 answered a question What is the cmake catkin variable for the workspace root dir?

Here are the CMakeLists.txt files:

ardrone_autonomy (project1) :

cmake_minimum_required(VERSION 2.8.3)
project(ardrone_autonomy)

find_package( catkin REQUIRED COMPONENTS roscpp rospy std_msgs image_transport sensor_msgs std_srvs tf camera_info_manager message_generation  )

#uncomment if you have defined messages or services
add_message_files( FILES
    matrix33.msg
    navdata_adc_data_frame.msg
    navdata_altitude.msg
    navdata_demo.msg
    navdata_euler_angles.msg
    navdata_games.msg
    navdata_gyros_offsets.msg
    navdata_hdvideo_stream.msg
    navdata_kalman_pressure.msg
    navdata_magneto.msg
    Navdata.msg
    navdata_phys_measures.msg
    navdata_pressure_raw.msg
    navdata_pwm.msg
    navdata_raw_measures.msg
    navdata_rc_references.msg
    navdata_references.msg
    navdata_time.msg
    navdata_trackers_send.msg
    navdata_trims.msg
    navdata_video_stream.msg
    navdata_vision_detect.msg
    navdata_vision.msg
    navdata_vision_of.msg
    navdata_vision_perf.msg
    navdata_vision_raw.msg
    navdata_watchdog.msg
    navdata_wifi.msg
    navdata_wind_speed.msg
    navdata_zimmu_3000.msg
    vector21.msg
    vector31.msg
)

add_service_files(
  FILES
  CamSelect.srv
  FlightAnim.srv
  LedAnim.srv
)

generate_messages(
  DEPENDENCIES
  std_msgs
  sensor_msgs
)

catkin_package(
  INCLUDE_DIRS include devel/include
  LIBRARIES ${PROJECT_NAME}
  CATKIN_DEPENDS roscpp std_msgs message_runtime
  DEPENDS libsdl-dev
#  DEPENDS system_lib
)

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)


find_package(Boost REQUIRED COMPONENTS) 
set(SDK ARDroneLib/)
link_directories(${PROJECT_SOURCE_DIR}/lib/)
include_directories(${SDK} ${SDK}/FFMPEG/Includes ${SDK}/Soft/Common ${SDK}/Soft/Lib ${SDK}/VP_SDK ${SDK}/VP_SDK/VP_Os/linux )
add_executable(ardrone_driver src/ardrone_driver.cpp src/video.cpp src/ardrone_sdk.cpp src/teleop_twist.cpp)
target_link_libraries(ardrone_driver ${catkin_LIBRARIES} pc_ardrone avcodec avutil swscale vlib  sdk SDL )

mrl_ardrone (project2) :

cmake_minimum_required(VERSION 2.8.3)
project(mrl_ardrone)

find_package(catkin REQUIRED COMPONENTS roscpp std_msgs cv_bridge ardrone_autonomy )

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES mrl_ardrone
  CATKIN_DEPENDS roscpp std_msgs cv_bridge ardrone_autonomy
#  DEPENDS system_lib
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
  # This is super sketchy, there must be an automated way to do this
  /home/mike/ros_ws/devel/include/
  ${ROS_ROOT}
  ${catkin_INCLUDE_DIRS}
)


## Declare a cpp executable
add_executable( tracker src/tracker/trackerMain.cpp src/tracker/tracker.cpp src/tracker/drone_controller.cpp src/tracker/PID.cpp )

# make sure configure headers are built before any node using them
add_dependencies(tracker ardrone_autonomy) 


add_executable( testMain src/tracker/testMain.cpp src/tracker/drone_controller.cpp src/tracker/PID.cpp )
add_dependencies( testMain ardrone_autonomy )

## Specify libraries to link a library or executable target against
find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})

find_package(cv_bridge)
include_directories(${cv_bridge_INCLUDE_DIRS})

target_link_libraries( tracker
  ${catkin_LIBRARIES}
  ${cv_bridge_INCLUDE_DIRS}
)

target_link_libraries( testMain
  ${catkin_LIBRARIES}
  ${cv_bridge_INCLUDE_DIRS}
)

When I run

~/ros_ws $ catkin_make

I get:

Project 'mrl_ardrone' tried to find library 'ardrone_autonomy'.  The
library is neither a target nor built/installed properly.  Did you compile
project 'ardrone_autonomy'? Did you find_package() it before the
subdirectory containing its code is included?

which suggests to me that my problem is not with the include directory itself, but something more general with CMake not being able to find stuff. But I have no idea.

2013-10-29 07:29:17 -0600 commented answer What is the cmake catkin variable for the workspace root dir?

I have 'include_directories(${catkin_INCLUDE_DIRS})', when I do 'find_package(catkin REQUIRED COMPONENTS package1)' I get: Project 'project2' tried to find library 'project1'. The library is neither a target nor built/installed properly. Did you compile project 'project1'? Did you find_package() it before the subdirectory containing its code is included?

2013-10-29 04:57:24 -0600 asked a question What is the cmake catkin variable for the workspace root dir?

Catkin puts the headers from my custom messages from package1 in

~/ros_ws/devel/include/<package1>/

I want to use them when compiling package2. I am assuming that the CMakeLists.txt for package2 needs a line like

include_directories(
  ${<WORSPACE_ROOT>}/devel/include
  ${catkin_INCLUDE_DIRS}
)

but I don't know the correct variable is for the workspace root, ie ~/ros_ws.

The other question is: is there a better way of doing than than manually specifying the top-level include dir?

Here are the CMakeLists.txt files:

ardrone_autonomy (project1) :

cmake_minimum_required(VERSION 2.8.3)
project(ardrone_autonomy)

find_package( catkin REQUIRED COMPONENTS roscpp rospy std_msgs image_transport sensor_msgs std_srvs tf camera_info_manager message_generation  )

#uncomment if you have defined messages or services
add_message_files( FILES
    matrix33.msg
    navdata_adc_data_frame.msg
    navdata_altitude.msg
    navdata_demo.msg
    navdata_euler_angles.msg
    navdata_games.msg
    navdata_gyros_offsets.msg
    navdata_hdvideo_stream.msg
    navdata_kalman_pressure.msg
    navdata_magneto.msg
    Navdata.msg
    navdata_phys_measures.msg
    navdata_pressure_raw.msg
    navdata_pwm.msg
    navdata_raw_measures.msg
    navdata_rc_references.msg
    navdata_references.msg
    navdata_time.msg
    navdata_trackers_send.msg
    navdata_trims.msg
    navdata_video_stream.msg
    navdata_vision_detect.msg
    navdata_vision.msg
    navdata_vision_of.msg
    navdata_vision_perf.msg
    navdata_vision_raw.msg
    navdata_watchdog.msg
    navdata_wifi.msg
    navdata_wind_speed.msg
    navdata_zimmu_3000.msg
    vector21.msg
    vector31.msg
)

add_service_files(
  FILES
  CamSelect.srv
  FlightAnim.srv
  LedAnim.srv
)

generate_messages(
  DEPENDENCIES
  std_msgs
  sensor_msgs
)

catkin_package(
  INCLUDE_DIRS include devel/include
  LIBRARIES ${PROJECT_NAME}
  CATKIN_DEPENDS roscpp std_msgs message_runtime
  DEPENDS libsdl-dev
#  DEPENDS system_lib
)

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)


find_package(Boost REQUIRED COMPONENTS) 
set(SDK ARDroneLib/)
link_directories(${PROJECT_SOURCE_DIR}/lib/)
include_directories(${SDK} ${SDK}/FFMPEG/Includes ${SDK}/Soft/Common ${SDK}/Soft/Lib ${SDK}/VP_SDK ${SDK}/VP_SDK/VP_Os/linux )
add_executable(ardrone_driver src/ardrone_driver.cpp src/video.cpp src/ardrone_sdk.cpp src/teleop_twist.cpp)
target_link_libraries(ardrone_driver ${catkin_LIBRARIES} pc_ardrone avcodec avutil swscale vlib  sdk SDL )

mrl_ardrone (project2) :

cmake_minimum_required(VERSION 2.8.3)
project(mrl_ardrone)

find_package(catkin REQUIRED COMPONENTS roscpp std_msgs cv_bridge ardrone_autonomy )

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES mrl_ardrone
  CATKIN_DEPENDS roscpp std_msgs cv_bridge ardrone_autonomy
#  DEPENDS system_lib
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
  # This is super sketchy, there must be an automated way to do this
  /home/mike/ros_ws/devel/include/
  ${ROS_ROOT}
  ${catkin_INCLUDE_DIRS}
)


## Declare a cpp executable
add_executable( tracker src/tracker/trackerMain.cpp src/tracker/tracker.cpp src/tracker/drone_controller.cpp src/tracker/PID.cpp )

# make sure configure headers are built before any node using them
add_dependencies(tracker ardrone_autonomy) 


add_executable( testMain src/tracker/testMain.cpp src/tracker/drone_controller.cpp src/tracker/PID.cpp )
add_dependencies( testMain ardrone_autonomy )

## Specify libraries to link a library or executable target against
find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})

find_package(cv_bridge)
include_directories(${cv_bridge_INCLUDE_DIRS})

target_link_libraries( tracker
  ${catkin_LIBRARIES}
  ${cv_bridge_INCLUDE_DIRS}
)

target_link_libraries( testMain
  ${catkin_LIBRARIES}
  ${cv_bridge_INCLUDE_DIRS}
)

When I run

~/ros_ws $ catkin_make

I get:

Project 'mrl_ardrone' tried to find library 'ardrone_autonomy'.  The
library is neither a target nor built/installed properly.  Did you compile
project 'ardrone_autonomy'? Did you find_package() it before the
subdirectory containing its code is included?

which suggests to me that my problem is not with the include directory itself, but something more general with CMake not being able to find stuff. But ... (more)

2013-10-29 04:49:55 -0600 commented answer ardrone_automony is not receiving correct navdata from AR.Drone2.0

Worked like charm, firmware was very easy to downgrade. Thanks!

2013-10-29 04:49:35 -0600 received badge  Supporter (source)
2013-10-29 04:49:30 -0600 received badge  Scholar (source)
2013-10-23 22:01:54 -0600 received badge  Popular Question (source)
2013-10-15 08:46:28 -0600 received badge  Editor (source)
2013-10-15 08:46:28 -0600 edited question ardrone_automony is not receiving correct navdata from AR.Drone2.0

I have been running ardrone_autonomy with an AR.Drone1.0 and it has been working great. Today I bought an AR.Drone2.0 and assumed that my code would work out of the box. Unfortunately ardrone_autonomy ardrone_driver throws this error over and over again:

One option (0) is not a valid option because its size is zero
[Navdata] Checksum failed : 1006 (distant) / 34055 (local)
Tag 12504 is an unknown navdata option tag

Is there something I need to change in the code / launch file to make it compatible with the AR.Drone2.0?

I should also mention (though I don't think it's relevant) that I modified ardrone_autonomy to make it catkin compatible.