Skip to content

Commit

Permalink
changes for python 2.x to compile, and 16.04 kinetic and 18.04 melodi…
Browse files Browse the repository at this point in the history
…c dockers
  • Loading branch information
goldbattle committed Apr 19, 2022
1 parent 8761165 commit bb638ff
Show file tree
Hide file tree
Showing 17 changed files with 216 additions and 58 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/docker_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,36 @@ name: Docker
on: [push, pull_request] # on all pushes and PRs

jobs:
build_1604:
name: "ROS1 Ubuntu 16.04"
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@v2
- name: Create Workspace
run: |
export REPO=$(basename $GITHUB_REPOSITORY) &&
cd $GITHUB_WORKSPACE/.. && mkdir src/ &&
mv $REPO/ src/ && mkdir $REPO/ && mv src/ $REPO/ && cd $REPO/
- name: Build Docker
run: |
export REPO=$(basename $GITHUB_REPOSITORY) &&
docker build -t kalibr -f $GITHUB_WORKSPACE/src/$REPO/Dockerfile_ros1_16_04 .
build_1804:
name: "ROS1 Ubuntu 18.04"
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@v2
- name: Create Workspace
run: |
export REPO=$(basename $GITHUB_REPOSITORY) &&
cd $GITHUB_WORKSPACE/.. && mkdir src/ &&
mv $REPO/ src/ && mkdir $REPO/ && mv src/ $REPO/ && cd $REPO/
- name: Build Docker
run: |
export REPO=$(basename $GITHUB_REPOSITORY) &&
docker build -t kalibr -f $GITHUB_WORKSPACE/src/$REPO/Dockerfile_ros1_18_04 .
build_2004:
name: "ROS1 Ubuntu 20.04"
runs-on: ubuntu-latest
Expand Down
56 changes: 56 additions & 0 deletions Dockerfile_ros1_16_04
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM osrf/ros:kinetic-desktop-full


# Dependencies we use, catkin tools is very good build system
# https://github.com/ethz-asl/kalibr/wiki/installation
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
apt-get install -y \
git wget autoconf automake \
python2.7-dev python-pip python-scipy python-matplotlib \
ipython python-wxgtk3.0 python-tk python-igraph \
libeigen3-dev libboost-all-dev libsuitesparse-dev \
doxygen \
libopencv-dev \
libpoco-dev libtbb-dev libblas-dev liblapack-dev libv4l-dev \
python-catkin-tools


# Create the workspace and build kalibr in it
ENV WORKSPACE /catkin_ws

RUN mkdir -p $WORKSPACE/src && \
cd $WORKSPACE && \
catkin init && \
catkin config --extend /opt/ros/kinetic && \
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release

ADD . $WORKSPACE/src/kalibr
# RUN cd $WORKSPACE/src &&\
# git clone https://github.com/ori-drs/kalibr.git

RUN cd $WORKSPACE &&\
catkin build -j$(nproc)


# When a user runs a command we will run this code before theirs
# This will allow for using the manual focal length if it fails to init
# https://github.com/ethz-asl/kalibr/pull/346
ENTRYPOINT export KALIBR_MANUAL_FOCAL_LENGTH_INIT=1 && \
# /bin/bash -c "source \"$WORKSPACE/devel/setup.bash\"" && \
cd $WORKSPACE && \
/bin/bash















50 changes: 50 additions & 0 deletions Dockerfile_ros1_18_04
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM osrf/ros:melodic-desktop-full


# Dependencies we use, catkin tools is very good build system
# https://github.com/ethz-asl/kalibr/wiki/installation
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
apt-get install -y \
git wget autoconf automake nano \
python3-dev python-pip python-scipy python-matplotlib \
ipython python-wxgtk4.0 python-tk python-igraph \
libeigen3-dev libboost-all-dev libsuitesparse-dev \
doxygen \
libopencv-dev \
libpoco-dev libtbb-dev libblas-dev liblapack-dev libv4l-dev \
python-catkin-tools


# Create the workspace and build kalibr in it
ENV WORKSPACE /catkin_ws

RUN mkdir -p $WORKSPACE/src && \
cd $WORKSPACE && \
catkin init && \
catkin config --extend /opt/ros/melodic && \
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release

