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 worknetwork- classes that provide communication between the robot and remote controlrobot- for the software part of the robotremote- 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
- Implement
BaseMotorinterface 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...
- Import of required modules
from s2rcp.robot import *
from s2rcp.network import TcpClient
- 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))
- 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(...)
)
- Motors controller can be turned on and off
controller.start()
controller.stop()
Code example from the remote side
- Import of required modules
from s2rcp.remote import *
from s2rcp.network import TcpClient
- 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))
- 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)
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23d2c681fbc65a6e85d7089853842e07d9f055427a2b9704e63753b33dedd595
|
|
| MD5 |
2d36db4c3888bd531635eb50caedf57d
|
|
| BLAKE2b-256 |
9e98f1f0c0ab20a487d9bce7e1c9faa2a87b466249591bda1ba1b026e2e4cd47
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ce0d2c439bf9892e4a3622ab082f0b1444782645d0f775d05f3024e765a1066
|
|
| MD5 |
6f81093224be631148a41f60cd84f59d
|
|
| BLAKE2b-256 |
da17ad9b9ff8907a7efea86b9d8dbcf000f906a7cb4f21284fa23b00573cc83f
|