Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoboard-rcll: Translate between RCLL ProtoBuf messages and the blackboard #328

Merged
merged 20 commits into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0c5fae4
protoboard: Templated plugin to convert protobuf to blackboard
vmatare Nov 6, 2017
d862d88
protoboard: add dummy handler for RobotInfo & VersionInfo
vmatare Nov 9, 2017
04e57b1
protoboard: auto. set time on BeaconSignal
vmatare Nov 9, 2017
cf07e25
protoboard: catch & log exceptions in handlers
vmatare Nov 9, 2017
583dfea
protoboard: add pb_nesting_converter
vmatare Nov 9, 2017
55ce29c
protoboard: add quantity fields to OrderInterface
vmatare Nov 14, 2017
f48ca2d
protoboard: fix pb->bb conversion for repeated fields
vmatare Nov 14, 2017
d93f1e5
protoboard: implement matching for repeated fields
vmatare Nov 28, 2017
e956e3c
protoboard: default operators for converter
vmatare Feb 19, 2018
dddf79f
protoboard-rcll: factor out domain definition
vmatare Oct 1, 2019
afc0106
protoboard-rcll: allow clang-format
vmatare Oct 1, 2019
5786569
protoboard-rcll: add interfaces for RCLL
vmatare Oct 8, 2019
5527f34
protoboard-rcll: simplify iface type -> id mapping
vmatare Oct 8, 2019
d80e164
skills: add create_peer skill
vmatare Oct 9, 2019
795c7cd
protoboard-rcll: adapt to API changes in core
vmatare Oct 11, 2019
6a86879
protoboard-rcll: handle MachineInfo & RingInfo
vmatare Oct 14, 2019
c39bfc9
protoboard-rcll: handle RS & DS prepare
vmatare Oct 14, 2019
36c7829
protobuf-rcll: add doxygen documentation
vmatare Oct 16, 2019
9b41c1d
fawkes: update submodule to protoboard merge
vmatare Dec 5, 2019
c0a411f
protoboard-rcll: fix MachineInfoInterface::loaded_with field descr
vmatare Dec 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fawkes
Submodule fawkes updated 48 files
+4 −4 .buildkite/pipeline.yml
+3 −2 .lgtm.yml
+11 −0 cfg/conf.d/gologpp.yaml
+4 −0 etc/format-scripts/check-file.sh
+2 −1 src/libs/Makefile
+1 −1 src/libs/core/version.h
+4 −1 src/libs/interface/interface.cpp
+63 −0 src/libs/interface/message.h
+35 −0 src/libs/interfaces/ProtobufPeerInterface.xml
+14 −29 src/libs/interfaces/generator/cpp_generator.cpp
+57 −0 src/libs/protoboard/Makefile
+195 −0 src/libs/protoboard/blackboard_manager.cpp
+333 −0 src/libs/protoboard/blackboard_manager.h
+55 −0 src/libs/protoboard/plugin.h
+97 −0 src/libs/protoboard/protoboard_types.h
+272 −0 src/libs/protoboard/protobuf_thread.cpp
+174 −0 src/libs/protoboard/protobuf_thread.h
+54 −0 src/libs/protoboard/protobuf_to_bb.cpp
+289 −0 src/libs/protoboard/protobuf_to_bb.h
+8 −8 src/libs/utils/math/lines.h
+3 −3 src/lua/skiller/subskill_jumpstate.lua
+1 −1 src/plugins/Makefile
+60 −0 src/plugins/gologpp/Makefile
+63 −0 src/plugins/gologpp/action_executor.cpp
+50 −0 src/plugins/gologpp/action_executor.h
+102 −0 src/plugins/gologpp/aspect/action_executor_dispatcher.cpp
+56 −0 src/plugins/gologpp/aspect/action_executor_dispatcher.h
+77 −0 src/plugins/gologpp/aspect/action_executor_dispatcher_inifin.cpp
+45 −0 src/plugins/gologpp/aspect/action_executor_dispatcher_inifin.h
+158 −0 src/plugins/gologpp/execution_thread.cpp
+71 −0 src/plugins/gologpp/execution_thread.h
+303 −0 src/plugins/gologpp/exog_manager.cpp
+136 −0 src/plugins/gologpp/exog_manager.h
+99 −0 src/plugins/gologpp/gologpp_fawkes_backend.cpp
+70 −0 src/plugins/gologpp/gologpp_fawkes_backend.h
+120 −0 src/plugins/gologpp/message_action_executor.cpp
+55 −0 src/plugins/gologpp/message_action_executor.h
+53 −0 src/plugins/gologpp/plugin.cpp
+87 −0 src/plugins/gologpp/print_action_executor.cpp
+43 −0 src/plugins/gologpp/print_action_executor.h
+229 −0 src/plugins/gologpp/skiller_action_executor.cpp
+71 −0 src/plugins/gologpp/skiller_action_executor.h
+94 −0 src/plugins/gologpp/sleep_action_executor.cpp
+50 −0 src/plugins/gologpp/sleep_action_executor.h
+87 −0 src/plugins/gologpp/test-scenarios/blocksworld/blocksworld.gpp
+31 −0 src/plugins/gologpp/test-scenarios/blocksworld/logger.gpp
+217 −0 src/plugins/gologpp/utils.cpp
+60 −0 src/plugins/gologpp/utils.h
100 changes: 100 additions & 0 deletions src/lua/skills/robotino/create_peer.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@

