Commit c91aad56 authored by Larkin Heintzman's avatar Larkin Heintzman

initial commit

parents
[submodule "motion_capture_system"]
path = motion_capture_system
url = https://github.com/KTH-SML/motion_capture_system.git
/opt/ros/noetic/share/catkin/cmake/toplevel.cmake
\ No newline at end of file
cmake_minimum_required(VERSION 3.0.2)
project(base_station)
## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
roscpp
rospy
sensor_msgs
std_msgs
message_generation
)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()
################################################
## Declare ROS messages, services and actions ##
################################################
## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
## Generate messages in the 'msg' folder
add_message_files(
FILES
JoystickParams.msg
)
## Generate services in the 'srv' folder
add_service_files(
FILES
Overwatch.srv
FlightTaskControl.srv
)
## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
geometry_msgs# sensor_msgs# std_msgs
)
################################################
## Declare ROS dynamic reconfigure parameters ##
################################################
## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed
## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES base_station
# CATKIN_DEPENDS geometry_msgs roscpp rospy sensor_msgs std_msgs
# DEPENDS system_lib
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
## Declare a C++ library
# add_library(${PROJECT_NAME}
# src/${PROJECT_NAME}/base_station.cpp
# )
## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
# add_executable(${PROJECT_NAME}_node src/base_station_node.cpp)
## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node
# ${catkin_LIBRARIES}
# )
#############
## Install ##
#############
# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# catkin_install_python(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark executables for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
# install(TARGETS ${PROJECT_NAME}_node
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark libraries for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
# install(TARGETS ${PROJECT_NAME}
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
# )
## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )
## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
#############
## Testing ##
#############
## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_base_station.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
<launch>
<include file="$(find base_station)/launch/machines.launch"/>
<include file="$(find base_station)/launch/sound_launch.launch">
<arg name="machine_name" value="plathQual"/>
<arg name="sound_file" value="/home/larkin/CantinaBand3.wav"/>
</include>
<!-- <include file="$(find base_station)/launch/sound_launch.launch">
<arg name="machine_name" value="plathQual"/>
<arg name="sound_file" value="/home/larkin/CantinaBand3.wav"/>
</include> -->
</launch>
<launch>
<!-- pick waypoint file here -->
<!-- <rosparam file="$(find base_station)/launch/waypoints_musical_drones.json"/> -->
<!-- clockery -->
<!-- <param name="/use_sim_time" value="true"/> -->
<node name="waypointGenerator" pkg="database_tools" type="waypointGenerator.py">
<rosparam command="load" param="anchorPoint">
<!-- kentland airstrip anchor point -->
<!-- [37.197280, -80.577791] -->
<!-- [37.196986, -80.578257] -->
<!-- long distance tests, kentland -->
[37.196941, -80.578335]
<!-- kentland airstrip anchor point -->
<!-- [37.223166, -80.432788] -->
</rosparam>
<!-- nearby tree variation -->
<rosparam command="load" param="pathPoints">
[
<!-- [37.197879, -80.578022],
[37.198037, -80.577689],
[37.198161, -80.577359],
[37.198161, -80.577072],
[37.197879, -80.576637] -->
]
</rosparam>
<!-- back tree line variation -->
<!-- <rosparam command="load" param="pathPoints">
[
[37.198626, -80.580931],
[37.199075, -80.580430],
[37.199472, -80.580124],
[37.199857, -80.579850],
[37.200139, -80.579378]
]
</rosparam> -->
<!-- front edge tree variation -->
<!-- <rosparam command="load" param="pathPoints">
[
[37.196937, -80.578330],
[37.198991, -80.580222],
[37.199216, -80.579948],
[37.199681, -80.579981],
[37.199446, -80.579800],
[37.199845, -80.578920],
[37.199659, -80.578543],
[37.199359, -80.577830],
[37.199423, -80.577418],
[37.199359, -80.576860],
[37.198569, -80.575857],
[37.196937, -80.578330],
]
</rosparam> -->
<!-- set altitude of all waypoints -->
<rosparam command="load" param="altitude"> 10.0 </rosparam>
<!-- number of drones to generate waypoints for -->
<rosparam command="load" param="droneNum"> 3 </rosparam>
</node>
<!-- then the real qualisys provides the track to follow TESTING -->
<!-- <group ns="tracking">
<include file="$(find mocap_qualisys)/launch/qualisys.launch">
<arg name="server_address" value="192.168.1.207"/>
</include>
</group> -->
<!-- define all names parameter -->
<rosparam command="load" param="nameList">
<!-- ["nerudaQual", "plathQual"] -->
["plathModem"]
</rosparam>
<!-- turn on gui interface -->
<node name="webserver" pkg="database_tools" type="webserver_launch.bash"/>
<!-- load machine names, plath, neruda, and home versions -->
<include file="$(find base_station)/launch/machines.launch"/>
<!-- launch neruda vehicle nodes -->
<include file="$(find base_station)/launch/remote_vehicle.launch">
<arg name="machine_name" value="plathModem"/>
<arg name="machine_id" value="0"/>
</include>
<!-- launch yeats's special bonus nacho flavor nodes -->
<!-- <include file="$(find base_station)/launch/remote_vehicle_yeats.launch">
<arg name="machine_name" value="yeats"/>
<arg name="machine_id" value="2"/>
</include> -->
</launch>
<launch>
<!-- turn on gui interface -->
<node name="webserver" pkg="database_tools" type="webserver_launch.bash"/>
<node name="waypointGenerator" pkg="database_tools" type="waypointGenerator_interface_demo.py">
<rosparam command="load" param="anchorPoint">
<!-- long distance tests, kentland -->
[37.196941, -80.578335]
</rosparam>
<!-- nearby tree variation -->
<rosparam command="load" param="pathPoints">
[
[37.198626, -80.580931],
[37.199075, -80.580430],
[37.199472, -80.580124],
[37.199857, -80.579850],
[37.200139, -80.579378]
]
</rosparam>
<!-- set altitude of all waypoints -->
<rosparam command="load" param="altitude"> 10.0 </rosparam>
<!-- number of drones to generate waypoints for -->
<rosparam command="load" param="droneNum"> 3 </rosparam>
<rosparam command="load" param="angleOffset"> 30.0 </rosparam>
</node>
<group ns="d1">
<param name="drone_id" type="int" value="0"/>
<node name="gps_stream" pkg="database_tools" type="gps_stream.py">
</node>
<node pkg="database_tools" type="sqlite_upload.py" name="sql_uploader"/>
</group>
<group ns="d2">
<param name="drone_id" type="int" value="1"/>
<node name="gps_stream" pkg="database_tools" type="gps_stream.py">
</node>
<node pkg="database_tools" type="sqlite_upload.py" name="sql_uploader"/>
</group>
<group ns="d3">
<param name="drone_id" type="int" value="2"/>
<node name="gps_stream" pkg="database_tools" type="gps_stream.py">
</node>
<node pkg="database_tools" type="sqlite_upload.py" name="sql_uploader"/>
</group>
</launch>
<launch>
<machine name="neruda" address="192.168.1.101" env-loader="/opt/ros/noetic/neruda_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="plath" address="192.168.1.102" env-loader="/opt/ros/noetic/plath_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="plathHouse" address="192.168.1.24" env-loader="/opt/ros/noetic/plath_house_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="nerudaHouse" address="192.168.1.191" env-loader="/opt/ros/noetic/neruda_house_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="plathPerf" address="192.168.1.10" env-loader="/opt/ros/noetic/plath_perf_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="plathModem" address="192.168.111.202" env-loader="/opt/ros/noetic/plath_modem_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="nerudaModem" address="192.168.111.201" env-loader="/opt/ros/noetic/neruda_modem_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="plathQual" address="192.168.1.18" env-loader="/opt/ros/noetic/plath_qual_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="nerudaQual" address="192.168.1.19" env-loader="/opt/ros/noetic/neruda_qual_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="yeats" address="192.168.1.103" env-loader="/opt/ros/noetic/yeats_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="yeatsHouse" address="192.168.1.198" env-loader="/opt/ros/noetic/yeats_house_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="yeatsModem" address="192.168.111.203" env-loader="/opt/ros/noetic/yeats_modem_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
</launch>
<launch>
<!-- do this for each drone you wish to launch -->
<!-- argument for machine name -->
<arg name="machine_name"/>
<!-- argument for machine id -->
<arg name="machine_id"/>
<group ns="$(arg machine_name)">
<!-- <group ns="plath-house"> -->
<!-- <arg name="machine_name"/> -->
<!-- <arg name="machine_id"/> -->
<node pkg="dji_osdk_ros" type="dji_vehicle_node" name="vehicle_node" output="screen" machine="$(arg machine_name)">
<param name="acm_name" type="string" value="/dev/ttyACM0"/>
<param name="serial_name" type="string" value="/dev/dji_usb"/>
<param name="baud_rate" type="int" value="921600"/>
<param name="app_id" type="int" value="1069806"/>
<param name="app_version" type="int" value="1"/>
<param name="align_time" type="bool" value="false"/>
<param name="enc_key" type="string" value="e180b993ca8365653437fbafe7211ba040386d77c3c87627882857a11bd8efbd"/>
<param name="use_broadcast" type="bool" value="false"/>
</node>
<!-- drone number, passed argument -->
<param name="drone_id" type="int" value="$(arg machine_id)"/>
<!-- camera_type to use for images, 0 for fpv camera and 1 for gimbal camera -->
<param name="camera_type" type="int" value="1"/>
<!-- base movement speed through waypoints -->
<param name="base_speed" type="double" value="4.0"/>
<!-- maximum speed for waypoint traverse -->
<param name="max_speed" type="double" value="4.0"/>
<!-- relative motion speed scalar -->
<param name="speed_scalar" type="double" value="1"/>
<!-- <param name="speed_scalar" type="double" value="5.0"/> -->
<!-- minimum allowed speed during relative motion -->
<param name="min_speed" type="double" value="0.01"/>
<!-- maximum yaw speed degs/s -->
<param name="max_yaw_speed" type="double" value="5.0"/>
<!-- <param name="max_yaw_speed" type="double" value="0.0"/> -->
<!-- whether we are mimicing playback or not -->
<!-- <param name="position_playback" type="bool" value="true"/> -->
<param name="position_playback" type="bool" value="false"/>
<!-- actual control loop time lol -->
<param name="loop_rate" type="double" value="5"/>
<!-- inverse controller damping value -->
<param name="controller_damping" type="double" value="20"/>
<!-- inverse controller frequency value -->
<param name="controller_frequency" type="double" value="0.2"/>
<!-- waypoint loading node -->
<!-- <group if="$(eval arg('machine_id') == 1)"> -->
<node pkg="dji_osdk_ros" type="bus_driver" name="bus_driver" output="screen" machine="$(arg machine_name)"/>
<!-- </group> -->
<!-- gui interface and imaging nodes -->
<node pkg="dji_osdk_ros" type="image_activation.py" name="image_activation" output="screen" machine="$(arg machine_name)"/>
<node pkg="database_tools" type="sqlite_upload.py" name="sql_uploader"/>
<node name="image_handler" pkg="database_tools" type="image_handler.py"/>
<!-- QUALISYS BULLSHIT -->
<!-- qualisys-like gps reference -->
<node name="qualisysSpoof" pkg="database_tools" type="qualisysSpoof.py">
<rosparam command="load" param="anchorPoint"> [37.196941, -80.578335] </rosparam>
</node>
<!-- if doing position playback -->
<node pkg="dji_osdk_ros" type="qualisysFeedback.py" name="qualisysTracking" output="screen" machine="$(arg machine_name)">
<!-- <param name="trackName" type="string" value="$(arg machine_name)"/> -->
<param name="trackName" type="string" value="plathQual"/>
<param name="qualisysName" type="string" value="tracking"/>
</node>
<!-- sound stuff -->
<!-- <arg name="device" default="front:CARD=Headset,DEV=0"/> -->
<!-- <remap from="robotsound" to="$(arg machine_name)/robotsound"/> -->
<!-- <node pkg="sound_play" type="soundplay_node.py" name="soundplay_node" machine="$(arg machine_name)">
<param name="device" value="$(arg device)"/>
</node> -->
</group>
</launch>
<launch>
<!-- do this for each drone you wish to launch -->
<!-- argument for machine name -->
<arg name="machine_name"/>
<!-- argument for machine id -->
<arg name="machine_id"/>
<group ns="$(arg machine_name)">
<!-- <group ns="plath-house"> -->
<!-- <arg name="machine_name"/> -->
<!-- <arg name="machine_id"/> -->
<node pkg="dji_sdk" type="dji_sdk_node" name="dji_sdk" output="screen" machine="$(arg machine_name)">
<param name="acm_name" type="string" value="/dev/ttyACM0"/>
<param name="serial_name" type="string" value="/dev/dji_usb"/>
<param name="baud_rate" type="int" value="921600"/>
<param name="app_id" type="int" value="1069806"/>
<param name="app_version" type="int" value="1"/>
<param name="align_time" type="bool" value="false"/>
<param name="enc_key" type="string" value="e180b993ca8365653437fbafe7211ba040386d77c3c87627882857a11bd8efbd"/>
<param name="use_broadcast" type="bool" value="false"/>
</node>
<!-- drone number, passed argument -->
<param name="drone_id" type="int" value="$(arg machine_id)"/>
<!-- camera_type to use for images, 0 for fpv camera and 1 for gimbal camera -->
<param name="camera_type" type="int" value="1"/>
<!-- base movement speed through waypoints -->
<!-- <param name="base_speed" type="double" value="0.5"/> -->
<param name="base_speed" type="double" value="5.0"/>
<!-- maximum speed for waypoint traverse -->
<!-- <param name="max_speed" type="double" value="1.0"/> -->
<param name="max_speed" type="double" value="5.0"/>
<!-- relative motion speed scalar -->
<!-- <param name="speed_scalar" type="double" value="0.01"/> -->
<param name="speed_scalar" type="double" value="5.0"/>
<!-- minimum allowed speed during relative motion -->
<param name="min_speed" type="double" value="0.1"/>
<!-- maximum yaw speed degs/s -->
<param name="max_yaw_speed" type="double" value="30.0"/>
<!-- whether we are mimicing playback or not -->
<!-- <param name="position_playback" type="bool" value="true"/> -->
<param name="position_playback" type="bool" value="false"/>
<!-- maximum move distance allowed, loop time sort of -->
<param name="std_move_dist" type="double" value="1.0"/>
<!-- waypoint loading node -->
<!-- <group if="$(eval arg('machine_id') == 1)"> -->
<node pkg="bus_driver" type="bus_driver_node" name="bus_driver_node" output="screen" machine="$(arg machine_name)"/>
<!-- </group> -->
<!-- gui interface and imaging nodes -->
<node pkg="bus_driver" type="image_activation.py" name="image_activation" output="screen" machine="$(arg machine_name)"/>
<node pkg="database_tools" type="sqlite_upload_yeats.py" name="sql_uploader"/>
<node name="image_handler" pkg="database_tools" type="image_handler.py"/>
<!-- <node pkg="bus_driver" type="poseFeedbackConversion.py" name="poseFeedbackConversion" output="screen" machine="$(arg machine_name)">
<rosparam command="load" param="angleOffset">
-33.0
</rosparam>
</node> -->
<!-- <node name="image_handler" pkg="database_tools" type="image_handler.py"/> -->
<!-- position sync node, if id == 0 -->
<!-- <group if="$(eval arg('machine_id') == 0)">
<node pkg="position_sync" type="position_sync_node" name="syncNode" output="screen" machine="$(arg machine_name)"/>
</group> -->
</group>
</launch>
<launch>
<!-- argument for machine name -->
<arg name="machine_name"/>
<!-- argument for which file to play -->
<arg name="sound_file"/>
<!-- <group ns="$(arg machine_name)"> -->
<remap from="/robotsound" to="/$(arg machine_name)/robotsound"/>
<node pkg="sound_play" type="play.py" name="play" args="$(arg sound_file)" machine="$(arg machine_name)"/>
<!-- </group> -->
</launch>
<launch>
<param name="/use_sim_time" value="true"/>
</launch>
float32 x # Control with respect to the x axis of the
# DJI::OSDK::Control::HorizontalCoordinate.
float32 y # Control with respect to the y axis of the
# DJI::OSDK::Control::HorizontalCoordinate.
float32 z # Control with respect to the z axis, up is positive.
float32 yaw #Yaw position/velocity control w.r.t. the ground frame.
\ No newline at end of file
<?xml version="1.0"?>
<package format="2">
<name>base_station</name>
<version>0.0.0</version>
<description>The base_station package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<maintainer email="llh@todo.todo">llh</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/base_station</url> -->
<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Authors do not have to be maintainers, but could be -->
<!-- Example: -->
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
<!-- The *depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
<!-- <depend>roscpp</depend> -->
<!-- Note that this is equivalent to the following: -->
<!-- <build_depend>roscpp</build_depend> -->
<!-- <exec_depend>roscpp</exec_depend> -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use build_export_depend for packages you need in order to build against this package: -->
<!-- <build_export_depend>message_generation</build_export_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use exec_depend for packages you need at runtime: -->
<!-- <exec_depend>message_runtime</exec_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<!-- Use doc_depend for packages you need only for building documentation: -->
<!-- <doc_depend>doxygen</doc_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>message_generation</build_depend>
<build_export_depend>geometry_msgs</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>message_runtime</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
#! /usr/bin/python3
# rospy for the subscriber
import rospy
from base_station.srv import Overwatch
import sys
def main(action, name):
# read in parameters from command line
# namespc = str(rospy.get_param("~name"))
# act = int(action)
namespc = str(name)
action = int(action)
rospy.init_node("overwatchControl_" + namespc + "_" + str(action), anonymous = True)
srvName = namespc + "/overwatch"
rospy.loginfo("calling overwatch control service...")
rospy.loginfo("namespace: " + namespc)
rospy.loginfo("action: " + str(action))
# print("namespace: " + namespc)
# print("action: " + str(action))
# request drone to open stereo images
rospy.wait_for_service(srvName)
service_proxy = rospy.ServiceProxy(srvName, Overwatch)
response = service_proxy(start = True, action = action) # go baby go
rospy.loginfo(response)
if __name__ == "__main__":
main(sys.argv[1], sys.argv[2])
#!/bin/bash
# source ros stuff
source ~/.bashrc
# run requested node(s)
echo "Running command $1 on all drones..."
for n in $(rosparam get /nameList)
do
if [[ "$n" != "-" ]]
then
echo "running $1 on $n ..." &
# do drone control for each
rosrun base_station droneControl.py $1 $n &
fi
done
echo "done on all nodes."
#constant for tasks
uint8 TASK_GOHOME = 1
uint8 TASK_POSITION_AND_YAW_CONTROL = 2
uint8 TASK_GOHOME_AND_CONFIRM_LANDING = 3
uint8 TASK_TAKEOFF = 4
uint8 TASK_VELOCITY_AND_YAWRATE_CONTROL = 5
uint8 TASK_LAND = 6
uint8 START_MOTOR = 7
uint8 STOP_MOTOR = 8
uint8 TASK_EXIT_GO_HOME = 12
uint8 TASK_EXIT_LANDING = 14
uint8 TASK_FORCE_LANDING_AVOID_GROUND = 30 #/*!< confirm landing */
uint8 TASK_FORCE_LANDING = 31 #/*!< force landing */
#request
uint8 task # see constants above for possible tasks
JoystickParams joystickCommand #Provide Position and Velocity control
uint32 velocityControlTimeMs #Velocity control time
float32 posThresholdInM #(Meter)
float32 yawThresholdInDeg #(Degree)
---
#response
bool result
# constants for different actions
uint8 START_WAYPOINT_PATH = 1
uint8 START_POSITION_PATH = 2
uint8 STOP_MOTION = 3
uint8 LAND = 4
uint8 GO_HOME = 5
uint8 TAKEOFF = 6
uint8 CALIBRATE_POS_REF = 7
# request
bool start
uint8 action
---
# response
bool result
cmake_minimum_required(VERSION 3.0.2)
project(database_tools)
## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
roscpp
rospy
sensor_msgs
std_msgs
)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()
################################################
## Declare ROS messages, services and actions ##
################################################
## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
## Generate messages in the 'msg' folder
# add_message_files(
# FILES
# Message1.msg
# Message2.msg
# )
## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )
## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )
## Generate added messages and services with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# geometry_msgs# sensor_msgs# std_msgs
# )
################################################
## Declare ROS dynamic reconfigure parameters ##
################################################
## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed
## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES database_tools
# CATKIN_DEPENDS geometry_msgs roscpp rospy sensor_msgs std_msgs
# DEPENDS system_lib
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
## Declare a C++ library
# add_library(${PROJECT_NAME}
# src/${PROJECT_NAME}/database_tools.cpp
# )
## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
# add_executable(${PROJECT_NAME}_node src/database_tools_node.cpp)
## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node
# ${catkin_LIBRARIES}
# )
#############
## Install ##
#############
# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# catkin_install_python(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark executables for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
# install(TARGETS ${PROJECT_NAME}_node
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark libraries for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
# install(TARGETS ${PROJECT_NAME}
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
# )
## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )
## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
#############
## Testing ##
#############
## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_database_tools.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
<launch>
<!-- machine name, also namespace -->
<arg name="machine_name"/>
<!-- machine id -->
<arg name="machine_id"/>
<group ns="$(arg machine_name)">
<param name="drone_id" type="int" value="$(arg machine_id)"/>
<node pkg="database_tools" type="sqlite_upload.py" name="sql_uploader"/>
<node name="image_handler" pkg="database_tools" type="image_handler.py"/>
</group>
<!--
<group ns="nerudaHouse">
<param name="drone_id" type="int" value="0"/>
<node pkg="database_tools" type="sqlite_upload.py" name="sql_uploader"/>
<node name="image_handler" pkg="database_tools" type="image_handler.py"/>
</group>
<group ns="plathHouse">
<param name="drone_id" type="int" value="1"/>
<node pkg="database_tools" type="sqlite_upload.py" name="sql_uploader"/>
<node name="image_handler" pkg="database_tools" type="image_handler.py"/>
</group> -->
</launch>
<launch>
<node name="webserver" pkg="database_tools" type="webserver_launch.bash"/>
<rosparam file="$(find base_station)/launch/waypoints_musical_drones.json"/>
<group ns="nerudaHouse">
<param name="drone_id" type="int" value="0"/>
<node pkg="database_tools" type="sqlite_upload.py" name="sql_uploader"/>
<node name="image_handler" pkg="database_tools" type="image_handler.py"/>
<node pkg="database_tools" type="gps_stream.py" name="gps_streamer"/>
</group>
<group ns="plathHouse">
<param name="drone_id" type="int" value="1"/>
<node pkg="database_tools" type="sqlite_upload.py" name="sql_uploader"/>
<node name="image_handler" pkg="database_tools" type="image_handler.py"/>
<node pkg="database_tools" type="gps_stream.py" name="gps_streamer"/>
</group>
</launch>
<launch>
<node name="waypointGenerator" pkg="database_tools" type="waypointGenerator.py">
<rosparam command="load" param="anchorPoint">
<!-- kentland airstrip anchor point -->
<!-- [37.197280, -80.577791] -->
[37.196986, -80.578257]
<!-- kentland airstrip anchor point -->
<!-- [37.223166, -80.432788] -->
</rosparam>
<!-- set altitude of all waypoints -->
<rosparam command="load" param="altitude"> 2.0 </rosparam>
<!-- number of drones to generate waypoints for -->
<rosparam command="load" param="droneNum"> 3 </rosparam>
</node>
</launch>
<?xml version="1.0"?>
<package format="2">
<name>database_tools</name>
<version>0.0.0</version>
<description>The database_tools package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<maintainer email="llh@todo.todo">llh</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/database_tools</url> -->
<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Authors do not have to be maintainers, but could be -->
<!-- Example: -->
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
<!-- The *depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
<!-- <depend>roscpp</depend> -->
<!-- Note that this is equivalent to the following: -->
<!-- <build_depend>roscpp</build_depend> -->
<!-- <exec_depend>roscpp</exec_depend> -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use build_export_depend for packages you need in order to build against this package: -->
<!-- <build_export_depend>message_generation</build_export_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use exec_depend for packages you need at runtime: -->
<!-- <exec_depend>message_runtime</exec_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<!-- Use doc_depend for packages you need only for building documentation: -->
<!-- <doc_depend>doxygen</doc_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>geometry_msgs</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
#!/usr/bin/python3
import rospy
from sensor_msgs.msg import NavSatFix
import json
from tools import meters2lat_lon, lat_lon2meters
import numpy as np
def normalize(v):
norm = np.linalg.norm(v)
if norm == 0:
return v
return v / norm
if __name__ == "__main__":
rospy.init_node("gps_streamer")
pub = rospy.Publisher("dji_osdk_ros/gps_position", NavSatFix, queue_size=10)
drone_id = rospy.get_param("drone_id")
updateRate = rospy.Rate(20)
while not rospy.has_param('/robot_list/robot_' + str(drone_id) + '/waypoints'):
rospy.loginfo("waiting for parameter...")
updateRate.sleep()
waypointDict = rospy.get_param("/robot_list/robot_" + str(drone_id) + "/waypoints")
index = 0
seq = 0
vecPosition = np.array([waypointDict["waypoint_" + str(index)][1], waypointDict["waypoint_" + str(index)][2]])
# anchorPoint = [37.223162, -80.432770]
# Pi = 3.1415924
rate = rospy.Rate(10) # publish at 10hz
while not rospy.is_shutdown():
target = waypointDict["waypoint_" + str(index)]
vecTarget = np.array([target[1], target[2]])
vecPosition = vecPosition + 0.000001*normalize(vecTarget - vecPosition)
# check if close to target
if np.linalg.norm(vecTarget - vecPosition) < 0.000005 and index < (len(waypointDict) - 1):
# made it to waypoint, pick next one`
index = index + 1
gpsMsg = NavSatFix()
# gpsMsg.header = 0
gpsMsg.header.seq = seq
# gpsMsg.header.stamp.secs = int(rospy.get_time())
# gpsMsg.header.frame_id = 'gps'
gpsMsg.latitude = vecPosition[0]
gpsMsg.longitude = vecPosition[1]
gpsMsg.altitude = 5.0
pub.publish(gpsMsg)
seq += 1
updateRate.sleep()
#!/usr/bin/python3
import rospy
import cv2
# ROS Image message
from sensor_msgs.msg import Image
# ROS Image message -> OpenCV2 image converter
from cv_bridge import CvBridge, CvBridgeError
# OpenCV2 for saving an image
# Instantiate CvBridge
bridge = CvBridge()
def image_callback(msg):
try:
# Convert your ROS Image message to OpenCV2
cv2_img = bridge.imgmsg_to_cv2(msg, "bgr8")
rospy.loginfo("received new image.")
# Save your OpenCV2 image as a jpeg
cv2.imwrite('/home/llh/sarwebui/media/droneimages/camera_image.jpeg', cv2_img)
except CvBridgeError as e:
print(e)
def main():
rospy.init_node('image_handler')
# Define your image topic
if (rospy.get_param('camera_type') == 0):
image_topic = "dji_osdk_ros/fpv_camera_images"
else:
image_topic = "dji_osdk_ros/main_camera_images"
# Set up your subscriber and define its callback
rospy.Subscriber(image_topic, Image, image_callback)
# Spin until ctrl + c
rospy.loginfo("image handler ready for images...")
rospy.spin()
if __name__ == '__main__':
main()
#!/usr/bin/python3
from tools import meters2lat_lon, lat_lon2meters, normalizeAngle
import numpy as np
import rospy
def generateWaypoints():
rospy.init_node("waypointGenerator")
anchorPoint = rospy.get_param("~anchorPoint")
waypointAltitude = rospy.get_param("~altitude")
# ring sizes
big = 10
med = 5
sml = 3
apMeters = lat_lon2meters(anchorPoint)
waypointOffsets = [
[-big, -big],
[big, -big],
[big, big],
[med, med],
[-med, med],
[-med, -med],
[-sml, -sml],
[sml, -sml],
[sml, sml],
[big, -big],
]
tempDict = {"waypoints" : {}, "positions" : {}, "numWaypoints" : 0, "numPositions" : 0}
waypointDict = {"robot_0" : tempDict, "robot_1" : tempDict}
numWaypoints = len(waypointOffsets)
numPositions = len(waypointOffsets) # TODO, add position list to parameters
for i, offset in enumerate(waypointOffsets):
waypointLatLon = meters2lat_lon([apMeters[0] + offset[0], apMeters[1] + offset[1]])
waypointLatLonRev = meters2lat_lon([apMeters[0] - offset[0], apMeters[1] - offset[1]])
waypointHeading = normalizeAngle(45*i)
# waypoints
waypointDict["robot_0"]["waypoints"].update({"waypoint_{}".format(i) : [i, waypointLatLon[0], waypointLatLon[1], waypointAltitude, waypointHeading]})
waypointDict["robot_1"]["waypoints"].update({"waypoint_{}".format(i) : [i, waypointLatLonRev[0], waypointLatLonRev[1], waypointAltitude, waypointHeading]})
# positions
waypointDict["robot_0"]["positions"].update({"position_{}".format(i) : [i, offset[0], offset[1], waypointAltitude, waypointHeading]})
waypointDict["robot_1"]["positions"].update({"position_{}".format(i) : [i, -offset[0], -offset[1], waypointAltitude, waypointHeading]})
# do this betta
waypointDict["robot_0"]["numWaypoints"] = numWaypoints
waypointDict["robot_0"]["numPositions"] = numPositions
waypointDict["robot_1"]["numWaypoints"] = numWaypoints
waypointDict["robot_1"]["numPositions"] = numPositions
rospy.set_param("/robot_list", waypointDict)
if __name__ == "__main__":
generateWaypoints()
#!/usr/bin/python3
import rospy
import numpy as np
from sensor_msgs.msg import NavSatFix
from sensor_msgs.msg import Imu
from std_msgs.msg import Float32
from geometry_msgs.msg import PointStamped
from geometry_msgs.msg import QuaternionStamped
from geometry_msgs.msg import Transform
from geometry_msgs.msg import Vector3
from geometry_msgs.msg import Quaternion
# from scipy.spatial.transform import Rotation
from tools import lat_lon2meters, meters2lat_lon
import math
from pyproj import Transformer
def point_rotation(origin, pt, ang):
# returns the pt rotated about the origin by ang (ang in degrees)
c = math.cos(math.radians(ang))
s = math.sin(math.radians(ang))
# translate to origin
pt_temp = [pt[0] - origin[0], pt[1] - origin[1]]
pt_spun = [ pt_temp[0]*c - pt_temp[1]*s, pt_temp[0]*s + pt_temp[1]*c ]
# translate back to frame
pt_spun = [pt_spun[0] + origin[0], pt_spun[1] + origin[1]]
return pt_spun
def meters2lat_lon(meters_point):
# returns point converted to lat lon from meters coordinate system
transformer = Transformer.from_crs(3857, 4326)
latlon_point = transformer.transform(meters_point[0], meters_point[1])
return latlon_point
def lat_lon2meters(latlon_point):
# returns point converted to meters from lat lon coordinate system
transformer = Transformer.from_crs(4326, 3857)
meters_point = transformer.transform(latlon_point[0], latlon_point[1])
return meters_point
def heightCallback(data):
global height
height = data.data
def rotCallback(data):
global quat
quat = data.quaternion
def gpsCallback(data):
global quat
global height
# convert and compare against home point
anchorPoint = rospy.get_param("~anchorPoint")
apMeters = lat_lon2meters([anchorPoint[0], anchorPoint[1]])
cpMeters = lat_lon2meters([data.latitude, data.longitude])
currentOffset = [cpMeters[0] - apMeters[0], cpMeters[1] - apMeters[1]]
# performing dark magics
translation = Vector3()
translation.x = currentOffset[1]
translation.y = currentOffset[0]
translation.z = height
transform = Transform()
transform.translation = translation
transform.rotation = quat
posePublisher.publish(transform)
# standing in for the feedback qualisys stream
posePublisher = rospy.Publisher("feedback", Transform, queue_size = 1)
quat = Quaternion()
height = 0.0
def main():
rospy.init_node("qualisysSpoof")
anchorPoint = rospy.get_param("~anchorPoint")
# dumb just use name spaces
rospy.Subscriber("dji_osdk_ros/gps_position", NavSatFix, gpsCallback, queue_size = 1)
rospy.Subscriber("dji_osdk_ros/attitude", QuaternionStamped, rotCallback, queue_size = 1)
rospy.Subscriber("dji_osdk_ros/height_above_takeoff", Float32, heightCallback, queue_size = 1)
rospy.spin()
# get anchor point from params
if __name__ == '__main__':
main()
#!/usr/bin/python3
import requests
import rospy
from sensor_msgs.msg import NavSatFix
import json
import datetime
# # create a new device, deviceis is the primary key
# r = requests.post('http://127.0.0.1:8000/app3/gpsdatas/',auth=('username','password'), data = {'deviceid':'max_testing', 'taskid':'sar_put2','gpsdata':'{'gps':['stamp':004,'lat':-81,'log':37]}'})
#
# # update record based on primary key. For example: './max_testing/' is added as pk
# r = requests.patch('http://127.0.0.1:8000/app3/gpsdatas/max_testing/', auth=('username','password'), data = {'deviceid':'max_testing', 'taskid':'sar_put2','gpsdata':'{'gps':['stamp':004,'lat':-80,'log':38]}'})
def callback(data, args):
deviceId = args[0]
taskId = args[1]
authorization = args[2]
baseTable = args[3]
gpsTable = args[4]
#rospy.loginfo(rospy.get_caller_id() + '%s', data)
#rospy.loginfo('connection status: ' + str(mydb.is_connected()))
if data.header.seq % 10 == 0: # only update every 10th message to avoid over crowding the sql
gps_data = {
'gps' : [
{
'stamp' : data.header.seq,
'timestamp' : data.header.stamp.secs,
'lat' : data.latitude,
'long' : data.longitude
},
]
}
gpsData = {'deviceid':deviceId, 'taskid':taskId, 'gpsdata' : json.dumps(gps_data)}
try:
r = requests.patch(baseTable + gpsTable + deviceId + '/',auth=authorization, data = gpsData)
except:
pass
print("aw fuck it")
def main():
baseTable = 'http://127.0.0.1:8000'
gpsTable = '/gpsdatas/'
waypointTable = '/waypointsdata/'
authorization = ('larkinheintzman','password')
deviceId = 'drone_' + str(rospy.get_param('drone_id'))
taskId = 'task_0'
topic = 'dji_osdk_ros/gps_position'
rospy.init_node('sql_uploader', anonymous = True)
rospy.Subscriber(topic, NavSatFix, callback, (deviceId, taskId, authorization, baseTable, gpsTable), queue_size = 1)
updateRate = rospy.Rate(20)
while not rospy.has_param('/robot_list/robot_' + str(rospy.get_param('drone_id')) + '/waypoints'):
rospy.loginfo("waiting for parameter...")
updateRate.sleep()
# upload waypoints to GUI
waypoint_dict = rospy.get_param('/robot_list/robot_' + str(rospy.get_param('drone_id')) + '/waypoints')
# rospy.loginfo("waypoint dict:")
# rospy.loginfo(waypoint_dict)
waypoint_json = []
for i,pt in enumerate(waypoint_dict.keys()):
waypoint_json.append({'stamp' : waypoint_dict[pt][0], 'timestamp' : -1, 'lat' : waypoint_dict[pt][1], 'long' : waypoint_dict[pt][2]}) # leaving out altitude for now!
waypoint_json = sorted(waypoint_json, key = lambda i: i['stamp'])
waypointData = {'deviceid':deviceId, 'taskid':taskId, 'waypointsdata' : json.dumps(waypoint_json)}
try:
# post new vehicle
r = requests.post(baseTable + waypointTable, auth=authorization, data = waypointData)
# patch old vehicle's waypoints
r = requests.patch(baseTable + waypointTable + deviceId + '/', auth=authorization, data = waypointData)
except:
rospy.loginfo("could not post waypoints")
# also create (post) new device on table
gps_data = {
'gps' : [
{
'stamp' : 0,
'timestamp' : 0,
'lat' : 37.0,
'long' : -80
},
]
}
gpsData = {'deviceid':deviceId, 'taskid':taskId, 'gpsdata' : json.dumps(gps_data)}
try:
r = requests.post(baseTable + gpsTable,auth=authorization, data = gpsData)
rospy.loginfo('waypoints updated')
except:
rospy.loginfo("could not post new gps")
rospy.spin()
if __name__ == '__main__':
main()
#!/usr/bin/python3
import requests
import rospy
from sensor_msgs.msg import NavSatFix
import json
import datetime
# # create a new device, deviceis is the primary key
# r = requests.post('http://127.0.0.1:8000/app3/gpsdatas/',auth=('username','password'), data = {'deviceid':'max_testing', 'taskid':'sar_put2','gpsdata':'{'gps':['stamp':004,'lat':-81,'log':37]}'})
#
# # update record based on primary key. For example: './max_testing/' is added as pk
# r = requests.patch('http://127.0.0.1:8000/app3/gpsdatas/max_testing/', auth=('username','password'), data = {'deviceid':'max_testing', 'taskid':'sar_put2','gpsdata':'{'gps':['stamp':004,'lat':-80,'log':38]}'})
def callback(data, args):
deviceId = args[0]
taskId = args[1]
authorization = args[2]
baseTable = args[3]
gpsTable = args[4]
#rospy.loginfo(rospy.get_caller_id() + '%s', data)
#rospy.loginfo('connection status: ' + str(mydb.is_connected()))
if data.header.seq % 10 == 0: # only update every 10th message to avoid over crowding the sql
gps_data = {
'gps' : [
{
'stamp' : data.header.seq,
'timestamp' : data.header.stamp.secs,
'lat' : data.latitude,
'long' : data.longitude
},
]
}
gpsData = {'deviceid':deviceId, 'taskid':taskId, 'gpsdata' : json.dumps(gps_data)}
try:
r = requests.patch(baseTable + gpsTable + deviceId + '/',auth=authorization, data = gpsData)
except:
pass
print("aw fuck it")
def main():
baseTable = 'http://127.0.0.1:8000'
gpsTable = '/gpsdatas/'
waypointTable = '/waypointsdata/'
authorization = ('larkinheintzman','password')
deviceId = 'drone_' + str(rospy.get_param('drone_id'))
taskId = 'task_0'
topic = 'dji_sdk/gps_position'
rospy.init_node('sql_uploader')
rospy.Subscriber(topic, NavSatFix, callback, (deviceId, taskId, authorization, baseTable, gpsTable))
updateRate = rospy.Rate(20)
while not rospy.has_param('/robot_list/robot_' + str(rospy.get_param('drone_id')) + '/waypoints'):
rospy.loginfo("waiting for parameter...")
updateRate.sleep()
# upload waypoints to GUI
waypoint_dict = rospy.get_param('/robot_list/robot_' + str(rospy.get_param('drone_id')) + '/waypoints')
# rospy.loginfo("waypoint dict:")
# rospy.loginfo(waypoint_dict)
waypoint_json = []
for i,pt in enumerate(waypoint_dict.keys()):
waypoint_json.append({'stamp' : waypoint_dict[pt][0], 'timestamp' : -1, 'lat' : waypoint_dict[pt][1], 'long' : waypoint_dict[pt][2]}) # leaving out altitude for now!
waypoint_json = sorted(waypoint_json, key = lambda i: i['stamp'])
waypointData = {'deviceid':deviceId, 'taskid':taskId, 'waypointsdata' : json.dumps(waypoint_json)}
try:
# post new vehicle
r = requests.post(baseTable + waypointTable, auth=authorization, data = waypointData)
# patch old vehicle's waypoints
r = requests.patch(baseTable + waypointTable + deviceId + '/', auth=authorization, data = waypointData)
except:
rospy.loginfo("could not post waypoints")
# also create (post) new device on table
gps_data = {
'gps' : [
{
'stamp' : 0,
'timestamp' : 0,
'lat' : 37.0,
'long' : -80
},
]
}
gpsData = {'deviceid':deviceId, 'taskid':taskId, 'gpsdata' : json.dumps(gps_data)}
try:
r = requests.post(baseTable + gpsTable,auth=authorization, data = gpsData)
except:
rospy.loginfo("could not post new gps")
rospy.loginfo('waypoints updated')
rospy.spin()
if __name__ == '__main__':
main()
from pyproj import Transformer
import math
def meters2lat_lon(meters_point):
# returns point converted to lat lon from meters coordinate system
transformer = Transformer.from_crs(3857, 4326)
latlon_point = transformer.transform(meters_point[0], meters_point[1])
return latlon_point
def lat_lon2meters(latlon_point):
# returns point converted to meters from lat lon coordinate system
transformer = Transformer.from_crs(4326, 3857)
meters_point = transformer.transform(latlon_point[0], latlon_point[1])
return meters_point
def normalizeAngle(angle):
newAngle = angle%360
newAngle = (newAngle + 360)%360
if(newAngle >= 180):
newAngle -= 360
return newAngle
def point_rotation(origin, pt, ang):
# returns the pt rotated about the origin by ang (ang in degrees)
c = math.cos(math.radians(ang))
s = math.sin(math.radians(ang))
# translate to origin
pt_temp = [pt[0] - origin[0], pt[1] - origin[1]]
pt_spun = [ pt_temp[0]*c - pt_temp[1]*s, pt_temp[0]*s + pt_temp[1]*c ]
# translate back to frame
pt_spun = [pt_spun[0] + origin[0], pt_spun[1] + origin[1]]
return pt_spun
#!/usr/bin/python3
from tools import meters2lat_lon, lat_lon2meters, normalizeAngle, point_rotation
import numpy as np
import rospy
def generateWaypoints():
rospy.init_node("waypointGenerator")
anchorPoint = rospy.get_param("~anchorPoint")
pathPoints = rospy.get_param("~pathPoints")
baseWaypointAltitude = rospy.get_param("~altitude")
droneNum = rospy.get_param("~droneNum")
angleOffset = rospy.get_param("~angleOffset")
# waypointAltitudeIncrement = baseWaypointAltitude # increase altitude for each drone in team
waypointAltitudeIncrement = 10 # increase altitude for each drone in team
# decide if path is "preplanned" or not
if (len(pathPoints) != 0):
apMeters = lat_lon2meters(anchorPoint)
tempDict = {"waypoints" : {}, "positions" : {}, "numWaypoints" : 0, "numPositions" : 0}
waypointDict = {}
# define dictionary
numWaypoints = len(pathPoints)
numPositions = len(pathPoints)
for d in range(droneNum):
# rospy.loginfo("blah!")
# print(d)
waypointDict["robot_{}".format(d)] = {}
waypointDict["robot_{}".format(d)] = {}
waypointDict["robot_{}".format(d)]["waypoints"] = {}
waypointDict["robot_{}".format(d)]["positions"] = {}
for i, pt in enumerate(pathPoints):
# for i, offset in enumerate(waypointOffsets):
waypointLatLon = pt
waypointHeading = 0.0
# waypointHeading = normalizeAngle(45*i)
latLonPt = lat_lon2meters(pt)
positionXY = [latLonPt[0] - apMeters[0], latLonPt[1] - apMeters[1]]
# waypoints
waypointDict["robot_{}".format(d)]["waypoints"].update({"waypoint_{}".format(i) : [i, waypointLatLon[0], waypointLatLon[1], baseWaypointAltitude + d*waypointAltitudeIncrement, waypointHeading]})
# positions
waypointDict["robot_{}".format(d)]["positions"].update({"position_{}".format(i) : [i, positionXY[0], positionXY[1], baseWaypointAltitude + d*waypointAltitudeIncrement, waypointHeading]})
# do this betta
waypointDict["robot_{}".format(d)]["numWaypoints"] = numWaypoints
waypointDict["robot_{}".format(d)]["numPositions"] = numPositions
# print(waypointDict)
rospy.set_param("/robot_list", waypointDict)
else:
# musical drones trajectory is convient test case, but general path is possible
# ring sizes
big = 2.0
med = 2.0
sml = 2.0
apMeters = lat_lon2meters(anchorPoint)
waypointOffsets = [
[-big, -big],
[big, -big],
[big, big],
[med, med],
[-med, med],
[-med, -med],
[-sml, -sml],
[sml, -sml],
[sml, sml],
[big, -big],
]
tempDict = {"waypoints" : {}, "positions" : {}, "numWaypoints" : 0, "numPositions" : 0}
waypointDict = {}
# define dictionary
numWaypoints = len(waypointOffsets)
numPositions = len(waypointOffsets) # TODO, add position list to parameters
# print(waypointDict)
for d in range(droneNum):
# rospy.loginfo("blah!")
# print(d)
waypointDict["robot_{}".format(d)] = {}
waypointDict["robot_{}".format(d)] = {}
waypointDict["robot_{}".format(d)]["waypoints"] = {}
waypointDict["robot_{}".format(d)]["positions"] = {}
for i, offset in enumerate(waypointOffsets):
waypointLatLon = meters2lat_lon([apMeters[0] + offset[0], apMeters[1] + offset[1]])
waypointLatLonRev = meters2lat_lon([apMeters[0] - offset[0], apMeters[1] - offset[1]])
waypointHeading = normalizeAngle(45*i)
# waypoints
waypointDict["robot_{}".format(d)]["waypoints"].update({"waypoint_{}".format(i) : [i, waypointLatLon[0], waypointLatLon[1], baseWaypointAltitude + d*waypointAltitudeIncrement, waypointHeading]})
# positions
waypointDict["robot_{}".format(d)]["positions"].update({"position_{}".format(i) : [i, offset[0], offset[1], baseWaypointAltitude + d*waypointAltitudeIncrement, waypointHeading]})
# do this betta
waypointDict["robot_{}".format(d)]["numWaypoints"] = numWaypoints
waypointDict["robot_{}".format(d)]["numPositions"] = numPositions
# print(waypointDict)
rospy.set_param("/robot_list", waypointDict)
return
# print(waypointDict)
if __name__ == "__main__":
generateWaypoints()
#!/usr/bin/python3
from tools import meters2lat_lon, lat_lon2meters, normalizeAngle, point_rotation
import numpy as np
import rospy
def generateWaypoints():
rospy.init_node("waypointGenerator")
anchorPoint = rospy.get_param("~anchorPoint")
pathPoints = rospy.get_param("~pathPoints")
baseWaypointAltitude = rospy.get_param("~altitude")
droneNum = rospy.get_param("~droneNum")
angleOffset = rospy.get_param("~angleOffset")
# waypointAltitudeIncrement = baseWaypointAltitude # increase altitude for each drone in team
waypointAltitudeIncrement = 10 # increase altitude for each drone in team
# decide if path is "preplanned" or not
if (len(pathPoints) != 0):
apMeters = lat_lon2meters(anchorPoint)
tempDict = {"waypoints" : {}, "positions" : {}, "numWaypoints" : 0, "numPositions" : 0}
waypointDict = {}
# define dictionary
numWaypoints = len(pathPoints)
numPositions = len(pathPoints)
for d in range(droneNum):
# rospy.loginfo("blah!")
# print(d)
waypointDict["robot_{}".format(d)] = {}
waypointDict["robot_{}".format(d)] = {}
waypointDict["robot_{}".format(d)]["waypoints"] = {}
waypointDict["robot_{}".format(d)]["positions"] = {}
for i, pt in enumerate(pathPoints):
# for i, offset in enumerate(waypointOffsets):
# waypointLatLon = pt
# calculate angle offset
ptMeters = lat_lon2meters(pt)
rotatedOffset = point_rotation([0,0], [ptMeters[0] - apMeters[0], ptMeters[1] - apMeters[1]], angleOffset*d)
waypointLatLon = meters2lat_lon([rotatedOffset[0] + apMeters[0], rotatedOffset[1] + apMeters[1]])
waypointHeading = 0.0
latLonPt = lat_lon2meters(pt)
positionXY = [latLonPt[0] - apMeters[0], latLonPt[1] - apMeters[1]]
# waypoints
waypointDict["robot_{}".format(d)]["waypoints"].update({"waypoint_{}".format(i) : [i, waypointLatLon[0], waypointLatLon[1], baseWaypointAltitude + d*waypointAltitudeIncrement, waypointHeading]})
# positions
waypointDict["robot_{}".format(d)]["positions"].update({"position_{}".format(i) : [i, positionXY[0], positionXY[1], baseWaypointAltitude + d*waypointAltitudeIncrement, waypointHeading]})
# do this betta
waypointDict["robot_{}".format(d)]["numWaypoints"] = numWaypoints
waypointDict["robot_{}".format(d)]["numPositions"] = numPositions
# print(waypointDict)
rospy.set_param("/robot_list", waypointDict)
return
# print(waypointDict)
if __name__ == "__main__":
generateWaypoints()
#!/usr/bin/bash
source ~/anaconda3/etc/profile.d/conda.sh
conda activate sarwebui_env
python ~/sarwebui/manage.py runserver localhost:8000
Subproject commit 0a0e817deb8f19d4ae8db9c527d2245337f16569
velodyne @ 7ee199f4
Subproject commit 7ee199f4cdfbd10659afbb8be184f202239694cb
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment