Does anything else other than dronekit and dronekit stil need to be installed to run the hello.py program on the Quick Start page? - dronekit-python

I followed the instructions on this page:
http://python.dronekit.io/guide/quick_start.html
What I've Done:
pip install dronekit
pip install dronekit-sitl
Then I created a python file with this in it:
print ("Start simulator (SITL)")
import dronekit_sitl
sitl = dronekit_sitl.start_default()
#connection_string = sitl.connection_string()
# Import DroneKit-Python
from dronekit import connect, VehicleMode
# Connect to the Vehicle.
print("Connecting to vehicle on: %s" % ('tcp:127.0.0.1:5760',))
vehicle = connect('tcp:127.0.0.1:5760', wait_ready=True)
# Get some vehicle attributes (state)
print ("Get some vehicle attribute values:")
print (" GPS: %s" % vehicle.gps_0)
print (" Battery: %s" % vehicle.battery)
print (" Last Heartbeat: %s" % vehicle.last_heartbeat)
print (" Is Armable?: %s" % vehicle.is_armable)
print (" System status: %s" % vehicle.system_status.state)
print (" Mode: %s" % vehicle.mode.name) # settable
# Close vehicle object before exiting script
vehicle.close()
# Shut down simulator
sitl.stop()
print("Completed")
Then I ran it, and this is the error I got on the terminal:
olin30259168:Desktop physics$ python hello.py
Start simulator (SITL)
Starting copter simulator (SITL)
SITL already Downloaded and Extracted.
Ready to boot.
Connecting to vehicle on: tcp:127.0.0.1:5760
>>> APM:Copter V3.3 (d6053245)
>>> Frame: QUAD
>>> Calibrating barometer
Traceback (most recent call last):
File "hello.py", line 12, in <module>
vehicle = connect('tcp:127.0.0.1:5760', wait_ready=True)
File "/Users/physics/anaconda/lib/python3.6/site-packages/dronekit/__init__.py", line 2849, in connect
vehicle.wait_ready(True)
File "/Users/physics/anaconda/lib/python3.6/site-packages/dronekit/__init__.py", line 2199, in wait_ready
timeout)
dronekit.APIException: wait_ready experienced a timeout after 30 seconds.
olin30259168:Desktop physics$
What I should be getting is:
Start simulator (SITL)
Downloading SITL from http://dronekit-assets.s3.amazonaws.com/sitl/copter/sitl-win-copter-3.3.tar.gz
Extracted.
Connecting to vehicle on: 'tcp:127.0.0.1:5760'
>>> APM:Copter V3.3 (d6053245)
>>> Frame: QUAD
>>> Calibrating barometer
>>> Initialising APM...
>>> barometer calibration complete
>>> GROUND START
Get some vehicle attribute values:
GPS: GPSInfo:fix=3,num_sat=10
Battery: Battery:voltage=12.587,current=0.0,level=100
Last Heartbeat: 0.713999986649
Is Armable?: False
System status: STANDBY
Mode: STABILIZE
Completed
It seems to connect, but it times out trying to calibrate the barometer, I run into the same issue when I run the examples that I cloned from this directory:
https://github.com/dronekit/dronekit-python/tree/master/examples

This is what I installed on windows 10, if it give the same problem just resart the computer and re-run it a maximum of 4 times and then let me know.
1) Install Python 2.7
2) Go to https://pip.pypa.io/en/stable/installing/
a. Click on get-pip.py
b. Save it on the desktop
c. Once downloaded double click on it
3) Go to Command Prompt
a. If it says C:\Users\oscar4423>
i. Type cd C:\Python27\Scripts
b. Once step I is done type pip like this C:\Python27\Scripts>pip
c. Now type pip install requests: C:\Python27\Scripts>pip install requests
4) Close the command prompt
5) Go to https://git-scm.com/downloads and then click “download for Windows”
6) Install git
7) Open the Command Prompt and type cd C:\Python27\Scripts
8) Type pip install git+https://github.com/3drobotics/solo-cli
C:\Python27\Scripts>pip install git+https://github.com/3drobotics/solo-cli
9) Now Install the following pip install virtualenv
10) Type pip install dronekit on the command prompt like this:
C:\Python27\Scripts> pip install dronekit
11) Type pip install dronekit-sitl on the command prompt like this:
C:\Python27\Scripts> pip install dronekit-sitl
12) pip install numpy pyparsing
13) pip install MAVProxy