----------------------------------------------------------------------------
-- create_peer.lua
--
-- (c) 2019 Victor Mataré
--
----------------------------------------------------------------------------

-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Library General Public License for more details.
--
-- Read the full text in the LICENSE.GPL file in the doc directory.

-- Initialize module
module(..., skillenv.module_init)

-- Crucial skill information
name = "create_peer"
fsm = SkillHSM:new{name=name, start="SEND_MSG"}
depends_skills = { }
depends_interfaces = {
{v = "peer_iface", type="ProtobufPeerInterface", id="/protoboard/peers"},
}

documentation = [==[Create and connect to a ProtoBuf peer

@param address The peer's IP address (string.
@param port The port to send to & receive on.
@param send_to_port The port to send to. Mutually exclusive with the @a port param.
@param recv_on_port The port to receive on. Mutually exclusive with the @a port param.
@param cipher (Optional) Cipher name
@param crypto_key (Optional) The encrypthon key

]==]

-- Initialize as skill module
skillenv.skill_module(_M)


function input_ok()
local port_ok = fsm.vars.port or (fsm.vars.send_to_port and fsm.vars.recv_on_port) and not(
fsm.vars.port and (fsm.vars.send_to_port or fsm.vars.recv_on_port)
)
local crypto_ok = (not not fsm.vars.cipher == not not fsm.vars.crypto_key)
return fsm.vars.address and port_ok and crypto_ok
end

fsm:define_states{ export_to=_M,
closure={ input_ok=input_ok },
{"SEND_MSG", JumpState}
}

fsm:add_transitions{
{"SEND_MSG", "FAILED", precond="not input_ok()", desc="wrong input params"},
{"SEND_MSG", "FINAL", cond=true}
}

function SEND_MSG:init()
local msg
if fsm.vars.send_to_port then
if fsm.vars.cipher then
msg = peer_iface.CreatePeerLocalCryptoMessage:new(
fsm.vars.address,
fsm.vars.send_to_port,
fsm.vars.recv_on_port,
fsm.vars.crypto_key,
fsm.vars.cipher
)
else
msg = peer_iface.CreatePeerLocalMessage:new(
fsm.vars.address,
fsm.vars.send_to_port,
fsm.vars.recv_on_port
)
end
else
if fsm.vars.cipher then
msg = peer_iface.CreatePeerCryptoMessage:new(
fsm.vars.address,
fsm.vars.port,
fsm.vars.crypto_key,
fsm.vars.cipher
)
else
msg = peer_iface.CreatePeerMessage:new(
fsm.vars.address,
fsm.vars.port
)
end
end
peer_iface:msgq_enqueue_copy(msg)
end

