mirror of
https://github.com/caperren/school_archives.git
synced 2025-11-09 21:51:15 +00:00
Added 2017-2018 mars rover repository.
This commit is contained in:
@@ -0,0 +1,205 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(rover_science)
|
||||
|
||||
## 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
|
||||
roscpp
|
||||
rospy
|
||||
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 run_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 run_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
|
||||
# )
|
||||
|
||||
add_message_files(
|
||||
FILES
|
||||
SoilSensorStatusMessage.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
|
||||
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 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
|
||||
## 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 system_statuses
|
||||
# CATKIN_DEPENDS roscpp rospy 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}/system_statuses.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/system_statuses_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
|
||||
# install(PROGRAMS
|
||||
# scripts/my_python_script
|
||||
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
|
||||
# )
|
||||
|
||||
## Mark executables and/or libraries for installation
|
||||
# install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
|
||||
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||
# RUNTIME DESTINATION ${CATKIN_PACKAGE_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_system_statuses.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)
|
||||
@@ -0,0 +1,7 @@
|
||||
float32 temp_c
|
||||
float32 moisture
|
||||
float32 loss_tangent
|
||||
float32 soil_electrical_conductivity
|
||||
float32 real_dielectric_permittivity
|
||||
float32 imaginary_dielectric_permittivity
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0"?>
|
||||
<package format="2">
|
||||
<name>rover_science</name>
|
||||
<version>0.0.0</version>
|
||||
<description>The rover_status package</description>
|
||||
|
||||
<!-- One maintainer tag required, multiple allowed, one person per tag -->
|
||||
<!-- Example: -->
|
||||
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
|
||||
<maintainer email="matcurtay@matcurtay.net">matcurtay</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>BSD</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/rover_status</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>roscpp</build_depend>
|
||||
<build_depend>rospy</build_depend>
|
||||
<build_depend>std_msgs</build_depend>
|
||||
<build_export_depend>roscpp</build_export_depend>
|
||||
<build_export_depend>rospy</build_export_depend>
|
||||
<build_export_depend>std_msgs</build_export_depend>
|
||||
<exec_depend>roscpp</exec_depend>
|
||||
<exec_depend>rospy</exec_depend>
|
||||
<exec_depend>message_generation</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>
|
||||
@@ -0,0 +1,264 @@
|
||||
#!/usr/bin/env python
|
||||
#####################################
|
||||
# Imports
|
||||
#####################################
|
||||
# Python native imports
|
||||
import rospy
|
||||
|
||||
from time import time, sleep
|
||||
|
||||
import serial.rs485
|
||||
import minimalmodbus
|
||||
import numpy
|
||||
|
||||
# Custom Imports
|
||||
from rover_science.msg import SoilSensorStatusMessage
|
||||
from std_msgs.msg import Float64MultiArray
|
||||
|
||||
#####################################
|
||||
# Global Variables
|
||||
#####################################
|
||||
NODE_NAME = "science_node"
|
||||
|
||||
DEFAULT_PORT = "/dev/rover/ttyRDF_SoilProbe"
|
||||
DEFAULT_RDF_BAUD = 115200
|
||||
DEFAULT_SOIL_BAUD = 9600
|
||||
|
||||
DEFAULT_RDF_PUBLISHER_TOPIC = "rdf/data"
|
||||
DEFAULT_SOIL_PROBE_PUBLISHER_TOPIC = "soil_probe/data"
|
||||
|
||||
RDF_NODE_ID = 1
|
||||
|
||||
COMMUNICATIONS_TIMEOUT = 0.1 # Seconds
|
||||
|
||||
RX_DELAY = 0.01
|
||||
TX_DELAY = 0.01
|
||||
|
||||
DEFAULT_HERTZ = 20
|
||||
FAILED_RDF_LIMIT = 20
|
||||
|
||||
SOIL_PROBE_READ_TIMEOUT = 8
|
||||
SOIL_PROBE_EXIT_TIMEOUT = 20
|
||||
|
||||
SOIL_PROBE_ADDRESS = "mar"
|
||||
|
||||
PAN_TILT_MODBUS_REGISTERS = {
|
||||
"CENTER_ALL": 0,
|
||||
|
||||
"PAN_ADJUST_POSITIVE": 1,
|
||||
"PAN_ADJUST_NEGATIVE": 2,
|
||||
"TILT_ADJUST_POSITIVE": 3,
|
||||
"TILT_ADJUST_NEGATIVE": 4
|
||||
}
|
||||
|
||||
SOIL_PROBE_COMMANDS = {
|
||||
"GET_ADDRESS": "AD=",
|
||||
"DESCRIPTION": "DS=",
|
||||
"PROBE_ENABLED": "PE=",
|
||||
"TAKE_READING": "TR",
|
||||
"TRANSMIT_READING": "T3",
|
||||
|
||||
"QUERY": "?"
|
||||
}
|
||||
|
||||
TRANSMIT_SET_3_INDICES = {
|
||||
"TEMP C": 0,
|
||||
"Moisture": 2,
|
||||
"Loss Tangent": 3,
|
||||
"Soil Electrical Conductivity (tc)": 4,
|
||||
"Real Dielectric Permittivity (tc)": 6,
|
||||
"Imag Dielectric Permittivity (tc)": 8,
|
||||
}
|
||||
|
||||
NODE_LAST_SEEN_TIMEOUT = 2 # seconds
|
||||
|
||||
|
||||
#####################################
|
||||
# DriveControl Class Definition
|
||||
#####################################
|
||||
class RoverScience(object):
|
||||
INSTRUMENTS = [
|
||||
"RDF",
|
||||
"SOIL"
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
rospy.init_node(NODE_NAME)
|
||||
|
||||
self.port = rospy.get_param("~port", DEFAULT_PORT)
|
||||
self.baud = rospy.get_param("~baud", DEFAULT_RDF_BAUD)
|
||||
|
||||
self.science_node_id = rospy.get_param("~pan_tilt_node_id", RDF_NODE_ID)
|
||||
|
||||
self.wait_time = 1.0 / rospy.get_param("~hertz", DEFAULT_HERTZ)
|
||||
|
||||
self.rdf_node = None
|
||||
self.soil_node = None
|
||||
|
||||
self.connect_to_rdf()
|
||||
|
||||
self.rdf_publisher = rospy.Publisher(DEFAULT_RDF_PUBLISHER_TOPIC, Float64MultiArray, queue_size=1)
|
||||
self.soil_probe_publisher = rospy.Publisher(DEFAULT_SOIL_PROBE_PUBLISHER_TOPIC, SoilSensorStatusMessage, queue_size=1)
|
||||
|
||||
self.modbus_nodes_seen_time = time()
|
||||
|
||||
self.failed_rdf_modbus_count = 0
|
||||
self.soil_probe_timeout_cumulative = 0
|
||||
|
||||
self.which_instrument = self.INSTRUMENTS.index("RDF")
|
||||
|
||||
self.probe_response_line = ""
|
||||
|
||||
self.run()
|
||||
|
||||
def __setup_minimalmodbus_for_485(self):
|
||||
self.rdf_node.serial = serial.rs485.RS485(self.port, baudrate=self.baud, timeout=COMMUNICATIONS_TIMEOUT) # type: serial.Serial
|
||||
self.rdf_node.serial.rs485_mode = serial.rs485.RS485Settings(rts_level_for_rx=1, rts_level_for_tx=0,
|
||||
delay_before_rx=RX_DELAY,
|
||||
delay_before_tx=TX_DELAY)
|
||||
|
||||
def run(self):
|
||||
while not rospy.is_shutdown():
|
||||
if self.which_instrument == self.INSTRUMENTS.index("RDF"):
|
||||
try:
|
||||
registers = self.rdf_node.read_registers(0, 1)
|
||||
self.rdf_publisher.publish(Float64MultiArray(data=[registers[0], time()]))
|
||||
self.failed_rdf_modbus_count = 0
|
||||
except Exception, e:
|
||||
# print e
|
||||
self.failed_rdf_modbus_count += 1
|
||||
|
||||
if self.failed_rdf_modbus_count == FAILED_RDF_LIMIT:
|
||||
print "RDF not present. Trying soil sensor"
|
||||
self.which_instrument = self.INSTRUMENTS.index("SOIL")
|
||||
|
||||
elif self.which_instrument == self.INSTRUMENTS.index("SOIL"):
|
||||
if not self.soil_node:
|
||||
self.switch_node_to_soil_probe()
|
||||
|
||||
self.broadcast_soil_sensor_data()
|
||||
|
||||
if self.soil_probe_timeout_cumulative > SOIL_PROBE_EXIT_TIMEOUT:
|
||||
print "No science devices present. Exiting..."
|
||||
return
|
||||
|
||||
def switch_node_to_soil_probe(self):
|
||||
del self.rdf_node
|
||||
|
||||
self.soil_node = serial.rs485.RS485(self.port, baudrate=DEFAULT_SOIL_BAUD, timeout=COMMUNICATIONS_TIMEOUT) # type: serial.Serial
|
||||
self.soil_node.rs485_mode = serial.rs485.RS485Settings(rts_level_for_rx=1, rts_level_for_tx=0, delay_before_rx=RX_DELAY, delay_before_tx=TX_DELAY)
|
||||
|
||||
out = "%s%s\r\n" % (SOIL_PROBE_ADDRESS, SOIL_PROBE_COMMANDS["PROBE_ENABLED"] + "1")
|
||||
self.soil_node.write(out)
|
||||
sleep(0.1)
|
||||
|
||||
def broadcast_soil_sensor_data(self):
|
||||
self.request_soil_reading()
|
||||
self.request_reading_results()
|
||||
self.get_probe_response_line()
|
||||
self.process_probe_response_and_send()
|
||||
|
||||
def process_probe_response_and_send(self):
|
||||
if self.probe_response_line != "":
|
||||
|
||||
try:
|
||||
self.probe_response_line = self.probe_response_line.replace(SOIL_PROBE_ADDRESS, "")
|
||||
|
||||
split_results = self.probe_response_line.split(",")
|
||||
|
||||
temp_c = split_results[TRANSMIT_SET_3_INDICES["TEMP C"]]
|
||||
moisture = split_results[TRANSMIT_SET_3_INDICES["Moisture"]]
|
||||
loss_tangent = split_results[TRANSMIT_SET_3_INDICES["Loss Tangent"]]
|
||||
sec_tc = split_results[TRANSMIT_SET_3_INDICES["Soil Electrical Conductivity (tc)"]]
|
||||
rdp_tc = split_results[TRANSMIT_SET_3_INDICES["Real Dielectric Permittivity (tc)"]]
|
||||
idp_tc = split_results[TRANSMIT_SET_3_INDICES["Imag Dielectric Permittivity (tc)"]]
|
||||
|
||||
message = SoilSensorStatusMessage()
|
||||
message.temp_c = float(temp_c)
|
||||
message.moisture = float(moisture)
|
||||
message.loss_tangent = float(loss_tangent)
|
||||
message.soil_electrical_conductivity = float(sec_tc)
|
||||
message.real_dielectric_permittivity = float(rdp_tc)
|
||||
message.imaginary_dielectric_permittivity = float(idp_tc)
|
||||
|
||||
self.soil_probe_publisher.publish(message)
|
||||
|
||||
except:
|
||||
print "Soil probe line corrupted. Trying again..."
|
||||
|
||||
def get_probe_response_line(self):
|
||||
start_time = time()
|
||||
char = ""
|
||||
self.probe_response_line = ""
|
||||
|
||||
while char != '\n' and (time() - start_time) < 2:
|
||||
if self.soil_node.inWaiting():
|
||||
char = self.soil_node.read()
|
||||
self.probe_response_line += char
|
||||
|
||||
if self.probe_response_line:
|
||||
self.soil_probe_timeout_cumulative = 0
|
||||
# print self.probe_response_line
|
||||
else:
|
||||
# print "timeout"
|
||||
self.soil_probe_timeout_cumulative += 2
|
||||
|
||||
def request_soil_reading(self):
|
||||
out = "%s%s\r\n" % (SOIL_PROBE_ADDRESS, SOIL_PROBE_COMMANDS["TAKE_READING"])
|
||||
self.soil_node.write(out)
|
||||
sleep(0.1)
|
||||
|
||||
def request_reading_results(self):
|
||||
out = "%s%s\r\n" % (SOIL_PROBE_ADDRESS, SOIL_PROBE_COMMANDS["TRANSMIT_READING"])
|
||||
self.soil_node.write(out)
|
||||
|
||||
def smoothListTriangle(self, list, strippedXs=False, degree=5):
|
||||
|
||||
weight = []
|
||||
|
||||
window = degree * 2 - 1
|
||||
|
||||
smoothed = [0.0] * (len(list) - window)
|
||||
|
||||
for x in range(1, 2 * degree): weight.append(degree - abs(degree - x))
|
||||
|
||||
w = numpy.array(weight)
|
||||
|
||||
for i in range(len(smoothed)):
|
||||
smoothed[i] = sum(numpy.array(list[i:i + window]) * w) / float(sum(w))
|
||||
|
||||
return smoothed
|
||||
|
||||
def smoothListGaussian(self, list, strippedXs=False, degree=5):
|
||||
|
||||
window = degree * 2 - 1
|
||||
|
||||
weight = numpy.array([1.0] * window)
|
||||
|
||||
weightGauss = []
|
||||
|
||||
for i in range(window):
|
||||
i = i - degree + 1
|
||||
|
||||
frac = i / float(window)
|
||||
|
||||
gauss = 1 / (numpy.exp((4 * (frac)) ** 2))
|
||||
|
||||
weightGauss.append(gauss)
|
||||
|
||||
weight = numpy.array(weightGauss) * weight
|
||||
|
||||
smoothed = [0.0] * (len(list) - window)
|
||||
|
||||
for i in range(len(smoothed)):
|
||||
smoothed[i] = sum(numpy.array(list[i:i + window]) * weight) / sum(weight)
|
||||
|
||||
return smoothed
|
||||
|
||||
def connect_to_rdf(self):
|
||||
self.rdf_node = minimalmodbus.Instrument(self.port, int(self.science_node_id))
|
||||
self.__setup_minimalmodbus_for_485()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
RoverScience()
|
||||
Reference in New Issue
Block a user