Related

LINK : fatal error LNK1104: cannot open file 'C:\Users\hp\.pyxbld\lib.win32-2.7\gensim\models\word2vec_inner.pyd'

I run the sourcecode of TWE model. I need to compile the C extension of python. I have installed the Microsoft Visual C++ Compiler for Python 2.7 and Cython.
First, I need to run the TWE/train.py:
import gensim
sentence_word = gensim.models.word2vec.LineSentence("tmp/word.file")
print "Training the word vector..."
w = gensim.models.Word2Vec(sentence_word,size=400, workers=20)
sentence = gensim.models.word2vec.CombinedSentence("tmp/word.file","tmp/topic.file")
print "Training the topic vector..."
w.train_topic(topic_number, sentence)
print "Saving the topic vectors..."
w.save_topic("output/topic_vector.txt")
print "Saving the word vectors..."
w.save_wordvector("output/word_vector.txt")`
Second, TWE/gensim/models/wor2vec.py:
try:
raise ImportError # ignore for now
from gensim_addons.models.word2vec_inner import train_sentence_sg,train_sentence_cbow, FAST_VERSION, train_sentence_topic
except ImportError:
try:
import pyximport
print 'import pyximport'
models_dir = os.path.dirname(__file__) or os.getcwd()
print 'models_dir'
pyximport.install(setup_args={"include_dirs": [models_dir, get_include()]})
print 'pyximport' # is the follow code's problem
from word2vec_inner import train_sentence_sg, train_sentence_cbow,
FAST_VERSION, train_sentence_topic
print 'from word2vec'
except:
FAST_VERSION = -1
def train_sentence_sg(model, sentence, alpha, work=None):
...
def train_sentence_cbow(model, sentence, alpha, work=None, neu1=None):
...
class Word2Vec(utils.SaveLoad):
...
def train(self, sentences, total_words=None, word_count=0, chunksize=100):
if FAST_VERSION < 0:
import warnings
warnings.warn("Cython compilation failed, training will be slow. Do you have Cython installed? `pip install cython`")
logger.info("training model with %i workers on %i vocabulary and %i features, "
"using 'skipgram'=%s 'hierarchical softmax'=%s 'subsample'=%s and 'negative sampling'=%s" %
(self.workers, len(self.vocab), self.layer1_size, self.sg, self.hs, self.sample, self.negative))
def worker_train():
...
if self.sg:
job_words = sum(train_sentence_topic(self, sentence, alpha, work) for sentence in job)
else:
ob_words = sum(train_sentence_cbow(self, sentence, alpha, work, neu1) for sentence in job)`
...
Thrid, I haved compiled the TWE/gensim/models/word2vec_inner.pyx with a setup.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
import numpy
extensions = [
Extension("word2vec_inner", ["word2vec_inner.pyx"],
include_dirs=[numpy.get_include()])
]
setup(
name="word2vec_inner",
ext_modules=cythonize(extensions),
)
by using the command 'python setup.py install', I have complied the word2vec_inner.pyx. But it appears the follow errors:
E:\Python27\python.exe D:/pycharm/TWE/TWE1/train.py wordmap.txt model-final.tassign 100
import pyximport
models_dir
pyximport
word2vec_inner.c
e:\python27\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg : Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
C:\Users\hp\.pyxbld\temp.win32-2.7\Release\pyrex\gensim\models\word2vec_inner.c(15079) : warning C4244:
'initializing' : conversion from 'double' to 'float', possible loss of data
C:\Users\hp\.pyxbld\temp.win32-2.7\Release\pyrex\gensim\models\word2vec_inner.c(15085) : warning C4244 : 'initializing' : conversion from 'double' to 'float', possible loss of data
LINK : fatal error LNK1104: cannot open file 'C:\Users\hp\.pyxbld\lib.win32-2.7\gensim\models\word2vec_inner.pyd'
Training the word vector...
D:\pycharm\TWE\TWE1\gensim\models\word2vec.py:410: UserWarning: Cython compilation failed, training will be slow. Do you have Cython installed? `pip install cython`
warnings.warn("Cython compilation failed, training will be slow. Do you have Cython installed? `pip install cython`")
PROGRESS: at 100.00% words, alpha 0.02500, 2556 words/s
Training the topic vector...
D:\pycharm\TWE\TWE1\gensim\models\word2vec.py:882: UserWarning: Cython compilation failed, training will be slow. Do you have Cython installed? `pip install cython`
warnings.warn("Cython compilation failed, training will be slow. Do you have Cython installed? `pip install cython`")
Exception in thread Thread-23:
Traceback (most recent call last):
File "E:\Python27\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "E:\Python27\lib\threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "D:\pycharm\TWE\TWE1\gensim\models\word2vec.py", line 909, in worker_train
job_words = sum(train_sentence_topic(self, sentence, alpha, work) for sentence in job)
File "D:\pycharm\TWE\TWE1\gensim\models\word2vec.py", line 909, in <genexpr>
job_words = sum(train_sentence_topic(self, sentence, alpha, work) for sentence in job)
NameError: global name 'train_sentence_topic' is not defined
Saving the topic vectors...
Saving the word vectors...
Process finished with exit code 0
I have checked that the .pyx file was compiled correctly and also installed the cython. in conclusion, it can't import train_sentence_sg,train_sentence_cbow, FAST_VERSION, train_sentence_topic from gensim/models/word2vec_inner or gensim_addons/models/word2vec_inner. So it appears these problems. But why? I have compiled the .pyx file correctly in both two directionarys. Anyone can help me? This problem haved troubled me several days. Please help me, thank you!
I ran into the same problem with PyCharm 2018.1 + Python 3.6.2.
This line is the key:
LINK : fatal error LNK1104: cannot open file 'C:\Users\hp\.pyxbld\lib.win32-2.7\gensim\models\word2vec_inner.pyd'
This error message is misleading. With Python, this error actually means:
cannot open file to write to it.
The file is probably locked for writing by some process, so the linker cannot complete its job.
Solution 1
A previous Python line import word2vec_inner locked writing to the file. Reset the Python console to remove the lock:
Solution 2
Use Process Explorer to find out which program is locking the file. Use Ctrl-F, then type the name of the locked file in question, and it will give you the process that locked the file.
Solution 3
Exit Pycharm, then precompile the Cython file into a package on the command line. In case this link changes, here is a mirror:
Imagine a simple “hello world” script in a file hello.pyx:
def say_hello_to(name):
print("Hello %s!" % name)
The following could be a corresponding setup.py script:
from distutils.core import setup
from Cython.Build import cythonize
setup(
name = 'Hello world app',
ext_modules = cythonize("hello.pyx"),
)
To build, run python setup.py build_ext --inplace. Then simply start
a Python session and do from hello import say_hello_to and use the
imported function as you see fit.
One caveat if you use setuptools instead of distutils, the default
action when running python setup.py install is to create a zipped egg
file which will not work with cimport for pxd files when you try to
use them from a dependent package. To prevent this, include
zip_safe=False in the arguments to setup().

