Browse Source

send config from python script

master
Alex Mikhalev 6 years ago
parent
commit
9fe62e38af
  1. 160
      e32_client/config_pb2.py
  2. 184
      e32_client/messages_pb2.py
  3. 48
      e32_client/ugv.py

160
e32_client/config_pb2.py

@ -0,0 +1,160 @@ @@ -0,0 +1,160 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: config.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor.FileDescriptor(
name='config.proto',
package='ugv.config',
syntax='proto3',
serialized_options=_b('H\003'),
serialized_pb=_b('\n\x0c\x63onfig.proto\x12\nugv.config\"X\n\tPidParams\x12\n\n\x02kp\x18\x01 \x01(\x02\x12\n\n\x02ki\x18\x02 \x01(\x02\x12\n\n\x02kd\x18\x03 \x01(\x02\x12\x12\n\nmax_output\x18\x04 \x01(\x02\x12\x13\n\x0bmax_i_error\x18\x05 \x01(\x02\"x\n\x06\x43onfig\x12\x17\n\x0fmin_target_dist\x18\x01 \x01(\x02\x12\x13\n\x0b\x64rive_power\x18\x02 \x01(\x02\x12(\n\tangle_pid\x18\x03 \x01(\x0b\x32\x15.ugv.config.PidParams\x12\x16\n\x0emin_flip_pitch\x18\x04 \x01(\x02\x42\x02H\x03\x62\x06proto3')
)
_PIDPARAMS = _descriptor.Descriptor(
name='PidParams',
full_name='ugv.config.PidParams',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='kp', full_name='ugv.config.PidParams.kp', index=0,
number=1, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='ki', full_name='ugv.config.PidParams.ki', index=1,
number=2, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='kd', full_name='ugv.config.PidParams.kd', index=2,
number=3, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='max_output', full_name='ugv.config.PidParams.max_output', index=3,
number=4, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='max_i_error', full_name='ugv.config.PidParams.max_i_error', index=4,
number=5, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=28,
serialized_end=116,
)
_CONFIG = _descriptor.Descriptor(
name='Config',
full_name='ugv.config.Config',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='min_target_dist', full_name='ugv.config.Config.min_target_dist', index=0,
number=1, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='drive_power', full_name='ugv.config.Config.drive_power', index=1,
number=2, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='angle_pid', full_name='ugv.config.Config.angle_pid', index=2,
number=3, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='min_flip_pitch', full_name='ugv.config.Config.min_flip_pitch', index=3,
number=4, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=118,
serialized_end=238,
)
_CONFIG.fields_by_name['angle_pid'].message_type = _PIDPARAMS
DESCRIPTOR.message_types_by_name['PidParams'] = _PIDPARAMS
DESCRIPTOR.message_types_by_name['Config'] = _CONFIG
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
PidParams = _reflection.GeneratedProtocolMessageType('PidParams', (_message.Message,), dict(
DESCRIPTOR = _PIDPARAMS,
__module__ = 'config_pb2'
# @@protoc_insertion_point(class_scope:ugv.config.PidParams)
))
_sym_db.RegisterMessage(PidParams)
Config = _reflection.GeneratedProtocolMessageType('Config', (_message.Message,), dict(
DESCRIPTOR = _CONFIG,
__module__ = 'config_pb2'
# @@protoc_insertion_point(class_scope:ugv.config.Config)
))
_sym_db.RegisterMessage(Config)
DESCRIPTOR._options = None
# @@protoc_insertion_point(module_scope)

184
e32_client/messages_pb2.py

