GithubHelp home page GithubHelp logo

bskari / pi-rc Goto Github PK

View Code? Open in Web Editor NEW
139.0 139.0 38.0 260 KB

Turn your Raspberry Pi into a radio controller for RC toys.

License: GNU General Public License v2.0

Makefile 1.42% Python 6.34% HTML 45.88% C 46.36%

pi-rc's People

Contributors

1anakin20 avatar bskari avatar mirgj avatar mzac avatar probonopd avatar vimalvnair avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pi-rc's Issues

Unable to access https://:4443/watch.html

Hello,

Unable to access watch.html, I receive following message and script stops.

Starting server
Running server on https://192.168.1.15:4443/
Traceback (most recent call last):
File "host_files.py", line 140, in
main()
File "host_files.py", line 136, in main
httpd.serve_forever()
File "/usr/lib/python3.4/socketserver.py", line 238, in serve_forever
self._handle_request_noblock()
File "/usr/lib/python3.4/socketserver.py", line 300, in _handle_request_noblock
request, client_address = self.get_request()
File "/usr/lib/python3.4/socketserver.py", line 473, in get_request
return self.socket.accept()
File "/usr/lib/python3.4/ssl.py", line 856, in accept
server_side=True)
File "/usr/lib/python3.4/ssl.py", line 364, in wrap_socket
_context=self)
File "/usr/lib/python3.4/ssl.py", line 576, in init
raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
ValueError: do_handshake_on_connect should not be specified for non-blocking sockets

How to send a signal just once?

I can successfully send this signal, with "+" being "27.145 MHz on", and "-" = off/other frequency:

+9024 -4512 +564 -564 +564 -1692 +564 -564 +564 -1692 +564 -1692 +564 -1692 +564 -564 +564 -1692 +564 -1692 +564 -564 +564 -1692 +564 -564 +564 -1692 +564 -564 +564 -1692 +564 -564 +564 -1692 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -1692 +564 -1692 +564 -1692 +564 -1692 +564 -1692 +564 -1692 +564 -1692 +564 -38628

I translated the above to

[
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 9024,
        "spacing_us": 4512,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 564,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 1692,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 564,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 1692,
        "repeats": 3
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 564,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 1692,
        "repeats": 2
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 564,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 1692,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 564,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 1692,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 564,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 1692,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 564,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 1692,
        "repeats": 1
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 564,
        "repeats": 8
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 1692,
        "repeats": 7
    },
    {
        "frequency": 27.145,
        "dead_frequency": 49.830,
        "burst_us": 564,
        "spacing_us": 1692000, 
        "repeats": 1
    }
]

I can successfully send the signal with:

sudo ./pi_pcm -v

# In another terminal:
cat mute.json > /dev/udp/127.0.0.1/12345

But it keeps repeating over and over. How can I make it send the signal just once? (Sending something all the time is not something I want to do.)

mute

Support the Raspberry Pi 2

The Raspberry Pi changed how the DMA is initialized. This should detect if it's being run on a Pi 2 and use the new DMA. In the short term, it should detect if it's running on a Pi 2, issue an error, and exit.

Convert into a Python package

It would be a lot easier for people if this project was converted into a Python package that was installable through Pip or easy_install. Plus, then people could just write plain-old Python and not have to worry about starting a remote server and formatting and sending JSON messages to it over UDP. For example, see RPIO and their GitHub project.

use seperate computer (windows 10) to run watch.py

Hello,

You mention that the watch.py can be run on the other computer. Then I got the error "/dev/null".

Apparently the codes is for the linux system.

Is it possible to run the code in the Windows enviorment?

interactive_control.py not responding

Whenever I try to control the car with my arrow keys, the python script doesn't seem to respond. After "Sending commands to 192.168.1.174" it just stops working. Thanks in advance.
interactive_control py

Cannot compile

Hi,

I've tried compiling the program just like you stated but I encounter compilation errors and the compiler terminates. Output:

Lavanoid@LavanoidPiFour ~/pi-rc $ scons
scons: Reading SConscript files...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o pi_pcm.o -c -g -Wall -Wextra -Wshadow -Wswitch-enum -Wswitch-default -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Werror pi_pcm.c
pi_pcm.c:64:21 fatal error: jansson.h: No such file or directory compilation terminated.
scons: *** [pi_pcm.o] Error 1
scons: building terminated because of errors.

Please help.

Replace gstreamer dependency from watch.py

Running watch.py requires that the user installs the gstreamer package. This is a really large package and is problematic for users with smaller SD cards.

