To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 6b0a577e authored by Andrew's avatar Andrew
Browse files

added rosnode

parent 5d00fd08
......@@ -247,6 +247,7 @@ generate_messages(
## * In the file package.xml:
## * add a build_depend and a run_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
......@@ -524,3 +525,4 @@ target_link_libraries(FlyingAgentGUI ${catkin_LIBRARIES})
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
#-DPYTHON_EXECUTABLE=python3
......@@ -55,11 +55,14 @@ from rospkg import RosPack
from std_msgs.msg import Float32
from std_msgs.msg import String
import time, sys
import struct
import logging
# import the necessary packages
from collections import deque
from imutils.video import VideoStream
import numpy as np
import math
import argparse
......@@ -69,13 +72,14 @@ import time
import matplotlib.pyplot as plt
from operator import itemgetter
from pykalman import KalmanFilter
from imutils.video import VideoStream
WIDTH = 640
BLURR = 11
ACT_SIZE = 100
FOV = 70
CAMERA = 2
CAMERA = 1
greenLower = (50, 50, 40)
......@@ -90,9 +94,8 @@ magentaUpper = (150,255,255)
upper = greenUpper
lower = greenLower
#if __name__ == '__main__':
#Start ROS-node
global node_name
node_name = "CrazyCamera"
rospy.init_node(node_name, anonymous=True)
......@@ -102,7 +105,7 @@ global ros_namespace
ros_namespace = rospy.get_namespace()
# Initialise a publisher for the battery voltage
# Initialise a publisher for the camera
global cfcamera_pub
cfcamera_pub = rospy.Publisher(node_name, Float32, queue_size=10)
......@@ -116,6 +119,7 @@ def big_diff(v1, v2, mult):
def similar_value(v1,v2,max_diff):
return max_diff > abs(v1-v2)
#initialize font
fontface = cv2.FONT_HERSHEY_SIMPLEX
fontscale = 0.5
......@@ -138,12 +142,12 @@ fontcolor = (255, 255, 255)
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-v", "--video",
help="path to the (optional) video file")
ap.add_argument("-b", "--buffer", type=int, default=64,
help="max buffer size")
args = vars(ap.parse_args())
#ap = argparse.ArgumentParser()
#ap.add_argument("-v", "--video",
# help="path to the (optional) video file")
#ap.add_argument("-b", "--buffer", type=int, default=64,
# help="max buffer size")
args = vars()
# define the lower and upper boundaries of the "green"
# ball in the HSV color space, then initialize the
# list of tracked points
......@@ -163,7 +167,7 @@ l_old = 0
fig, ax = plt.subplots()
pts = deque(maxlen=args["buffer"])
#pts = deque(maxlen=args["buffer"])
# if a video path was not supplied, grab the reference
# to the webcam
......@@ -178,7 +182,9 @@ else:
time.sleep(0.2)
# keep looping
while True:
cfcamera_pub.publish(0.5)
#allow changing of color-range in runtime
key = cv2.waitKey(1) & 0xFF
......@@ -323,7 +329,7 @@ while True:
if similar_value(l,l_old,10) or similar_value(phi_ud,phi_ud_old,5) or similar_value(phi_lr,phi_lr_old,5):
output = 'dist: ' + str(int(l)) + ' phi_ud: ' + "{:5.1f}".format(phi_ud * 57.296) + ' phi_lr: ' + "{:5.1f}".format(phi_lr * 57.296)
cfcamera_pub.publish(l)
cfcamera_pub.publish(0.5)
else:
mark_missing = True
......
/usr/local/lib/python3.5/site-packages/cv2.so
\ No newline at end of file
/usr/local/lib/python3.5/site-packages/cv2.so
\ No newline at end of file
/usr/local/lib/python3.6/dist-packages/cv2.cpython-36m-x86_64-linux-gnu.so
\ No newline at end of file
......@@ -6,9 +6,9 @@ battery_voltage_threshold_lower_while_standby: 3.30
battery_voltage_threshold_upper_while_standby: 4.20
# Battery thresholds while in the "flying" state, in [Volts]
battery_voltage_threshold_lower_while_flying: 2.60
battery_voltage_threshold_lower_while_flying: 2.80
battery_voltage_threshold_upper_while_flying: 3.70
# Delay before changing the state of the battery, in [number of measurements]
# > Note that the delay in seconds therefore depends on the polling period
battery_delay_threshold_to_change_state: 5
\ No newline at end of file
battery_delay_threshold_to_change_state: 5
......@@ -91,7 +91,7 @@ shouldDisplayDebugInfo : false
# A flag for which controller to use, defined as:
# 1 - Rate controller
# 2 - Angle-Rate nested controller
controller_method : 2
controller_method : 1
# The LQR Controller parameters for z-height
gainMatrixThrust_2StateVector : [ 0.98, 0.25]
......@@ -126,4 +126,4 @@ estimator_method : 1
# > For the (x,y,z) position
PMKF_Ahat_row1_for_positions : [ 0.6723, 0.0034]
PMKF_Ahat_row2_for_positions : [-12.9648, 0.9352]
PMKF_Kinf_for_positions : [ 0.3277,12.9648]
\ No newline at end of file
PMKF_Kinf_for_positions : [ 0.3277,12.9648]
......@@ -524,9 +524,11 @@ void requestSetpointChangeCallback(const SetpointWithHeader& newSetpoint)
}
// Crazy Camera Callback
void CrazyCameraCallback(float Float32)
void CrazyCameraCallback(std_msgs::float32 msg)
{
std::cout(Float32)std::endl;
float value = msg.data;
std::cout(value)std::endl;
std::cout("hey")std::endl;
}
......@@ -870,7 +872,7 @@ int main(int argc, char* argv[]) {
// /dfall/.../ParameterService/<filename with .yaml extension>
ros::Subscriber safeContoller_yamlReady_fromAgent = nodeHandle_to_own_agent_parameter_service.subscribe( "TemplateController", 1, isReadyTemplateControllerYamlCallback);
ros::Subscriber safeContoller_yamlReady_fromCoord = nodeHandle_to_coordinator_parameter_service.subscribe("TemplateController", 1, isReadyTemplateControllerYamlCallback);
k
// GIVE YAML VARIABLES AN INITIAL VALUE
......@@ -900,7 +902,7 @@ int main(int argc, char* argv[]) {
loadYamlFromFilenameCall.request.stringWithHeader.data = "TemplateController";
// Set for whom this applies to
loadYamlFromFilenameCall.request.stringWithHeader.shouldCheckForAgentID = false;
// Wait until the serivce exists
// Wait until the serivce existsk
requestLoadYamlFilenameServiceClient.waitForExistence(ros::Duration(-1));
// Make the service call
if(requestLoadYamlFilenameServiceClient.call(loadYamlFromFilenameCall))
......@@ -915,7 +917,7 @@ int main(int argc, char* argv[]) {
ROS_ERROR("[TEMPLATE CONTROLLER] The request load yaml file service call failed.");
}
k
// PUBLISHERS AND SUBSCRIBERS
......@@ -984,7 +986,7 @@ int main(int argc, char* argv[]) {
// For this we need to first create a node handle to the coordinator:
//std::string namespace_to_coordinator;
//constructNamespaceForCoordinator( m_coordID, namespace_to_coordinator );
//ros::NodeHandle nodeHandle_to_coordinator(namespace_to_coordinator);
//ros::NodeHandle nodeHandle_to_coordinator(namespace_to_coordinator);CommandRecei
// And now we can instantiate the subscriber:
ros::Subscriber customCommandReceivedSubscriber_from_coord = nodeHandle_to_coordinator.subscribe("TemplateControllerService/CustomButtonPressed", 1, customCommandReceivedCallback);
......
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