dronekit install error: instructions are not working

I followed the instructions to install dronekit-python as described in the Getting Started page.
I ran the following command:
pip install dronekit
and I got a message:
Cold notfind a version that satisfies the requirements dronekit (from
versions: 2.0.0b2 .... 2.0.0rc9)
I did as scaredrone has prescribed two days ago:
pip install dronekit=2.0.0rc4
and I got the exception:
Exception:
Traceback (most recent call last):
File "C:\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\pip\commands\install.py", line 257, in run
InstallRequirement.from_line(name, None))
File "C:\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\pip\req.py", line 172, in from_line
return cls(req, comes_from, url=url, prereleases=prereleases)
File "C:\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\pip\req.py", line 70, in __init__
req = pkg_resources.Requirement.parse(req)
File "C:\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\pip\_vendor\pkg_resources.py", line 2606, in parse
reqs = list(parse_requirements(s))
File "C:\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\pip\_vendor\pkg_resources.py", line 2544, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "C:\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\pip\_vendor\pkg_resources.py", line 2512, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', 'dronekit=2.0.0rc4', 'at', '=2.0.0rc4')
I had the same problem. Try to run
sudo pip install --pre dronekit
the --pre flag enables installation of pre-release software.
Don't know why it hasn't been documented.
Answer from here: https://discuss.dronekit.io/t/pip-install-dronekit-fails-on-odroid-xu4-unless-pre-is-used/93

