1.安装依赖
sudo apt-get install uuid-dev libboost-all-dev libpoco-dev libgoogle-glog-dev python-dev python-setuptools python-pip
sudo dpkg -i bros_1.3.0_amd64.deb cmake_3.15.4_amd64.deb cyber-bzl_5.0.0_amd64.deb fastrtps-bzl_1.5.0_amd64.deb protobuf-bzl_3.6.1_amd64.deb
sudo python easy_install protobuf-3.6.1-py2.7.egg
easy_install
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==20.7.0','console_scripts','easy_install'
__requires__ = 'setuptools==20.7.0'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('setuptools==20.7.0', 'console_scripts', 'easy_install')()
)
View Code
2.构建
打开终端
测试protobuf安装成功没:
protoc --version
libprotoc 3.6.1
libprotobuf.so->libprotobuf.so.3.6.1
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
cd examples
mkdir build
cd build
cmake ../ -DCMAKE_PREFIX_PATH=/opt/bros
make
View Code
3.运行
/opt/cyber/setup.bash
./talker # 运行talker
./listener # 运行listener
4.使用action
# 使用Action
复制examples/proto目录下的fibonacci.proto,改为带上你自己的Action名字的protobuf文件,如TestAction.proto
仅仅修改Goal,Result和Feedback部分,其他不要动
```proto
syntax = "proto2";
message Fibonacci // 这里改成你自己的如TestAction
{
// App definition
message Goal
{
// 这部分改为你自己的Goal定义
required int32 order = 1;
}
message Result
{
// 这部分改为你自己的Result定义
repeated int32 sequence = 1;
}
message Feedback
{
// 这部分改为你自己的Feedback定义
repeated int32 sequence = 1;
}
// Impl definition
message Impl
{
// Common
message Time
{
required int32 sec = 1;
required uint32 nanosec = 2;
}
message GoalInfo
{
required bytes goal_id = 1;
required Time stamp = 2;
}
message GoalStatus
{
required GoalInfo goal_info = 1;
required int32 status = 2;
}
// Goal Service
message SendGoalService
{
message Request
{
required bytes goal_id = 1;
required Goal goal = 2;
}
message Response
{
required Time stamp = 1;
required bool accepted = 2;
}
}
// CancelGaol service
message CancelGoalService
{
message Request
{
required GoalInfo goal_info = 1;
}
message Response
{
required int32 return_code = 1;
}
}
// Result Service
message GetResultService
{
message Request
{
required bytes goal_id = 1;
}
message Response
{
required bytes goal_id = 1;
required int32 status = 2;
required Result result = 3;
}
}
// Feedback publisher
message FeedbackMessage
{
required bytes goal_id = 1;
required Feedback feedback = 2;
}
// GoalStatus publisher
message GoalStatusMessage
{
repeated GoalStatus status_list = 1;
}
}
}
```