3 changes: 3 additions & 0 deletions src/lua/skills/robotino/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ skillenv.use_skill("skills.robotino.bring_product_to")
skillenv.use_skill("skills.robotino.get_product_from")
skillenv.use_skill("skills.robotino.approach_test")
skillenv.use_skill("skills.robotino.discard")

-- ProtoBuf communication
skillenv.use_skill("skills.robotino.create_peer")
2 changes: 2 additions & 0 deletions src/plugins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ SUBDIRS = clips-motor-switch \
mps-laser-gen \
webtools-bridge \
skiller_motor_state \
protoboard-rcll \
asp-planner


include $(BUILDSYSDIR)/rules.mk

gazebo: ax12_gripper tag_vision arduino conveyor_pose navgraph-generator-mps
29 changes: 29 additions & 0 deletions src/plugins/protoboard-rcll/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#*****************************************************************************
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#*****************************************************************************

BASEDIR = ../../..
include $(BASEDIR)/etc/buildsys/config.mk
include $(BUILDSYSDIR)/protobuf.mk
include $(BUILDSYSDIR)/boost.mk

PRESUBDIRS = interfaces

LIBS_protoboard_rcll = fawkesprotoboard llsf_msgs \
OrderInterface PrepareMachineInterface SendBeaconInterface ProtobufPeerInterface \
RecvBeaconInterface RCLLGameStateInterface MachineInfoInterface RingInfoInterface

CFLAGS += $(CFLAGS_CPP11)

OBJS_protoboard_rcll = rcll_receiving.o rcll_sending.o plugin.o
OBJS_all = $(OBJS_protoboard_rcll)

PLUGINS_all = $(PLUGINDIR)/protoboard-rcll.$(SOEXT)
PLUGINS_build = $(PLUGINS_all)

include $(BUILDSYSDIR)/base.mk
33 changes: 33 additions & 0 deletions src/plugins/protoboard-rcll/interfaces/MachineInfoInterface.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE interface SYSTEM "interface.dtd">
<interface name="MachineInfoInterface" author="Victor Mataré" year="2019">
<constants>
<enum name="Team">
<comment>Team color</comment>
<item name="CYAN">Cyan team</item>
<item name="MAGENTA">Magenta team</item>
</enum>
<enum name="RingColor">
<comment>Available ring colors</comment>
<item name="RING_NONE">Not a RingStation</item>
<item name="RING_BLUE">Blue ring</item>
<item name="RING_GREEN">Green ring</item>
<item name="RING_ORANGE">Orange ring</item>
<item name="RING_YELLOW">Yellow ring</item>
</enum>
</constants>
<data>
<comment>Information about a machine</comment>
<field type="string" name="machine_name" length="32">Machine name</field>
<field type="string" name="machine_type" length="32">Machine type</field>
<field type="string" name="state" length="64">Current state</field>
<field type="Team" name="team_color">Team color</field>
<field type="float" name="pose" length="3">2D Pose (x, y, yaw)</field>
<field type="string" name="zone" length="32">Zone the machine is in</field>
<field type="uint32" name="rotation">Discretized rotation in degrees</field>
<field type="bool" name="correctly_reported">Whether it was correctly reported</field>
<field type="uint32" name="loaded_with">Bases loaded in slide</field>
<field type="RingColor" name="ring_colors" length="2">Available ring colors</field>
</data>
</interface>

