Commit 3d8daf1a authored by phfriedl's avatar phfriedl
Browse files

Updated crazyradio client library

parent d535a9f7
......@@ -94,7 +94,7 @@ class PPSRadioClient:
def motorCommandCallback(data):
"""Callback for motor controller actions"""
cf_client._send_to_commander(0, 0, 0, 0, data.cmd1 * 10000, data.cmd2 * 10000, data.cmd3 * 10000, data.cmd4 * 10000, CONTROLLER_MOTOR)
cf_client._send_to_commander(0, 0, 0, 0, data.cmd1 * 1000, data.cmd2 * 1000, data.cmd3 * 1000, data.cmd4 * 1000, CONTROLLER_MOTOR)
rospy.loginfo("motor controller callback: %s, %s, %s, %s", data.cmd1, data.cmd2, data.cmd3, data.cmd4)
def angleCommandCallback(data):
......@@ -121,13 +121,17 @@ if __name__ == '__main__':
available=[]
available = cflib.crtp.scan_interfaces()
rospy.loginfo("Crazyflies found:")
for i in available:
rospy.loginfo("----------------------------------------------------------------")
rospy.loginfo(i[0])
for i in available:
print i[0]
if len(available) > 0:
global cf_client
#TODO: load address from parameters
cf_client = PPSRadioClient(available[0][0])
cf_client = PPSRadioClient("radio://0/72/2M")
#cf_client = PPSRadioClient(available[0][0])
time.sleep(2.0)
#TODO: change publisher name if not correct
rospy.Subscriber("/PPSClient/MotorCommand", MotorCommand, motorCommandCallback)
......
......@@ -24,21 +24,28 @@
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from .cfclient import main
import os
from appdirs import AppDirs
import sys
try:
from .version import VERSION
except:
try:
import subprocess
VERSION = subprocess.check_output(["git", "describe"])
except:
VERSION = "dev"
# Path used all over the application
if not hasattr(sys, 'frozen'):
module_path = os.path.dirname(__file__)
else:
module_path = os.path.dirname(sys.executable)
config_path = AppDirs("cfclient", "Bitcraze").user_config_dir
# Locate the sdl2 lib on Windows (should be in cfclient/thirst_party/)
if os.name == 'nt':
os.environ["PYSDL2_DLL_PATH"] = os.path.join(module_path, "third_party")
if not hasattr(sys, 'frozen'):
import pkg_resources
try:
import subprocess
ret = subprocess.call(["git", "diff", "--quiet", "HEAD"])
if ret > 0:
VERSION += "+"
except:
VERSION += "+"
VERSION = pkg_resources.require("cfclient")[0].version
except pkg_resources.DistributionNotFound:
VERSION = "dev"
else:
import json
with open(os.path.join(module_path, "version.json")) as f:
VERSION = json.load(f)['version']
{
"writable" : {
"input_device": "",
"link_uri": "",
"flightmode": "Normal",
"open_tabs": "Flight Control",
"trim_pitch": 0.0,
"slew_limit": 45,
"slew_rate": 30,
"trim_roll": 0.0,
"max_thrust": 80,
"min_thrust": 25,
"max_yaw": 200,
"input_device": "",
"link_uri": "",
"flightmode": "Normal",
"open_tabs": "Flight Control",
"trim_pitch": 0.0,
"slew_limit": 45,
"slew_rate": 30,
"trim_roll": 0.0,
"max_thrust": 80,
"min_thrust": 25,
"max_yaw": 200,
"max_rp": 30,
"client_side_xmode": false,
"auto_reconnect": false,
......@@ -21,11 +21,11 @@
"enable_zmq_input": false
},
"read-only" : {
"normal_slew_limit": 45,
"normal_slew_rate": 30,
"normal_max_thrust": 80,
"normal_min_thrust": 25,
"normal_max_yaw": 200,
"normal_slew_limit": 45,
"normal_slew_rate": 30,
"normal_max_thrust": 80,
"normal_min_thrust": 25,
"normal_max_yaw": 200,
"normal_max_rp": 30,
"default_cf_channel": 10,
"default_cf_speed": 0,
......
{
"inputconfig": {
"inputdevice": {
"updateperiod": 10,
"springythrottle": false,
"name": "Joystick",
"axis": [
{
"scale": -1.0,
"type": "Input.AXIS",
"id": 3,
"key": "thrust",
"name": "thrust"
},
{
"scale": 1.0,
"type": "Input.AXIS",
"id": 2,
"key": "yaw",
"name": "yaw"
},
{
"scale": 1.0,
"type": "Input.AXIS",
"id": 0,
"key": "roll",
"name": "roll"
},
{
"scale": -1.0,
"type": "Input.AXIS",
"id": 1,
"key": "pitch",
"name": "pitch"
},
{
"scale": 1.0,
"type": "Input.HAT",
"id": 0,
"key": "trim",
"name": "trim"
},
{
"scale": -1.0,
"type": "Input.BUTTON",
"id": 4,
"key": "pitchNeg",
"name": "pitchNeg"
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 5,
"key": "pitchPos",
"name": "pitchPos"
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 1,
"key": "estop",
"name": "killswitch"
},
{
"scale": -1.0,
"type": "Input.BUTTON",
"id": 2,
"key": "rollNeg",
"name": "rollNeg"
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 3,
"key": "rollPos",
"name": "rollPos"
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 0,
"key": "althold",
"name": "althold"
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 6,
"key": "exit",
"name": "exitapp"
}
]
}
}
}
{
"inputconfig": {
"inputdevice": {
"updateperiod": 10,
"springythrottle": false,
"name": "Joystick",
"axis": [
{
"scale": -1.0,
"type": "Input.AXIS",
"id": 3,
"key": "thrust",
"name": "thrust"
},
{
"scale": 1.0,
"type": "Input.AXIS",
"id": 2,
"key": "yaw",
"name": "yaw"
},
{
"scale": 1.0,
"type": "Input.AXIS",
"id": 0,
"key": "roll",
"name": "roll"
},
{
"scale": -1.0,
"type": "Input.AXIS",
"id": 1,
"key": "pitch",
"name": "pitch"
},
{
"scale": 1.0,
"type": "Input.HAT",
"id": 0,
"key": "trim",
"name": "trim"
},
{
"scale": -1.0,
"type": "Input.BUTTON",
"id": 4,
"key": "pitchNeg",
"name": "pitchNeg"
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 5,
"key": "pitchPos",
"name": "pitchPos"
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 1,
"key": "estop",
"name": "killswitch"
},
{
"scale": -1.0,
"type": "Input.BUTTON",
"id": 2,
"key": "rollNeg",
"name": "rollNeg"
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 3,
"key": "rollPos",
"name": "rollPos"
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 0,
"key": "althold",
"name": "althold"
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 6,
"key": "exit",
"name": "exitapp"
}
]
}
}
}
{
"inputconfig": {
"inputdevice": {
"updateperiod": 10,
"name": "PS3_Mode_3",
"updateperiod": 10,
"name": "PS3_Mode_3",
"axis": [
{
"scale": -1.0,
"type": "Input.AXIS",
"id": 1,
"key": "thrust",
"scale": -1.0,
"type": "Input.AXIS",
"id": 1,
"key": "thrust",
"name": "thrust"
},
},
{
"scale": 1.0,
"type": "Input.AXIS",
"scale": 1.0,
"type": "Input.AXIS",
"ids": [
12,
12,
13
],
"key": "yaw",
],
"key": "yaw",
"name": "yaw"
},
},
{
"scale": 1.0,
"type": "Input.AXIS",
"id": 2,
"key": "roll",
"scale": 1.0,
"type": "Input.AXIS",
"id": 2,
"key": "roll",
"name": "roll"
},
},
{
"scale": -1.0,
"type": "Input.AXIS",
"id": 3,
"key": "pitch",
"scale": -1.0,
"type": "Input.AXIS",
"id": 3,
"key": "pitch",
"name": "pitch"
},
},
{
"scale": -1.0,
"type": "Input.BUTTON",
"id": 6,
"scale": -1.0,
"type": "Input.BUTTON",
"id": 6,
"key": "pitchNeg",
"name": "pitchNeg"
},
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 4,
"scale": 1.0,
"type": "Input.BUTTON",
"id": 4,
"key": "pitchPos",
"name": "pitchPos"
},
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 14,
"key": "estop",
"scale": 1.0,
"type": "Input.BUTTON",
"id": 14,
"key": "estop",
"name": "killswitch"
},
},
{
"scale": -1.0,
"type": "Input.BUTTON",
"id": 7,
"scale": -1.0,
"type": "Input.BUTTON",
"id": 7,
"key": "rollNeg",
"name": "rollNeg"
},
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 5,
"scale": 1.0,
"type": "Input.BUTTON",
"id": 5,
"key": "rollPos",
"name": "rollPos"
},
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 12,
"key": "exit",
"scale": 1.0,
"type": "Input.BUTTON",
"id": 12,
"key": "exit",
"name": "exitapp"
}
]
}
}
}
\ No newline at end of file
}
{
"inputconfig": {
"inputdevice": {
"updateperiod": 10,
"name": "PS4_Mode_1",
"updateperiod": 10,
"name": "PS4_Mode_1",
"axis": [
{
"scale": -1.0,
"type": "Input.AXIS",
"id": 5,
"key": "thrust",
"scale": -1.0,
"type": "Input.AXIS",
"id": 5,
"key": "thrust",
"name": "thrust"
},
},
{
"scale": 1.0,
"type": "Input.AXIS",
"id": 2,
"key": "yaw",
"scale": 1.0,
"type": "Input.AXIS",
"id": 2,
"key": "yaw",
"name": "yaw"
},
},
{
"scale": 1.0,
"type": "Input.AXIS",
"id": 0,
"key": "roll",
"scale": 1.0,
"type": "Input.AXIS",
"id": 0,
"key": "roll",
"name": "roll"
},
},
{
"scale": -1.0,
"type": "Input.AXIS",
"id": 1,
"key": "pitch",
"scale": -1.0,
"type": "Input.AXIS",
"id": 1,
"key": "pitch",
"name": "pitch"
},
},
{
"scale": -1.0,
"type": "Input.BUTTON",
"id": 1,
"scale": -1.0,
"type": "Input.BUTTON",
"id": 1,
"key": "pitchNeg",
"name": "pitchNeg"
},
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 3,
"scale": 1.0,
"type": "Input.BUTTON",
"id": 3,
"key": "pitchPos",
"name": "pitchPos"
},
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 12,
"key": "estop",
"scale": 1.0,
"type": "Input.BUTTON",
"id": 12,
"key": "estop",
"name": "killswitch"
},
},
{
"scale": -1.0,
"type": "Input.BUTTON",
"id": 0,
"scale": -1.0,
"type": "Input.BUTTON",
"id": 0,
"key": "rollNeg",
"name": "rollNeg"
},
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 2,
"scale": 1.0,
"type": "Input.BUTTON",
"id": 2,
"key": "rollPos",
"name": "rollPos"
},
},
{
"scale": 1.0,
"type": "Input.BUTTON",
"id": 5,
"key": "althold",