Skip to content
Snippets Groups Projects
Commit 7fe8cf40 authored by sfrana's avatar sfrana :cloud_tornado:
Browse files

added functionality for get/set param

parent bf96ad81
No related branches found
No related tags found
5 merge requests!106Adding Pycrocart 2.1,!104adding cflib to this branch,!103Updating develop to current state of master branch,!98Pycrocart 2.1 will,!94Merge cflib adapter into main
No preview for this file type
No preview for this file type
...@@ -13,6 +13,8 @@ import cflib.crtp ...@@ -13,6 +13,8 @@ import cflib.crtp
from cflib.crazyflie import Crazyflie from cflib.crazyflie import Crazyflie
from cflib.crazyflie.syncCrazyflie import SyncCrazyflie from cflib.crazyflie.syncCrazyflie import SyncCrazyflie
from queue import Queue from queue import Queue
#import groundstation_socket as gs
from groundstation_socket import MessageTypeID
from cflib.crazyflie.log import LogConfig from cflib.crazyflie.log import LogConfig
...@@ -78,13 +80,17 @@ class CrazyflieConnection: ...@@ -78,13 +80,17 @@ class CrazyflieConnection:
def BeginUpdate(): def BeginUpdate():
raise Exception raise Exception
def OverrideOuput(): def OverrideOuput():
#Sends all setpoints for a given amount of time """Sends all setpoints for a given amount of time"""
#TODO #TODO
raise Exception raise Exception
def GetNodeIds(): def GetNodeIds():
raise Exception raise Exception
def SetParam(self, group: str, name: str, value: float): def SetParam(self, command):
""" Set a crazyflie parameter value. """ """ Set a crazyflie parameter value. """
group = command['data'][0:1]
name = command['data'][2:3]
value = command['data'][4:7]
try: try:
if self.scf.is_link_open(): if self.scf.is_link_open():
full_name = group + "." + name full_name = group + "." + name
...@@ -107,15 +113,36 @@ class CrazyflieConnection: ...@@ -107,15 +113,36 @@ class CrazyflieConnection:
print("Done setting param") print("Done setting param")
self.param_callback_count += 1 self.param_callback_count += 1
def GetParam(self, group: str, name: str): def GetParam(self, command, outputQueue: Queue): #group: str, name: str,
""" Retrieve parameter value from crazyflie toc. """ """ Retrieve parameter value from crazyflie toc. """
#Bytes 0 and 1 are node ID, ie group
#Bytes 2 and 3 are node paramID, ie name
group = command['data'][0:1]
name = command['data'][2:3]
try: try:
if self.scf.is_link_open(): if self.scf.is_link_open():
return self.scf.cf.param.values[group][name] val = self.scf.cf.param.values[group][name]
except AttributeError: except AttributeError:
val = -1.234567
pass pass
return -1.234567890 # 1234567890 should be pretty obvious that
data = bytearray(group)
data.append(name)
data.append(val)
responsedata = {
"msg_type": (MessageTypeID.RESPPARAM_ID),
"msg_id": command['msg_id'],
"data_len": 8,
"data": data
}
outputQueue.put(responsedata)
#return -1.234567890 # 1234567890 should be pretty obvious that
# something has gone wrong. # something has gone wrong.
def SetSource(): def SetSource():
raise Exception raise Exception
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment