Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 49 additions & 0 deletions .github/actions/aws-mfa-login/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: aws-mfa-login
author: [email protected]
description: mfa login for aws

inputs:
access_key_id:
description: 'AWS access key id'
required: true
secret_access_key:
description: 'AWS access secret key'
required: true
mfa_key:
description: 'MFA Key'
required: true
mfa_arn:
description: 'MFA arn'
required: true

runs:
using: "composite"
steps:
- run: sudo apt install awscli -y
shell: bash

- run: sudo -S -k apt-get install -y oathtool jq
shell: bash

- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ inputs.access_key_id }}
aws-secret-access-key: ${{ inputs.secret_access_key }}
aws-region: ap-northeast-2

- run: |
token=$(oathtool -b --totp ${{ inputs.mfa_key }})
aws sts get-session-token --duration-seconds 36000 --serial-number ${{ inputs.mfa_arn }} --token-code $token > mfa-temp.json
accessKeyId=$(cat mfa-temp.json | jq -r .Credentials.AccessKeyId)
secretAccessKey=$(cat mfa-temp.json | jq -r .Credentials.SecretAccessKey)
sessionToken=$(cat mfa-temp.json | jq -r .Credentials.SessionToken)
echo ${accessKeyId}
echo ${secretAccessKey}
echo ${sessionToken}
aws configure set aws_access_key_id $accessKeyId
aws configure set aws_secret_access_key $secretAccessKey
aws configure set aws_session_token $sessionToken
aws configure set region ap-northeast-2
shell: bash
- run: aws sts get-caller-identity
shell: bash
31 changes: 31 additions & 0 deletions .github/actions/floatic-ppa-access/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: floatic-ppa-access
author: [email protected]
description: ppa server inbound setting

inputs:
target_group_name:
description: "aws ec2 scurity group name"
required: true

protocol:
description: "inbound protocol"
required: true
default: tcp

port:
description: "inbound port"
required: true
default: 443

runs:
using: "composite"
steps:
- id: get_public_ip
uses: haythem/[email protected]

- run: aws ec2 authorize-security-group-ingress --group-name ${{ inputs.target_group_name }} --protocol ${{ inputs.protocol }} --port ${{ inputs.port }} --cidr ${{ steps.get_public_ip.outputs.ipv4 }}/32
shell: bash

- uses: webiny/[email protected]
with:
run: aws ec2 revoke-security-group-ingress --group-name ${{ inputs.target_group_name }} --protocol ${{ inputs.protocol }} --port ${{ inputs.port }} --cidr ${{ steps.get_public_ip.outputs.ipv4 }}/32
77 changes: 77 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CD
on:
push:
tags:
- v*

jobs:
ecr_setting:
# if: contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/deploy')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: AWS Mfa login
uses: ./.github/actions/aws-mfa-login
with:
access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
mfa_key: ${{ secrets.MFA_KEY }}
mfa_arn: ${{ secrets.MFA_ARN }}

- id: get_ecr_password
name: Get ECR password
run: |
PROIFLE_REGION=$(aws configure get region)
ECR_PASSWORD=$(aws ecr get-login-password --region $PROIFLE_REGION)
echo "ECR_PASSWORD=$ECR_PASSWORD" >> $GITHUB_OUTPUT
outputs:
ecr_password: ${{ steps.get_ecr_password.outputs.ECR_PASSWORD }}

debian_build:
needs: ecr_setting
runs-on: ubuntu-latest
container:
image: 557571393534.dkr.ecr.ap-northeast-2.amazonaws.com/floom
credentials:
username: AWS
password: ${{ needs.ecr_setting.outputs.ecr_password }}
steps:
- name: Update dist
run: sudo apt update

- uses: actions/checkout@v3
with:
path: 'flody_ws/etc/'

- name: AWS Mfa login
uses: ./flody_ws/etc/.github/actions/aws-mfa-login
with:
access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
mfa_key: ${{ secrets.MFA_KEY }}
mfa_arn: ${{ secrets.MFA_ARN }}

- name: PPA server access
uses: ./flody_ws/etc/.github/actions/floatic-ppa-access
with:
target_group_name: ${{ secrets.SECURITY_GROUP_NAME }}

- name: Checkout submodules
run: |
cd flody_ws/etc
git submodule update --init --recursive