24 changes: 24 additions & 0 deletions src/plugins/protoboard-rcll/interfaces/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#*****************************************************************************
# Makefile Build System for Fawkes: Robotino interfaces
# -------------------
# Created on Fri Mar 26 17:25:00 2012
# Copyright (C) 2006-2012 by Tim Niemueller, AllemaniACs RoboCup Team
#
#*****************************************************************************
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#*****************************************************************************

BASEDIR = ../../../..

include $(BASEDIR)/etc/buildsys/config.mk

INTERFACES_all = $(notdir $(patsubst %.xml,%,$(wildcard $(SRCDIR)/*.xml)))
include $(BUILDSYSDIR)/interface.mk

include $(BUILDSYSDIR)/base.mk

51 changes: 51 additions & 0 deletions src/plugins/protoboard-rcll/interfaces/OrderInterface.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE interface SYSTEM "interface.dtd">
<interface name="OrderInterface" author="Victor Mataré" year="2017">
<constants>
<enum name="BaseColor">
<comment>What color to output</comment>
<item name="BASE_RED">Red base</item>
<item name="BASE_BLACK">Black base</item>
<item name="BASE_SILVER">Silver base</item>
</enum>
<enum name="RingColor">
<comment>Available ring colors</comment>
<item name="RING_BLUE">Blue ring</item>
<item name="RING_GREEN">Green ring</item>
<item name="RING_ORANGE">Orange ring</item>
<item name="RING_YELLOW">Yellow ring</item>
</enum>
<enum name="CapColor">
<comment>Available cap colors</comment>
<item name="CAP_BLACK">Black cap</item>
<item name="CAP_GREY">Grey cap</item>
</enum>
<enum name="Team">
<comment>Team color</comment>
<item name="CYAN">Cyan team</item>
<item name="MAGENTA">Magenta team</item>
</enum>
<enum name="Complexity">
<comment>Product complexity</comment>
<item name="C0">No ring</item>
<item name="C1">One ring</item>
<item name="C2">Two rings</item>
<item name="C3">Three rings</item>
</enum>
</constants>
<data>
<comment>Description of a single order</comment>
<field type="uint32" name="order_id">Order ID</field>
<field type="Complexity" name="complexity">Order complexity</field>
<field type="BaseColor" name="base_color">Requested base color</field>
<field type="RingColor" name="ring_colors" length="4">Requested rings</field>
<field type="CapColor" name="cap_color">Requested cap color</field>
<field type="uint32" name="delivery_period_begin">Delivery window start (seconds of game time)</field>
<field type="uint32" name="delivery_period_end">Delivery window end (seconds of game time)</field>
<field type="uint32" name="delivery_gate">Which gate must be used at the DS</field>
<field type="uint32" name="quantity_requested">How many of this type must be delivered</field>
<field type="uint32" name="quantity_delivered_cyan">How many were delivered by Cyan</field>
<field type="uint32" name="quantity_delivered_magenta">How many were delivered by Magenta</field>
</data>
</interface>

84 changes: 84 additions & 0 deletions src/plugins/protoboard-rcll/interfaces/PrepareMachineInterface.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE interface SYSTEM "interface.dtd">
<interface name="PrepareMachineInterface" author="Victor Mataré" year="2017">
<constants>
<enum name="MachineSide">
<comment>Side of an MPS</comment>
<item name="OUTPUT">Output side (even tag ID)</item>
<item name="INPUT">Input side (odd tag ID)</item>
</enum>
<enum name="BaseColor">
<comment>What color to output</comment>
<item name="BASE_RED">Red base</item>
<item name="BASE_BLACK">Black base</item>
<item name="BASE_SILVER">Silver base</item>
</enum>
<enum name="RingColor">
<comment>Available ring colors</comment>
<item name="RING_BLUE">Blue ring</item>
<item name="RING_GREEN">Green ring</item>
<item name="RING_ORANGE">Orange ring</item>
<item name="RING_YELLOW">Yellow ring</item>
</enum>
<enum name="CapColor">
<comment>Available cap colors</comment>
<item name="CAP_BLACK">Black cap</item>
<item name="CAP_GREY">Grey cap</item>
</enum>
<enum name="Team">
<comment>Team color</comment>
<item name="CYAN">Cyan team</item>
<item name="MAGENTA">Magenta team</item>
</enum>
<enum name="SSOp">
<comment>Storage Station operation</comment>
<item name="STORE">Store something</item>
<item name="RETRIEVE">Retrieve something</item>
</enum>
<enum name="CSOp">
<comment>Cap Station operation</comment>
<item name="RETRIEVE_CAP">Retrieve cap</item>
<item name="MOUNT_CAP">Mount cap</item>
</enum>
</constants>

<data>
<comment>No data needed really, just store last msgid</comment>
<field type="uint32" name="last_msgid">Last sent message ID</field>
<field type="int64" name="peer_id">Peer ID to send to</field>
</data>

<message name="SetPeerMessage">
<comment>Set peer ID that messages should be sent to</comment>
<field type="int64" name="peer_id">Peer ID to use</field>
</message>
<message name="PrepareBS">
<comment>Make BS output specified base element at the specified side</comment>
<field type="Team" name="team_color">The sending team's color</field>
<field type="string" length="16" name="machine">Machine name</field>
<field type="MachineSide" name="side">Where the base should come out</field>
<field type="BaseColor" name="color">What base color should come out</field>
</message>
<message name="PrepareDS">
<field type="Team" name="team_color">The sending team's color</field>
<field type="string" length="16" name="machine">Machine name</field>
<field type="uint32" name="order_id">Delivered order ID</field>
</message>
<message name="PrepareSS">
<field type="Team" name="team_color">The sending team's color</field>
<field type="string" length="16" name="machine">Machine name</field>
<field type="SSOp" name="operation">Operation to perform</field>
<field type="uint32" length="3" name="slot">Where to store/retrieve</field>
</message>
<message name="PrepareRS">
<field type="Team" name="team_color">The sending team's color</field>
<field type="string" length="16" name="machine">Machine name</field>
<field type="RingColor" name="ring_color">Ring color</field>
</message>
<message name="PrepareCS">
<field type="Team" name="team_color">The sending team's color</field>
<field type="string" length="16" name="machine">Machine name</field>
<field type="CSOp" name="operation">Operation to perform</field>
</message>
</interface>

33 changes: 33 additions & 0 deletions src/plugins/protoboard-rcll/interfaces/RCLLGameStateInterface.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE interface SYSTEM "interface.dtd">
<interface name="RCLLGameStateInterface" author="Victor Mataré" year="2017">
<constants>
<enum name="GameState">
<comment>Game state</comment>
<item name="INIT">Just after startup of the refbox</item>
<item name="WAIT_START">Time not yet running</item>
<item name="RUNNING">Game is running</item>
<item name="PAUSED">Game was paused</item>
</enum>
<enum name="GamePhase">
<comment>Game phase</comment>
<item name="PRE_GAME">Game hasn't begun</item>
<item name="SETUP">Setup phase</item>
<item name="EXPLORATION">Exploration phase</item>
<item name="PRODUCTION">Production phase</item>
<item name="POST_GAME">Game has ended</item>
</enum>
</constants>
<data>
<comment>Full game state</comment>
<field type="int64" name="game_time_sec">Time in seconds since game start</field>
<field type="int64" name="game_time_nsec">Nanoseconds part</field>
<field type="GameState" name="state">Current game state</field>
<field type="GamePhase" name="phase">Current game phase</field>
<field type="uint32" name="points_cyan">Points awarded to cyan</field>
<field type="string" name="team_cyan" length="255">Name of the cyan team</field>
<field type="uint32" name="points_magenta">Points awarded to magenta</field>
<field type="string" name="team_magenta" length="255">Name of the magenta team</field>
</data>
</interface>

Loading