ADD . $WORKSPACE/src/kalibr
# RUN cd $WORKSPACE/src &&\
# git clone https://github.com/ori-drs/kalibr.git

RUN cd $WORKSPACE &&\
catkin build -j$(nproc)


# When a user runs a command we will run this code before theirs
# This will allow for using the manual focal length if it fails to init
# https://github.com/ethz-asl/kalibr/pull/346
ENTRYPOINT export KALIBR_MANUAL_FOCAL_LENGTH_INIT=1 && \
# /bin/bash -c "source \"$WORKSPACE/devel/setup.bash\"" && \
cd $WORKSPACE && \
/bin/bash









6 changes: 2 additions & 4 deletions Dockerfile_ros1_20_04
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ FROM osrf/ros:noetic-desktop-full
# https://github.com/ethz-asl/kalibr/wiki/installation
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
apt-get install -y \
git wget autoconf automake \
git wget autoconf automake nano \
python3-dev python3-pip python3-scipy python3-matplotlib \
ipython3 python3-wxgtk4.0 python3-tk \
ipython3 python3-wxgtk4.0 python3-tk python3-igraph \
libeigen3-dev libboost-all-dev libsuitesparse-dev \
doxygen \
libopencv-dev \
libpoco-dev libtbb-dev libblas-dev liblapack-dev libv4l-dev \
python3-catkin-tools python3-osrf-pycommon
RUN python3 -m pip install --upgrade pip; \
python3 -m pip install python-igraph --upgrade


# Create the workspace and build kalibr in it
Expand Down
1 change: 1 addition & 0 deletions Schweizer-Messer/sm_python/python/sm/Progress.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function #handle print in 2.x python
import time
import datetime
import sys
Expand Down
6 changes: 3 additions & 3 deletions aslam_offline_calibration/kalibr/python/kalibr_bagextractor
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ if parsed.image_topics is not None:
iProgress.sample()

print("\r done. ")
print()
print()
print("")
print("")

#extract imu data
if parsed.imu_topics is not None:
Expand All @@ -93,4 +93,4 @@ if parsed.imu_topics is not None:
spamwriter.writerow([timestamp_int, omega[0],omega[1],omega[2], alpha[0],alpha[1],alpha[2] ])
iProgress.sample()
print("\r done. ")
print()
print("")
22 changes: 11 additions & 11 deletions aslam_offline_calibration/kalibr/python/kalibr_calibrate_cameras
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ def main():

#display process
if (verbose or (view_id % 25) == 0) and calibrator.estimator.getNumBatches()>0 and view_id>1:
print()
print("")
print("------------------------------------------------------------------")
print()
print("")
print("Processed {0} of {1} views with {2} views used".format(view_id+1, numViews, calibrator.estimator.getNumBatches()))
print()
print("")
kcc.printParameters(calibrator)
print()
print("")
print("------------------------------------------------------------------")

#calibration progress
Expand All @@ -305,13 +305,13 @@ def main():
if initOutlierRejection:
#check all views after the min. number of batches has been reached
batches_to_check=list(range(0, calibrator.estimator.getNumBatches()))
print();print()
print("");print("")
print("Filtering outliers in all batches...")
initOutlierRejection=False
progress_filter = sm.Progress2(len(batches_to_check)); progress_filter.sample()
elif runEndFiltering:
#check all batches again after all views have been processed
print();print()
print("");print("")
print("All views have been processed.\n\nStarting final outlier filtering...")
batches_to_check=list(range(0, calibrator.estimator.getNumBatches()))
progress_filter = sm.Progress2(len(batches_to_check)); progress_filter.sample()
Expand Down Expand Up @@ -385,15 +385,15 @@ def main():
progress_filter.sample()

#final output
print()
print()
print("")
print("")
print("..................................................................")
print()
print("")
print("Calibration complete.")
print()
print("")
if parsed.removeOutliers:
sm.logWarn("Removed {0} outlier corners.".format(len(removedOutlierCorners)) )
print()
print("")
print("Processed {0} images with {1} images used".format(numViews, calibrator.estimator.getNumBatches()))
kcc.printParameters(calibrator)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import os
np.set_printoptions(suppress=True)