chromium embedded framework CEF3 cross-compile for arm

Can anyone share a complete list of steps to be performed in order to cross compile CEF3 for ARM?
I am working on host = ubuntu 14.04 and I would like to cross compile for odroid board.
This is the list of steps I performed:
>git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
>export PATH=`pwd`/depot_tools:"$PATH"
>mkdir CEF3_odroid
>cd CEF3_odroid
>mkdir chromium
>cd chromium
>fetch --nohooks chromium --nosvn=True
>#I found the following revision reading CHROMIUM_BUILD_COMPATIBILITY.txt from https://bitbucket.org/chromiumembedded/cef/src
>gclient sync --revision 14bd12d63019fbdd6f9d6c16b986a5f64a21264b --jobs 16
>cd src
>git clone https://bitbucket.org/chromiumembedded/cef.git
>sudo apt-get install gcc-arm-linux-gnueabihf
>sudo apt-get install g++-4.8-multilib-arm-linux-gnueabihf
>./build/install-build-deps.sh --arm
>cd cef
>export GYP_GENERATORS='ninja'
>export GYP_CROSSCOMPILE=1
>export GYP_DEFINES='target_arch=arm arm_float_abi=hard component=shared_library linux_use_gold_flags=1'
>./cef_create_projects.sh
And I got the following error: gyp: Call to 'python cups_config_helper.py --libs /media/varesio/disco2/GEF/CEF3_odroid/chromium/src/chrome/installer/linux/debian_wheezy_arm-sysroot' returned exit status 1. Traceback (most recent call last): File "tools/gclient_hook.py", line 106, in RunAction(cef_dir, gyper) File "/media/varesio/disco2/GEF/CEF3_odroid/chromium/src/cef/tools/gclient_util.py", line 39, in RunAction command, cwd=dir, always=True) File "/media/varesio/disco2/GEF/CEF3_Linux/depot_tools/gclient_utils.py", line 293, in CheckCallAndFilterAndHeader return CheckCallAndFilter(args, **kwargs) File "/media/varesio/disco2/GEF/CEF3_Linux/depot_tools/gclient_utils.py", line 538, in CheckCallAndFilter rv, args, kwargs.get('cwd', None), None, None) subprocess2.CalledProcessError: Command '/usr/bin/python ../build/gyp_chromium cef.gyp -I cef.gypi' returned non-zero exit status 1 in /media/varesio/disco2/GEF/CEF3_odroid/chromium/src/cef
Thanks Andrea
I've had same problem. Resolved by adding use_cups=0 to GYP_DEFINES env.

How to list packages and dependencies that will be installed in Macports?

