Skip to main content

Simple Remote Robot Control Protocol

Project description

S2RCP - Simple Remote Robot Control Protocol.

S2RCP is a simple application-level protocol for remote robot control. Allows remote control of robot motors by sending and receiving packets with commands. Due to the small size of the packets and the simplicity of their encoding and decoding, applications implemented on the basis of S2RCP can be launched on devices with weak hardware, for example, on EV3 Mindstorms microcomputers with the ev3dev operating system. Another advantage of S2RCP is its versatility. According to this protocol, you can control any robot where you do not need perfect precision of movements.

This package includes modules:

  • core - basic classes and functions needed to work
  • network - classes that provide communication between the robot and remote control
  • robot - for the software part of the robot
  • remote - for the software part responsible for remote controlling the robot

How to use?

Installation

Install from pip

pip install s2rcp

Code example from the robot side

  1. Implement BaseMotor interface for your motors
from s2rcp.robot import BaseMotor

class MyMotorAdapter(BaseMotor):
    def start(self, speed, inverted):
        # your implmentaion is here...

    def stop(self):
        # your implmentaion is here...
  1. Import of required modules
from s2rcp.robot import *
from s2rcp.network import TcpClient
  1. Create a TCP client to accept connection from remote controller
tcp_client = TcpClient()

# ROBOT_ADDRESS - ipv4 address in the form "xxx.xxx.xxx.xxx", for example 
# "192.168.1.10"
# ROBOT_PORT - the port that will listen to the work, for example 53445
# tcp_client.listen((ROBOT_ADDRESS, ROBOT_PORT))
  1. Create a controller and register your motors
# Create controller for motors
controller = MotorsController(tcp_client)

# Register your motors
LEFT, RIGHT = range(2)      # create constants for id motors
controller.set_motor(
    # your motor class implementing the BaseMotor interface (see above)
    LEFT, MyMotorAdapter(...)     # any constructor
)
controller.set_motor(
    RIGHT, MyMotorAdapter(...)
)
  1. Motors controller can be turned on and off
controller.start()
controller.stop()

Code example from the remote side

  1. Import of required modules
from s2rcp.remote import *
from s2rcp.network import TcpClient
  1. Create a TCP client to connect to the robot
tcp_client = TcpClient()

# ROBOT_ADDRESS - ipv4 address in the form "xxx.xxx.xxx.xxx", for example 
# "192.168.1.10"
# ROBOT_PORT - the port that the robot controller listens to, for example 
# 53445
tcp_client.connect((ROBOT_ADDRESS, ROBOT_PORT))
  1. Setup basic robot control
# Example of settings axes for "tank" control
axes_config = AxesConfig()
axes_config.add_new_axis("MOVE")
axes_config.add_motor_to_axis("MOVE", motor_id=0, motor_k=1.0)
axes_config.add_motor_to_axis("MOVE", motor_id=1, motor_k=1.0)
axes_config.add_new_axis("ROTATE")
axes_config.add_motor_to_axis("ROTATE", motor_id=0, motor_k=1.0)
axes_config.add_motor_to_axis("ROTATE", motor_id=1, motor_k=-1.0)

# Create controller
controller = RemoteController(tcp_client, axes_config)
  1. Example of robot control
# "go straight ahead"
controller.set_axis_value("MOVE", +1.0)
controller.update() 
#            ^^^ 
# Controller updates the internal state, generates commands and sends them to 
# the robot

# "turn around on the spot"
controller.set_axis_value("ROTATE", -1.0)
controller.update()

# "stop"
controller.set_axis_value("MOVE", 0)
controller.update()

Source code

See here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s2rcp-1.0.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

s2rcp-1.0.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file s2rcp-1.0.0.tar.gz.

File metadata

  • Download URL: s2rcp-1.0.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for s2rcp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 23d2c681fbc65a6e85d7089853842e07d9f055427a2b9704e63753b33dedd595
MD5 2d36db4c3888bd531635eb50caedf57d
BLAKE2b-256 9e98f1f0c0ab20a487d9bce7e1c9faa2a87b466249591bda1ba1b026e2e4cd47

See more details on using hashes here.

File details

Details for the file s2rcp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: s2rcp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for s2rcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ce0d2c439bf9892e4a3622ab082f0b1444782645d0f775d05f3024e765a1066
MD5 6f81093224be631148a41f60cd84f59d
BLAKE2b-256 da17ad9b9ff8907a7efea86b9d8dbcf000f906a7cb4f21284fa23b00573cc83f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page