Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

added custom time offset paramter (time stamp) #43

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
76 changes: 76 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
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 ../*.deb
shell: bash

- name: Upload to S3
run: |
aws s3 cp $(ls flody_ws/*.deb) s3://robotics-workflow-archive/sick_scan2/
18 changes: 18 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/include/**",
"/opt/ros/humble/include/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
2 changes: 2 additions & 0 deletions driver/src/sick_generic_caller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ int main(int argc, char **argv)
int skip=0;
bool sw_pll_only_publish=true;
bool intensity=true;
double time_offset = 0.0;

// Declare default parameters
node->declare_parameter<std::string>("frame_id", "world");
Expand All @@ -214,6 +215,7 @@ int main(int argc, char **argv)
node->declare_parameter<bool>("use_software_pll", use_software_pll);
node->declare_parameter<bool>("sw_pll_only_publish", sw_pll_only_publish);
node->declare_parameter<bool>("intensity",intensity);
node->declare_parameter<double>("time_offset",intensity);

#if 0
//handling if params had been defined before
Expand Down
11 changes: 10 additions & 1 deletion driver/src/sick_scan_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ namespace sick_scan
node->get_parameter("use_software_pll", cfg.use_software_pll);
node->get_parameter("sw_pll_only_publish",cfg.sw_pll_only_publish);
node->get_parameter("intensity",cfg.intensity);
node->get_parameter("time_offset",cfg.time_offset);
update_config(cfg);
}
#if 0
Expand Down Expand Up @@ -2397,6 +2398,7 @@ namespace sick_scan

bRet = SoftwarePLL::instance().getCorrectedTimeStamp(&recvTimeStamp,
SystemCountScan);
recvTimeStamp = rclcpp::Time(recvTimeStamp) + rclcpp::Duration::from_nanoseconds(this->config_.time_offset);
double timestampfloat_coor = recvTimeStamp.sec + recvTimeStamp.nanosec * 1e-9;
double DeltaTime = timestampfloat - timestampfloat_coor;
//ROS_INFO("%F,%F,%u,%u,%F",timestampfloat,timestampfloat_coor,SystemCountTransmit,SystemCountScan,DeltaTime);
Expand Down Expand Up @@ -2970,9 +2972,16 @@ namespace sick_scan
if (sendMsg & outputChannelFlagId) // publish only configured channels - workaround for cfg-bug MRS1104
{
msg.header.stamp = recvTimeStamp;

// RCLCPP_INFO(getMainNode()->get_logger(), "time_offset : %f", config_.time_offset);
//msg.range_min = 0.0f;
//msg.range_max = 100.0f;
for (auto & d : msg.ranges){
if(d > msg.range_max || d <= 0.0001){
d = std::numeric_limits<float>::infinity();
} else if(d <= msg.range_min){
d = msg.range_min;
}
}
pub_->publish(msg);
}
#else
Expand Down
2 changes: 1 addition & 1 deletion include/sick_scan/SickScanConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace sick_scan
int skip;
bool use_software_pll;
bool sw_pll_only_publish;

double time_offset;
};
}

Expand Down