Is there a way to just list all new packages and their dependencies that port will install for a given command?
For instance, consider installing the SciPy stack with the suggested:
sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose
That installs a ton of packages and dependencies not listed in the above command.
Also, some of them I already have.
I'm already aware of the -y switch but that gives a verbose output of everything, including packages I had already installed.
I'm interested to have port tell me which new packages (be it dependencies or not) will be installed.
Is there a known way or do people just parse the -y output of the command, comparing each reported package against the existing installed packages?
Cheers
p.s. I'm fairly new to Macports and MacOSX (in Linux, apt-get always tells you which new packages will be installed)
You can use a port expression to print what will be installed:
port echo rdepof:$yourport and not installed
or for multiple ports
port echo \( rdepof:$yourport rdepof:$yourport2 ... \) and not installed
Due to the number of Portfiles involved in this and how the set operations are implemented, this will be rather slow. That being said, we're also working on improving this and providing feedback prior to installation like apt-get in a future MacPorts version.
neverpanic already gave a answer, but it seems unable to handle variants (like +notebook) and command-line options (like configure.compiler=macports-clang-3.7). I had a separate solution. The following Python script can display the new dependencies recursively:
#!/usr/bin/env python
#coding: utf-8
import re
import sys
import subprocess
# Gets command output as a list of lines
def popen_readlines(cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
p.wait()
if p.returncode != 0:
raise subprocess.CalledProcessError(p.returncode, cmd)
else:
return map(lambda line: line.rstrip('\n'), p.stdout.readlines())
# Gets the port name from a line like " gcc6 #6.1.0_0 (active)"
def get_port_name(port_line):
return re.sub(r'^ (\S+).*', r'\1', port_line)
# Gets installed ports as a set
def get_installed():
installed_ports_lines = popen_readlines(['port', 'installed'])[1:]
installed_ports = set(map(get_port_name, installed_ports_lines))
return installed_ports
# Gets port names from items that may contain version specifications,
# variants, or options
def get_ports(ports_and_specs):
requested_ports = set()
for item in ports_and_specs:
if not (re.search(r'^[-+#]', item) or re.search(r'=', item)):
requested_ports.add(item)
return requested_ports
# Gets dependencies for the given port list (which may contain options
# etc.), as a list of tuples (combining with level), excluding items in
# ignored_ports
def get_deps(ports, ignored_ports, level):
if ports == []:
return []
deps_raw = popen_readlines(['port', 'deps'] + ports)
uninstalled_ports = []
for line in deps_raw:
if re.search(r'Dependencies:', line):
deps = re.sub(r'.*Dependencies:\s*', '', line).split(', ')
uninstalled_ports += [x for x in deps if x not in ignored_ports]
ignored_ports |= set(deps)
port_level_pairs = []
for port in uninstalled_ports:
port_level_pairs += [(port, level)]
port_level_pairs += get_deps([port], ignored_ports, level + 1)
return port_level_pairs
def main():
if sys.argv[1:]:
ports_and_specs = sys.argv[1:]
ignored_ports = get_installed() | get_ports(ports_and_specs)
uninstalled_ports = get_deps(ports_and_specs, ignored_ports, 0)
for (port, level) in uninstalled_ports:
print ' ' * (level * 2) + port
if __name__ == '__main__':
main()
It can be invoked like port_rdeps.py libomp configure.compiler=macports-clang-3.7. As a bonus, it can show the uninstalled dependencies as a tree.

Serial COM Port For ARM in Processing

I write a program on Processing Language, to show the number of serial port in DropDownMenu list for Intel chip.
But I am struggling to run the same program on ARM chip.
Can you plz guide me on how do I resolve this issue?
import processing.serial.*; import controlP5.*;
ControlP5 cp5; DropdownList serialPortsList; Serial serialPort;
void setup() {
size(700, 400,P3D);
String[] portNames = Serial.list();
cp5 = new ControlP5(this);
// create a DropdownList
serialPortsList = cp5.addDropdownList("serial ports").setPosition(10, 10).setWidth(200);
for(int i = 0 ; i < portNames.length; i++) serialPortsList.addItem(portNames[i], i);
}
void draw() {
background(128);
}
I don't know about your above program completely but what I understood you are struggling, to show or recognized the Ports of RaspberryPi based on ARM.
For that I just search and got a solution for you. I summaries these steps for you
Update the system
sudo apt-get update
sudo apt-get dist-upgrade
Install Oracle Java
sudo apt-get install oracle-java7-jdk
sudo update-alternatives--config java
select java version "1.7.0_40"
Download & Install Processing
Go to Download \ Processing.org and get the Linux 32-bit version.
tar xvzf processing-2.1-linux32.tgz rm -rf ~/processing-2.1/java
ln -s /usr/lib/jvm/jdk-7-oracle-armhf
~/processing-2.1/java
Install the java Simple Serial connector
Download jSSC-2.6.0-Release.zip and extract it:
unzip jSSC-2.6.0-Release.zip
mv jSSC-2.6.0-Release/jssc.jar ~/processing-2.1/modes/java/libraries/serial/library/
~/processing-2.1/processing
Test Processing’s serial support
// Example by Tom Igoe
import processing.serial.*;
// The serial port
Serial myPort;
// List all the available serial ports
println(Serial.list());

Resources