I originally used gstreamer because I couldn't find a reliable cross-platform way of capturing images from a webcam. Running a background gstreamer process to continually save images to the hard drive and open them periodically in Python is really hacky and gross. I recently came across an OpenCV package for Python that looks like it can capture from webcams, so that should be investigated further. There's another package, SimpleCV, that looks really easy to use, but I think that installing it with pip requires GCC to be installed as well as Python development headers, while many distributions have packages for Python OpenCV, so I'd prefer to use the latter if possible. I've also heard that the Raspberry Pi camera module and OpenCV are sometimes difficult to work with together, so those should be tested, as well as separate laptops or other computers with webcams.

It would also be nice to add an option to remove the webcam dependency all together, so that the Pi can still search for command codes and users can just watch the car for movement themselves.

microseconds 10x?

I'm running on a RPi v1 B.
I'm using a USB scope to view the generated frequency signal and all my timings.
I modified control_dune_warrior.py to work with my requirements and found the usec values I specified produced timings that were 10 times longer.
So for example where you have:
if bit_pattern[-1] == 0:
useconds = 127
That would output the frequency for 1270 microseconds.
I wasn't able to understand the cause, so I divided my desired timings by 10 and the output is better.
I'm concerned I might still have some underlying issue I should address though.

Timings from other applications, old and new, are correct on my scope, so I think it's pi-rc, control_dune_warrior.py, or maybe some OS/hardware setting related to DMA?
Any idea what would cause this?
Thanks
Ion

2.4 GHz?

My RC car runs on 2.4 GHz, what should I do?

Raspberry pi 3B+ Crash

Hi
I want to use this script to control my RC car.
However, on my Raspberry PI 3B+ he is completely stuck, and nothing works when I start.

You can replicate the problem:
1: Clone repository
2:

make
sudo -s
./pi_pcm

3: started ./pi_pcm -v and python3 host_files.py
4: after a few seconds, the pi is stuck and does not respond to any input. (also on mouse / keyboard)

[Request] Ability to turn front wheels without accelerating

As the title states, would it be possible to turn the front directional wheels without accelerating? Would be useful for turning the vehicle without "breaking the speed limit", I seem to crash my car when I accelerate while turning - being able to slow down on a turn would be great!

Sorry for not paying much attention on this project lately, I've had college and I've been diagnosed with depression as well as anxiety so I haven't been able to do much recently. We still need to sort out that PIP package thing that we were planning to do.

Thanks again!

Added partial Raspberry Pi 4 support

I have achieved to make this work partially on the Pi 4. By guessing my way with the datasheet and by copy pasting from this PiFmRDS updated file who aims to support the Pi 4, and lots of luck. Mainly, it was updating the addresses. I have no clue how I made it work.

However, as I said, it is partial. With the RC car I tested it with, I could only achieve it to go forwards. I am unsure it is the RC car I tested it with or something else. I don't believe much it is the car. The RC car works fine with the Pi 2. I don't know enough about low level to figure it out.

The code is in my fork pi4 branch: https://github.com/1anakin20/pi-rc/tree/pi4

Add control spec for a Dunn Rite Hydro-Net

`{
"name": "Dunn Right Hydro-Net Pool Skimmer",
"description": "https://dunnriteproducts.com/hydro-net/",
"frequency": 27.15,
"synchronization_burst_us": 1500,
"synchronization_spacing_us": 500,
"total_synchronizations": 4,
"signal_burst_us": 500,
"signal_spacing_us": 500,

"forward": 46,
"forward_left": 34,
"forward_right": 52,
"left": 0,
"reverse": 28,
"reverse_left": 10,
"reverse_right": 40,
"right": 0

}`

Errors when running the control.html-site.

Been trying to get a car running through the control.html-site, but getting all kinds of errors (see attached image). Sometimes it works, sometimes it doesn't. I am running the control.html-file using a Tornado web server and visiting the site using my Mac. Maybe there is something with the encoding?

My json looks like this:
{
"name": "Driftin Cars 27 mhz",
"description": "Bought for 99 crowns at Teknikmagasinet. 27.145 mhz.",
"frequency": 27.145,
"synchronization_burst_us": 1200,
"synchronization_spacing_us": 400,
"total_synchronizations": 4,
"signal_burst_us": 400,
"signal_spacing_us": 400,

"forward": 10,
"forward_left": 27,
"forward_right": 35,
"left": 57,
"reverse": 40,
"reverse_left": 51,
"reverse_right": 45,
"right": 65

}

screen shot 2015-05-08 at 13 26 31

I've done it!