@ -14,19 +14,23 @@ from google.protobuf import symbol_database as _symbol_database @@ -14,19 +14,23 @@ from google.protobuf import symbol_database as _symbol_database
_sym_db = _symbol_database.Default()
import config_pb2 as config__pb2
from config_pb2 import *
DESCRIPTOR = _descriptor.FileDescriptor(
name='messages.proto',
package='uas.ugv.messages',
package='ugv.messages',
syntax='proto3',
serialized_options=_b('H\003'),
serialized_pb=_b('\n\x0emessages.proto\x12\x10uas.ugv.messages\"V\n\x08Location\x12\x13\n\x0b\x66ix_quality\x18\x01 \x01(\r\x12\x10\n\x08latitude\x18\x02 \x01(\x02\x12\x11\n\tlongitude\x18\x03 \x01(\x02\x12\x10\n\x08\x61ltitude\x18\x04 \x01(\x02\"y\n\nUGV_Status\x12*\n\x05state\x18\x01 \x01(\x0e\x32\x1b.uas.ugv.messages.UGV_State\x12,\n\x08location\x18\x02 \x01(\x0b\x32\x1a.uas.ugv.messages.Location\x12\x11\n\tyaw_angle\x18\x03 \x01(\x02\"c\n\x0bUGV_Message\x12.\n\x06status\x18\x01 \x01(\x0b\x32\x1c.uas.ugv.messages.UGV_StatusH\x00\x12\x15\n\x0b\x63ommand_ack\x18\x02 \x01(\rH\x00\x42\r\n\x0bugv_message\"2\n\x10\x44riveHeadingData\x12\x0f\n\x07heading\x18\x01 \x01(\x02\x12\r\n\x05power\x18\x02 \x01(\x02\"\x93\x01\n\rGroundCommand\x12\n\n\x02id\x18\x01 \x01(\r\x12\x31\n\x04type\x18\x02 \x01(\x0e\x32#.uas.ugv.messages.GroundCommandType\x12;\n\rdrive_heading\x18\x03 \x01(\x0b\x32\".uas.ugv.messages.DriveHeadingDataH\x00\x42\x06\n\x04\x64\x61ta\"U\n\rGroundMessage\x12\x32\n\x07\x63ommand\x18\x01 \x01(\x0b\x32\x1f.uas.ugv.messages.GroundCommandH\x00\x42\x10\n\x0eground_message*\xa6\x01\n\tUGV_State\x12\x0e\n\nSTATE_IDLE\x10\x00\x12\x12\n\x0eSTATE_AQUIRING\x10\x01\x12\x11\n\rSTATE_DRIVING\x10\x02\x12\x12\n\x0eSTATE_FINISHED\x10\x03\x12\x0e\n\nSTATE_TEST\x10\x04\x12\x12\n\x0eSTATE_FLIPPING\x10\x05\x12\x11\n\rSTATE_TURNING\x10\x06\x12\x17\n\x13STATE_DRIVE_HEADING\x10\x07*b\n\x11GroundCommandType\x12\x0f\n\x0b\x43MD_DISABLE\x10\x00\x12\x17\n\x13\x43MD_DRIVE_TO_TARGET\x10\x01\x12\x0c\n\x08\x43MD_TEST\x10\x02\x12\x15\n\x11\x43MD_DRIVE_HEADING\x10\x03\x42\x02H\x03\x62\x06proto3')
)
serialized_pb=_b('\n\x0emessages.proto\x12\x0cugv.messages\x1a\x0c\x63onfig.proto\"5\n\x0eTargetLocation\x12\x10\n\x08latitude\x18\x01 \x01(\x02\x12\x11\n\tlongitude\x18\x02 \x01(\x02\"V\n\x08Location\x12\x13\n\x0b\x66ix_quality\x18\x01 \x01(\r\x12\x10\n\x08latitude\x18\x02 \x01(\x02\x12\x11\n\tlongitude\x18\x03 \x01(\x02\x12\x10\n\x08\x61ltitude\x18\x04 \x01(\x02\"q\n\nUGV_Status\x12&\n\x05state\x18\x01 \x01(\x0e\x32\x17.ugv.messages.UGV_State\x12(\n\x08location\x18\x02 \x01(\x0b\x32\x16.ugv.messages.Location\x12\x11\n\tyaw_angle\x18\x03 \x01(\x02\"_\n\x0bUGV_Message\x12*\n\x06status\x18\x01 \x01(\x0b\x32\x18.ugv.messages.UGV_StatusH\x00\x12\x15\n\x0b\x63ommand_ack\x18\x02 \x01(\rH\x00\x42\r\n\x0bugv_message\"2\n\x10\x44riveHeadingData\x12\x0f\n\x07heading\x18\x01 \x01(\x02\x12\r\n\x05power\x18\x02 \x01(\x02\"\xea\x01\n\rGroundCommand\x12\n\n\x02id\x18\x01 \x01(\r\x12-\n\x04type\x18\x02 \x01(\x0e\x32\x1f.ugv.messages.GroundCommandType\x12\x37\n\rdrive_heading\x18\x03 \x01(\x0b\x32\x1e.ugv.messages.DriveHeadingDataH\x00\x12\x37\n\x0ftarget_location\x18\x04 \x01(\x0b\x32\x1c.ugv.messages.TargetLocationH\x00\x12$\n\x06\x63onfig\x18\x05 \x01(\x0b\x32\x12.ugv.config.ConfigH\x00\x42\x06\n\x04\x64\x61ta\"Q\n\rGroundMessage\x12.\n\x07\x63ommand\x18\x01 \x01(\x0b\x32\x1b.ugv.messages.GroundCommandH\x00\x42\x10\n\x0eground_message*\xa6\x01\n\tUGV_State\x12\x0e\n\nSTATE_IDLE\x10\x00\x12\x12\n\x0eSTATE_AQUIRING\x10\x01\x12\x11\n\rSTATE_DRIVING\x10\x02\x12\x12\n\x0eSTATE_FINISHED\x10\x03\x12\x0e\n\nSTATE_TEST\x10\x04\x12\x12\n\x0eSTATE_FLIPPING\x10\x05\x12\x11\n\rSTATE_TURNING\x10\x06\x12\x17\n\x13STATE_DRIVE_HEADING\x10\x07*\x8a\x01\n\x11GroundCommandType\x12\x0f\n\x0b\x43MD_DISABLE\x10\x00\x12\x17\n\x13\x43MD_DRIVE_TO_TARGET\x10\x01\x12\x0c\n\x08\x43MD_TEST\x10\x02\x12\x15\n\x11\x43MD_DRIVE_HEADING\x10\x03\x12\x12\n\x0e\x43MD_SET_TARGET\x10\x04\x12\x12\n\x0e\x43MD_SET_CONFIG\x10\x05\x42\x02H\x03P\x00\x62\x06proto3')
,
dependencies=[config__pb2.DESCRIPTOR,],
public_dependencies=[config__pb2.DESCRIPTOR,])
_UGV_STATE = _descriptor.EnumDescriptor(
name='UGV_State',
full_name='uas.ugv.messages.UGV_State',
full_name='ugv.messages.UGV_State',
filename=None,
file=DESCRIPTOR,
values=[
@ -65,15 +69,15 @@ _UGV_STATE = _descriptor.EnumDescriptor( @@ -65,15 +69,15 @@ _UGV_STATE = _descriptor.EnumDescriptor(
],
containing_type=None,
serialized_options=None,
serialized_start=638,
serialized_end=804,
serialized_start=774,
serialized_end=940,
)
_sym_db.RegisterEnumDescriptor(_UGV_STATE)
UGV_State = enum_type_wrapper.EnumTypeWrapper(_UGV_STATE)
_GROUNDCOMMANDTYPE = _descriptor.EnumDescriptor(
name='GroundCommandType',
full_name='uas.ugv.messages.GroundCommandType',
full_name='ugv.messages.GroundCommandType',
filename=None,
file=DESCRIPTOR,
values=[
@ -93,11 +97,19 @@ _GROUNDCOMMANDTYPE = _descriptor.EnumDescriptor( @@ -93,11 +97,19 @@ _GROUNDCOMMANDTYPE = _descriptor.EnumDescriptor(
name='CMD_DRIVE_HEADING', index=3, number=3,
serialized_options=None,
type=None),
_descriptor.EnumValueDescriptor(
name='CMD_SET_TARGET', index=4, number=4,
serialized_options=None,
type=None),
_descriptor.EnumValueDescriptor(
name='CMD_SET_CONFIG', index=5, number=5,
serialized_options=None,
type=None),
],
containing_type=None,
serialized_options=None,
serialized_start=806,
serialized_end=904,
serialized_start=943,
serialized_end=1081,
)
_sym_db.RegisterEnumDescriptor(_GROUNDCOMMANDTYPE)
@ -114,39 +126,79 @@ CMD_DISABLE = 0 @@ -114,39 +126,79 @@ CMD_DISABLE = 0
CMD_DRIVE_TO_TARGET = 1
CMD_TEST = 2
CMD_DRIVE_HEADING = 3
CMD_SET_TARGET = 4
CMD_SET_CONFIG = 5
_TARGETLOCATION = _descriptor.Descriptor(
name='TargetLocation',
full_name='ugv.messages.TargetLocation',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='latitude', full_name='ugv.messages.TargetLocation.latitude', index=0,
number=1, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='longitude', full_name='ugv.messages.TargetLocation.longitude', index=1,
number=2, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=46,
serialized_end=99,
)
_LOCATION = _descriptor.Descriptor(
name='Location',
full_name='uas.ugv.messages.Location',
full_name='ugv.messages.Location',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='fix_quality', full_name='uas.ugv.messages.Location.fix_quality', index=0,
name='fix_quality', full_name='ugv.messages.Location.fix_quality', index=0,
number=1, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='latitude', full_name='uas.ugv.messages.Location.latitude', index=1,
name='latitude', full_name='ugv.messages.Location.latitude', index=1,
number=2, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='longitude', full_name='uas.ugv.messages.Location.longitude', index=2,
name='longitude', full_name='ugv.messages.Location.longitude', index=2,
number=3, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='altitude', full_name='uas.ugv.messages.Location.altitude', index=3,
name='altitude', full_name='ugv.messages.Location.altitude', index=3,
number=4, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
@ -164,34 +216,34 @@ _LOCATION = _descriptor.Descriptor( @@ -164,34 +216,34 @@ _LOCATION = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=36,
serialized_end=122,
serialized_start=101,
serialized_end=187,
)
_UGV_STATUS = _descriptor.Descriptor(
name='UGV_Status',
full_name='uas.ugv.messages.UGV_Status',
full_name='ugv.messages.UGV_Status',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='state', full_name='uas.ugv.messages.UGV_Status.state', index=0,
name='state', full_name='ugv.messages.UGV_Status.state', index=0,
number=1, type=14, cpp_type=8, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='location', full_name='uas.ugv.messages.UGV_Status.location', index=1,
name='location', full_name='ugv.messages.UGV_Status.location', index=1,
number=2, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='yaw_angle', full_name='uas.ugv.messages.UGV_Status.yaw_angle', index=2,
name='yaw_angle', full_name='ugv.messages.UGV_Status.yaw_angle', index=2,
number=3, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
@ -209,27 +261,27 @@ _UGV_STATUS = _descriptor.Descriptor( @@ -209,27 +261,27 @@ _UGV_STATUS = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=124,
serialized_end=245,
serialized_start=189,
serialized_end=302,
)
_UGV_MESSAGE = _descriptor.Descriptor(
name='UGV_Message',
full_name='uas.ugv.messages.UGV_Message',
full_name='ugv.messages.UGV_Message',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='status', full_name='uas.ugv.messages.UGV_Message.status', index=0,
name='status', full_name='ugv.messages.UGV_Message.status', index=0,
number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='command_ack', full_name='uas.ugv.messages.UGV_Message.command_ack', index=1,
name='command_ack', full_name='ugv.messages.UGV_Message.command_ack', index=1,
number=2, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
@ -247,30 +299,30 @@ _UGV_MESSAGE = _descriptor.Descriptor( @@ -247,30 +299,30 @@ _UGV_MESSAGE = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
_descriptor.OneofDescriptor(
name='ugv_message', full_name='uas.ugv.messages.UGV_Message.ugv_message',
name='ugv_message', full_name='ugv.messages.UGV_Message.ugv_message',
index=0, containing_type=None, fields=[]),
],
serialized_start=247,
serialized_end=346,
serialized_start=304,
serialized_end=399,
)
_DRIVEHEADINGDATA = _descriptor.Descriptor(
name='DriveHeadingData',
full_name='uas.ugv.messages.DriveHeadingData',
full_name='ugv.messages.DriveHeadingData',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='heading', full_name='uas.ugv.messages.DriveHeadingData.heading', index=0,
name='heading', full_name='ugv.messages.DriveHeadingData.heading', index=0,
number=1, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='power', full_name='uas.ugv.messages.DriveHeadingData.power', index=1,
name='power', full_name='ugv.messages.DriveHeadingData.power', index=1,
number=2, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
@ -288,39 +340,53 @@ _DRIVEHEADINGDATA = _descriptor.Descriptor( @@ -288,39 +340,53 @@ _DRIVEHEADINGDATA = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=348,
serialized_end=398,
serialized_start=401,
serialized_end=451,
)
_GROUNDCOMMAND = _descriptor.Descriptor(
name='GroundCommand',
full_name='uas.ugv.messages.GroundCommand',
full_name='ugv.messages.GroundCommand',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='id', full_name='uas.ugv.messages.GroundCommand.id', index=0,
name='id', full_name='ugv.messages.GroundCommand.id', index=0,
number=1, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='type', full_name='uas.ugv.messages.GroundCommand.type', index=1,
name='type', full_name='ugv.messages.GroundCommand.type', index=1,
number=2, type=14, cpp_type=8, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='drive_heading', full_name='uas.ugv.messages.GroundCommand.drive_heading', index=2,
name='drive_heading', full_name='ugv.messages.GroundCommand.drive_heading', index=2,
number=3, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='target_location', full_name='ugv.messages.GroundCommand.target_location', index=3,
number=4, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='config', full_name='ugv.messages.GroundCommand.config', index=4,
number=5, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
@ -333,23 +399,23 @@ _GROUNDCOMMAND = _descriptor.Descriptor( @@ -333,23 +399,23 @@ _GROUNDCOMMAND = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
_descriptor.OneofDescriptor(
name='data', full_name='uas.ugv.messages.GroundCommand.data',
name='data', full_name='ugv.messages.GroundCommand.data',
index=0, containing_type=None, fields=[]),
],
serialized_start=401,
serialized_end=548,
serialized_start=454,
serialized_end=688,
)
_GROUNDMESSAGE = _descriptor.Descriptor(
name='GroundMessage',
full_name='uas.ugv.messages.GroundMessage',
full_name='ugv.messages.GroundMessage',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='command', full_name='uas.ugv.messages.GroundMessage.command', index=0,
name='command', full_name='ugv.messages.GroundMessage.command', index=0,
number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
@ -367,11 +433,11 @@ _GROUNDMESSAGE = _descriptor.Descriptor( @@ -367,11 +433,11 @@ _GROUNDMESSAGE = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
_descriptor.OneofDescriptor(
name='ground_message', full_name='uas.ugv.messages.GroundMessage.ground_message',
name='ground_message', full_name='ugv.messages.GroundMessage.ground_message',
index=0, containing_type=None, fields=[]),
],
serialized_start=550,
serialized_end=635,
serialized_start=690,
serialized_end=771,
)
_UGV_STATUS.fields_by_name['state'].enum_type = _UGV_STATE
@ -385,13 +451,22 @@ _UGV_MESSAGE.oneofs_by_name['ugv_message'].fields.append( @@ -385,13 +451,22 @@ _UGV_MESSAGE.oneofs_by_name['ugv_message'].fields.append(
_UGV_MESSAGE.fields_by_name['command_ack'].containing_oneof = _UGV_MESSAGE.oneofs_by_name['ugv_message']
_GROUNDCOMMAND.fields_by_name['type'].enum_type = _GROUNDCOMMANDTYPE
_GROUNDCOMMAND.fields_by_name['drive_heading'].message_type = _DRIVEHEADINGDATA
_GROUNDCOMMAND.fields_by_name['target_location'].message_type = _TARGETLOCATION
_GROUNDCOMMAND.fields_by_name['config'].message_type = config__pb2._CONFIG
_GROUNDCOMMAND.oneofs_by_name['data'].fields.append(
_GROUNDCOMMAND.fields_by_name['drive_heading'])
_GROUNDCOMMAND.fields_by_name['drive_heading'].containing_oneof = _GROUNDCOMMAND.oneofs_by_name['data']
_GROUNDCOMMAND.oneofs_by_name['data'].fields.append(
_GROUNDCOMMAND.fields_by_name['target_location'])
_GROUNDCOMMAND.fields_by_name['target_location'].containing_oneof = _GROUNDCOMMAND.oneofs_by_name['data']
_GROUNDCOMMAND.oneofs_by_name['data'].fields.append(
_GROUNDCOMMAND.fields_by_name['config'])
_GROUNDCOMMAND.fields_by_name['config'].containing_oneof = _GROUNDCOMMAND.oneofs_by_name['data']
_GROUNDMESSAGE.fields_by_name['command'].message_type = _GROUNDCOMMAND
_GROUNDMESSAGE.oneofs_by_name['ground_message'].fields.append(
_GROUNDMESSAGE.fields_by_name['command'])
_GROUNDMESSAGE.fields_by_name['command'].containing_oneof = _GROUNDMESSAGE.oneofs_by_name['ground_message']
DESCRIPTOR.message_types_by_name['TargetLocation'] = _TARGETLOCATION
DESCRIPTOR.message_types_by_name['Location'] = _LOCATION
DESCRIPTOR.message_types_by_name['UGV_Status'] = _UGV_STATUS
DESCRIPTOR.message_types_by_name['UGV_Message'] = _UGV_MESSAGE
@ -402,45 +477,52 @@ DESCRIPTOR.enum_types_by_name['UGV_State'] = _UGV_STATE @@ -402,45 +477,52 @@ DESCRIPTOR.enum_types_by_name['UGV_State'] = _UGV_STATE
DESCRIPTOR.enum_types_by_name['GroundCommandType'] = _GROUNDCOMMANDTYPE
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
TargetLocation = _reflection.GeneratedProtocolMessageType('TargetLocation', (_message.Message,), dict(
DESCRIPTOR = _TARGETLOCATION,
__module__ = 'messages_pb2'
# @@protoc_insertion_point(class_scope:ugv.messages.TargetLocation)
))
_sym_db.RegisterMessage(TargetLocation)
Location = _reflection.GeneratedProtocolMessageType('Location', (_message.Message,), dict(
DESCRIPTOR = _LOCATION,
__module__ = 'messages_pb2'
# @@protoc_insertion_point(class_scope:uas.ugv.messages.Location)
# @@protoc_insertion_point(class_scope:ugv.messages.Location)
))
_sym_db.RegisterMessage(Location)
UGV_Status = _reflection.GeneratedProtocolMessageType('UGV_Status', (_message.Message,), dict(
DESCRIPTOR = _UGV_STATUS,
__module__ = 'messages_pb2'
# @@protoc_insertion_point(class_scope:uas.ugv.messages.UGV_Status)
# @@protoc_insertion_point(class_scope:ugv.messages.UGV_Status)
))
_sym_db.RegisterMessage(UGV_Status)
UGV_Message = _reflection.GeneratedProtocolMessageType('UGV_Message', (_message.Message,), dict(
DESCRIPTOR = _UGV_MESSAGE,
__module__ = 'messages_pb2'
# @@protoc_insertion_point(class_scope:uas.ugv.messages.UGV_Message)
# @@protoc_insertion_point(class_scope:ugv.messages.UGV_Message)
))
_sym_db.RegisterMessage(UGV_Message)
DriveHeadingData = _reflection.GeneratedProtocolMessageType('DriveHeadingData', (_message.Message,), dict(
DESCRIPTOR = _DRIVEHEADINGDATA,
__module__ = 'messages_pb2'
# @@protoc_insertion_point(class_scope:uas.ugv.messages.DriveHeadingData)
# @@protoc_insertion_point(class_scope:ugv.messages.DriveHeadingData)
))
_sym_db.RegisterMessage(DriveHeadingData)
GroundCommand = _reflection.GeneratedProtocolMessageType('GroundCommand', (_message.Message,), dict(
DESCRIPTOR = _GROUNDCOMMAND,
__module__ = 'messages_pb2'
# @@protoc_insertion_point(class_scope:uas.ugv.messages.GroundCommand)
# @@protoc_insertion_point(class_scope:ugv.messages.GroundCommand)
))
_sym_db.RegisterMessage(GroundCommand)
GroundMessage = _reflection.GeneratedProtocolMessageType('GroundMessage', (_message.Message,), dict(
DESCRIPTOR = _GROUNDMESSAGE,
__module__ = 'messages_pb2'
# @@protoc_insertion_point(class_scope:uas.ugv.messages.GroundMessage)
# @@protoc_insertion_point(class_scope:ugv.messages.GroundMessage)
))
_sym_db.RegisterMessage(GroundMessage)

48
e32_client/ugv.py

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#!/usr/bin/env python3
import logging
import sys
import serial
import threading
@ -12,10 +13,13 @@ from e32 import E32 @@ -12,10 +13,13 @@ from e32 import E32
import messages_pb2 as messages
from google.protobuf.message import Message
logging.basicConfig(format='%(asctime)s [%(name)s] %(levelname)s: %(message)s', datefmt='%Y-%b-%d %H:%M:%S')
log = logging.getLogger("ugv")
log.setLevel(logging.DEBUG)
class UGVComms(E32):
MAX_WRITE_RETRY = 5
RETRY_TIME = 1.0
RETRY_TIME = 3.0
def __init__(self, serial_port: serial.Serial):
E32.__init__(self, serial_port)
@ -31,7 +35,7 @@ class UGVComms(E32): @@ -31,7 +35,7 @@ class UGVComms(E32):
self.ser.write(b'\n')
def write_message(self, msg: Message):
print("writing message: ", msg)
log.debug("writing message: %s", msg)
data = msg.SerializeToString()
self.write_base64(data)
@ -53,11 +57,11 @@ class UGVComms(E32): @@ -53,11 +57,11 @@ class UGVComms(E32):
while True:
if cmdid in self.msg_acks:
self.msg_acks.remove(cmdid)
print("received ack for command")
log.debug("received ack for command")
return
time_left = time.time() - last_write_time
if time_left >= self.RETRY_TIME:
print("retry writing command")
log.warning("retry writing command")
self.write_message(gmsg)
last_write_time = time.time()
self.ack_cv.wait(timeout=time_left)
@ -69,7 +73,7 @@ class UGVComms(E32): @@ -69,7 +73,7 @@ class UGVComms(E32):
try:
decoded = b64decode(data, validate=True)
except binascii.Error:
print("read bad data: ", data)
log.warning("read bad data: %s", data)
self.ser.flush()
return None
msg = messages.UGV_Message()
@ -79,7 +83,7 @@ class UGVComms(E32): @@ -79,7 +83,7 @@ class UGVComms(E32):
def process_message(self, msg: messages.UGV_Message):
if msg is None:
return
print("received UGV message: ", msg)
log.debug("received UGV message: %s", msg)
if msg.HasField("command_ack"):
with self.ack_cv:
self.msg_acks.append(msg.command_ack)
@ -99,11 +103,13 @@ class UGVComms(E32): @@ -99,11 +103,13 @@ class UGVComms(E32):
try:
msg = self.read_message()
self.process_message(msg)
except serial.SerialException as e:
print("serial error: ", e, file=sys.stderr)
except serial.SerialException:
if not self.ser.is_open: # port was probably just closed
return
log.error("serial error", exc_info=True)
return
except Exception as e:
print("error reading message: ", e, file=sys.stderr)
except Exception:
log.error("error reading message", exc_info=True)
continue
@ -119,17 +125,31 @@ def main(): @@ -119,17 +125,31 @@ def main():
ugv.start()
time.sleep(0.2)
try:
cmd = messages.GroundCommand()
cmd.type = messages.CMD_SET_TARGET
cmd.target_location.latitude = 34.068415
cmd.target_location.longitude = -118.443217
# ugv.write_command(cmd)
cmd.type = messages.CMD_SET_CONFIG
cmd.config.angle_pid.kp = 0.10
cmd.config.angle_pid.ki = 0#.00005
cmd.config.angle_pid.kd = 0.4
cmd.config.angle_pid.max_output = 0.5
cmd.config.angle_pid.max_i_error = 15.0
cmd.config.min_target_dist = 10.0
cmd.config.min_flip_pitch = 90.0
ugv.write_command(cmd)
while True:
if ugv.last_status is None or ugv.last_status.state is not messages.STATE_DRIVE_HEADING:
cmd = messages.GroundCommand()
cmd.type = messages.CMD_DRIVE_HEADING
cmd.drive_heading.heading = -90.0
cmd.drive_heading.power = 0.2
cmd.drive_heading.heading = -115.0 - 180
cmd.drive_heading.power = 0.3
ugv.write_command(cmd)
time.sleep(1.0)
time.sleep(2.0)
except KeyboardInterrupt:
ugv.write_command(messages.CMD_DISABLE)
print("exiting...")
log.info("exiting...")
finally:
ugv.ser.flush()
ugv.ser.close()

Loading…
Cancel
Save