- name: Generate debian file
run: |
source /opt/floatic/debian/ros/humble/setup.bash
cd flody_ws/etc
floom-generate rosdebian
ls debian_results/*.deb
shell: bash

- name: Upload to S3
run: |
ls flody_ws/etc/debian_results/
aws s3 cp flody_ws/etc/debian_results s3://robotics-workflow-archive/flody_snapshot --include "*.deb" --recursive
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ It subscribes to topics and maintains a buffer of recent messages like a dash ca
### Server

```
$ ros2 run rosbag2_snapshot snapshotter
$ ros2 run rosbag2_snapshot snapshotter --ros-args --params-file src/rosbag2_snapshot/rosbag2_snapshot/param/multiple_topics.params.yaml (EDITED)

Buffer recent messages until triggered to write or trigger an already running instance.

Expand All @@ -37,8 +37,8 @@ Buffer recent messages until triggered to write or trigger an already running in

### Client

###### Write all buffered data to `<datetime>.bag`
`ros2 run rosbag2_snapshot snapshotter_client --ros-params -p action_type:=trigger_write`
###### Write all buffered data to `<datetime>.bag` (EDITED)
`ros2 run rosbag2_snapshot snapshotter_client --ros-args -p action_type:=trigger_write -p prefix:=a -p filename:={절대 경로 to bag file to write to} --params-file {path to topics yaml file from rosbag2_snapshot}`

###### Write buffered data from selected topics to `new_lighting<datetime>.bag`
`ros2 run rosbag2_snapshot snapshotter_client --ros-params -p filename:=new_lighting -p topics:=["/camera/image_raw", "/camera/camera_info"]`
Expand All @@ -52,7 +52,8 @@ Buffer recent messages until triggered to write or trigger an already running in
###### Resume buffering new data
`ros2 run rosbag2_snapshot snapshotter_client --ros-params -p action_type:=resume`

###### Call trigger service manually

###### Call trigger service manually (LESS ERROR PRONE)

```
$ ros2 service call /trigger_snapshot rosbag2_snapshot_msgs/srv/TriggerSnapshot "{filename: '', topics: [], start_time: {sec: 0, nanosec: 0}, stop_time: {sec: 0, nanosec: 0}}"
Expand Down
1 change: 0 additions & 1 deletion rosbag2_snapshot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ endif()

ament_auto_package(
INSTALL_TO_SHARE
param
)
13 changes: 0 additions & 13 deletions rosbag2_snapshot/param/multiple_topics.params.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions rosbag2_snapshot/param/single_topic.params.yaml

This file was deleted.

10 changes: 5 additions & 5 deletions rosbag2_snapshot/src/snapshotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ void SnapshotterClient::setSnapshotterClientOptions(const SnapshotterClientOptio
};
}

TriggerSnapshot::Request::SharedPtr req;
TriggerSnapshot::Request::SharedPtr req = std::make_shared<TriggerSnapshot::Request>();

for (const auto & topic : opts.topics_) {
req->topics.push_back(topic.asMessage());
Expand Down Expand Up @@ -798,7 +798,7 @@ void SnapshotterClient::setSnapshotterClientOptions(const SnapshotterClientOptio
auto future_result =
rclcpp::spin_until_future_complete(this->get_node_base_interface(), result_future);

if (future_result == rclcpp::FutureReturnCode::SUCCESS) {
if (future_result != rclcpp::FutureReturnCode::SUCCESS) {
RCLCPP_ERROR(get_logger(), "Calling the service failed.");
} else {
auto result = result_future.get();
Expand All @@ -823,14 +823,14 @@ void SnapshotterClient::setSnapshotterClientOptions(const SnapshotterClientOptio
};
}

SetBool::Request::SharedPtr req;
SetBool::Request::SharedPtr req = std::make_shared<SetBool::Request>();
req->data = (opts.action_ == SnapshotterClientOptions::RESUME);

auto result_future = client->async_send_request(req);
auto future_result =
rclcpp::spin_until_future_complete(this->get_node_base_interface(), result_future);

if (future_result == rclcpp::FutureReturnCode::SUCCESS) {
if (future_result != rclcpp::FutureReturnCode::SUCCESS) {
RCLCPP_ERROR(get_logger(), "Calling the service failed.");
} else {
auto result = result_future.get();
Expand All @@ -852,4 +852,4 @@ void SnapshotterClient::setSnapshotterClientOptions(const SnapshotterClientOptio

#include <rclcpp_components/register_node_macro.hpp> // NOLINT
RCLCPP_COMPONENTS_REGISTER_NODE(rosbag2_snapshot::Snapshotter)
RCLCPP_COMPONENTS_REGISTER_NODE(rosbag2_snapshot::SnapshotterClient)
RCLCPP_COMPONENTS_REGISTER_NODE(rosbag2_snapshot::SnapshotterClient)