Hi again, I've finally created the .json for my car. Here is the link to the .json: dl.dropbox.com/s/eqttx72i6wq1tjc/jsbr-fmustang-40m.json?dl=0

Here is a picture of it too: https://www.dropbox.com/s/vljvwuxngbuvcs6/DSC_0482.jpg?dl=0

This is some info about it:

Manufacturer: JSBR
Frequency: 40MHz
Model of: Ford Mustang
Item No. 23819

Thanks again for this amazing project! It's so awesome!

Filter Required?

Would this require some sort of 'filter' to be able to transmit Legally? I have heard from other people that it would transmit in the 3rd, 5th, 7th and 9th without one (which are essential bands)

[Q] Writing a HTML/Javascript to control the car from a browser

Hi again,

Now that I have PI-RC working, is it possible to send UDP packets to the pi_pcm server from a web browser using Javascript? If so, what contents does the UDP packet contain exactly? Can you provide an example? Is it also possible for you to provide a simple Javascript that sends the packet?

I'm asking because I've written a web page for my current project which allows me to control a robot from my Nintendo 3DS and I think it would be awesome to create a page that works with Pi-RC too.

Thanks again!

Could not allocate memory

>sudo -s
# ./pi_pcm
Using mbox device /dev/vcio.
Could not allocate memory.
Terminating with signal 0

This was working up until just recently (likely today). This might have been the result of an update or 2, though I have no specific hunches.

My debug skills with c are very rudimentary, but I determined from some print edits that it's this line that the memory error is coming from:

pi-rc/pi_pcm.c

Lines 470 to 472 in bfc74a4

if(! (mbox.mem_ref = mem_alloc(mbox.handle, NUM_PAGES * 4096, 4096, MEM_FLAG))) {
fatal("Could not allocate memory.\n");
}

...

Well, actually... a restart seems to have fixed this issue and it is working again... so feel free to close, but I'm going to post to see what you think was going on here... It might happen again, and may indicate some underlying issue I should look into?

Can't compile pi-rc

Hey,
I just tried to follow your "Getting Started" instructions. Unfortunatelly it fails on the command 'scons'

-> scons: *** No SConstruct file found.
File "/usr/lib/scons/SCons/Script/Main.py", line 912, in _main

I had a look into the pi-rc directory and found a Makefile, so I decided to make.
Now, when I try to ./pi_pcm -v my raspberry freezes.

What am I doing wrong? Any help is highly appreciated.

Thanks!

Segmentation fault on line 554 of pi_pcm.c

I'm trying to use your program, and when running the pi_pcm create by make, I get the following output:

pi@raspberrypi:~/pi-rc $ sudo ./pi_pcm
Using mbox device /dev/vcio.
Terminating with signal 11

Further inspection using gdb yields:

(gdb) run
Starting program: /home/pi/pi-rc/pi_pcm
Using mbox device /dev/vcio.

Program received signal SIGSEGV, Segmentation fault.
0x00011a68 in write_samples (cbp=0x0, frequency=49.8300018) at pi_pcm.c:554
554             ctl->sample[i] = 0x5a << 24 | frequency_control; /* Silence */
(gdb) backtrace
#0  0x00011a68 in write_samples (cbp=0x0, frequency=49.8300018) at pi_pcm.c:554
#1  0x00011204 in main (argc=1, argv=0xbefff804) at pi_pcm.c:326

I am using a Raspberry Pi 1 model B with completely fresh Raspbian Jessie lite (headless).

It's probably my fault, but I'm not a C programmer, so I don't really know what's going on here.

[Q] You tried a Pi-Face Control and Display (CAD)?

Hi again,

I thought it would be awesome if the PiFace CAD (http://www.piface.org.uk/products/piface_control_and_display/) could be used with this program. I've written the scripts and everything. This would be a great bonus for your repo! Here's the link: https://www.dropbox.com/s/jjncyh1gdho2sgp/pifacecad_interactive_control.py?dl=0

Here's a video of it working: https://www.youtube.com/watch?v=W0RaCfn0hJQ&list=UUAdvO-XWlx-q6D_5bJ2blnA

Thanks again!

unable to contact server; did you start it

i did all the steps but i dont know how start the server... from the putty terminal in windos always i have;
unable to contact server; did you start it?
and
server does not appear to be listening for messages, aborting
thanks for your assistance

pi_pcm not responding

hi there, thanks for your tutorial.
I am trying to install everything on my pi and found that when I am trying to execute following command, pi does not respond anything.....

root@raspberrypi:/home/pi/pi-rc# ./pi_pcm

do you know what could be the reason ?
Thanks,
Atul

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.