def signal_exit(signal, frame):
print()
print("")
sm.logWarn("Shutting down! (CTRL+C)")
sys.exit(1)

Expand Down Expand Up @@ -183,7 +183,7 @@ def main():
if imu is not imus[0]:
imu.findOrientationPrior(imus[0])

print()
print("")
print("Building the problem")
iCal.buildProblem(splineOrder=6,
poseKnotsPerSecond=100,
Expand All @@ -199,28 +199,28 @@ def main():
timeOffsetPadding=parsed.timeoffset_padding,
verbose = parsed.verbose)

print()
print("")
print("Before Optimization")
print("===================")
util.printErrorStatistics(iCal)

print()
print("")
print("Optimizing...")
iCal.optimize(maxIterations=parsed.max_iter, recoverCov=parsed.recover_cov)

print()
print("")
print("After Optimization (Results)")
print("==================")
util.printErrorStatistics(iCal)
util.printResults(iCal, withCov=parsed.recover_cov)

print()
print("")
bagtag = os.path.splitext(parsed.bagfile[0])[0]
yamlFilename = bagtag + "-camchain-imucam.yaml"
iCal.saveCamChainParametersYaml(yamlFilename)
print(" Saving camera chain calibration to file: {0}".format(yamlFilename))

print()
print("")
yamlFilename = bagtag + "-imu.yaml"
iCal.saveImuSetParametersYaml(yamlFilename)
print(" Saving imu calibration to file: {0}".format(yamlFilename))
Expand All @@ -233,14 +233,14 @@ def main():
reportFile = bagtag + "-report-imucam.pdf"
util.generateReport(iCal, filename=reportFile, showOnScreen=not parsed.dontShowReport)
print(" Report written to {0}".format(reportFile))
print()
print("")

if parsed.exportPoses:
print("Exporting poses...")
posesFile = bagtag + "-poses-imucam-imu0.csv"
util.exportPoses(iCal, filename=posesFile)
print("Poses written to {0}".format(posesFile))
print()
print("")

if __name__ == "__main__":
main()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function #handle print in 2.x python
import sm
from sm import PlotCollection
from kalibr_common import ConfigReader as cr
Expand Down Expand Up @@ -616,14 +617,14 @@ def printParameters(cself, dest=sys.stdout):


def printDebugEnd(cself):
print()
print()
print("")
print("")

for cidx, cam in enumerate(cself.cameras):
print("cam{0}".format(cidx))
print("----------")
print()
print()
print("")
print("")

corners, reprojs, rerrs = getReprojectionErrors(cself, cidx)
if len(rerrs)>0:
Expand All @@ -633,12 +634,12 @@ def printDebugEnd(cself):
print(se[0])
print(se[1])

print()
print("")
p = cam.geometry.projection().getParameters().flatten()
for temp in p:
print(temp)

print()
print("")
d = cam.geometry.projection().distortion().getParameters().flatten()
for temp in d:
print(temp)
Expand All @@ -652,8 +653,8 @@ def printDebugEnd(cself):
for temp in T.q():
print(temp)

print()
print()
print("")
print("")

def saveChainParametersYaml(cself, resultFile, graph):
cameraModels = {acvb.DistortedPinhole: 'pinhole',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function #handle print in 2.x python
import sm
import aslam_backend as aopt

Expand Down Expand Up @@ -146,7 +147,7 @@ def printTable(self):
print("timestamp \t", end=' ')
for cam_id in range(0, self.numCameras()):
print("cam{0} \t".format(cam_id), end=' ')
print()
print("")

#sort for time
times_sorted = np.sort(list(self.targetViews.keys()))
Expand All @@ -160,5 +161,5 @@ def printTable(self):
except KeyError:
numCorners = "-"
print("\t", numCorners, end=' ')
print()
print("")

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function #handle print in 2.x python
import yaml
import sys
import numpy as np
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def __init__(self, dataset, indices=None):
def __iter__(self):
return self

def next(self):
# required for python 2.x compatibility
idx = next(self.iter)
return self.dataset.getImage(idx)

def __next__(self):
idx = next(self.iter)
return self.dataset.getImage(idx)
Expand Down
Loading

0 comments on commit bb638ff

Please sign in to comment.