Skip to content
Open
Show file tree
Hide file tree
Changes from 11 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
1 change: 1 addition & 0 deletions .bazeliskrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
USE_BAZEL_VERSION=8.4.2
28 changes: 19 additions & 9 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
# Default to an optimized build to match Drake.
build -c opt
# Default to an optimized build.
build --compilation_mode=opt

# Default build options to match Drake.
# Default build options.
build --force_pic
build --strip=never
build --strict_system_includes

# Default test options.
build --test_output=errors
build --test_summary=terse

# Use C++20.
# Bazel has two universes of command-line copts and linkopts: the "target"
# config (`--copt`) and the "host" aka "exec" config (`--host_copt`).
# Since franka_driver doesn't cross-compile, we want the two configs to be the same,
# so we should always set both flavors for all copts and linkopts.
build --cxxopt=-std=c++20
build --host_cxxopt=-std=c++20
build --host_cxxopt=-std=c++20

# https://github.com/bazelbuild/bazel/issues/1164
build --action_env=CCACHE_DISABLE=1

# Use eigen, fmt, spdlog from the host OS via pkg-config, rather than bzlmod.
# It's okay to remove this line if you'd rather use bzlmod. For details, see:
# https://github.com/RobotLocomotion/drake/blob/master/tools/flags/BUILD.bazel
build --@drake//tools/flags:public_repo_default=pkgconfig

# Try to import user-specific configuration local to workspace.
try-import %workspace%/user.bazelrc
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ bazel.log
core
*~
*.jlp
MODULE.bazel.lock
117 changes: 117 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
module(name = "drake_franka_driver")

bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_cc", version = "0.2.9")
bazel_dep(name = "rules_python", version = "1.6.3")
bazel_dep(name = "gflags", version = "2.2.2")
bazel_dep(name = "rules_shell", version = "0.6.1")

bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2", dev_dependency = True)

# Pinocchio is required for libfranka v5 (FR3 robots) dynamics computations.
# Version 2.6.21 provides the rigid body dynamics needed by the modern libfranka API.
bazel_dep(name = "pinocchio", version = "2.6.21.bcr.4")

# LCM (Lightweight Communications and Marshalling) for inter-process communication.
# Using a specific commit from the main branch for latest features.
LCM_COMMIT = "4f9f586e9fda1ab2d5e12427386226519f65b6de"

bazel_dep(name = "lcm")
archive_override(
module_name = "lcm",
sha256 = "d2de73ea17993d3586eb9559b48ac3e35dd68064ad6abbdd3e0d4081e5b90685",
strip_prefix = "lcm-{}".format(LCM_COMMIT.lstrip("v")),
urls = [x.format(LCM_COMMIT) for x in [
"https://github.com/lcm-proj/lcm/archive/{}.tar.gz",
]],
)

bazel_dep(name = "drake")

# Drake version configuration.
DRAKE_COMMIT = "v1.45.0"

DRAKE_CHECKSUM = "fd70210cbbe233b78bb6df2d8f42c7334ea15fca8833865322d788ab4eaf0c16"

archive_override(
module_name = "drake",
sha256 = DRAKE_CHECKSUM,
strip_prefix = "drake-{}".format(DRAKE_COMMIT.lstrip("v")),
urls = [x.format(DRAKE_COMMIT) for x in [
"https://github.com/RobotLocomotion/drake/archive/{}.tar.gz",
]],
)

# Use the host system /usr/bin/python3.
python_repository = use_repo_rule(
"@drake//tools/workspace/python:repository.bzl",
"python_repository",
)

python_repository(
name = "python",
linux_interpreter_path = "/usr/bin/python3",
requirements_flavor = "build",
)

register_toolchains("@python//:all")

# Import Drake's public dependencies (deprecated pycodestyle, buildifier).
drake_dep_repositories = use_extension(
"@drake//tools/workspace:default.bzl",
"drake_dep_repositories",
)
use_repo(
drake_dep_repositories,
"buildifier",
"pycodestyle",
)

# Import Drake's internal dependencies for linting tools.
internal_repositories = use_extension(
"@drake//tools/workspace:default.bzl",
"internal_repositories",
)
use_repo(
internal_repositories,
"cpplint_internal",
"pycodestyle_internal",
"styleguide_internal",
)

# Create aliases for Drake dependencies that libfranka needs to access.
# Drake uses a flag-based system to switch between module and pkgconfig versions.
# We'll use Drake's eigen_repository to get the configured version.
eigen_repository = use_repo_rule(
"@drake//tools/workspace/eigen:repository.bzl",
"eigen_repository",
)

eigen_repository(name = "eigen")

# Import external dependencies for Franka robot control.
# This provides:
# - drake_models: Robot URDF/SDF models for visualization and simulation
# - libfranka_v4 (0.9.0): Control library for FE3 robots with firmware v4.x
# - libfranka_v5 (~0.15.0): Control library for FR3 robots with firmware v5.x
# - libfranka_common_v4/v5: Shared protocol definitions for each version
external_repos = use_extension(
"//tools/workspace:external_repositories.bzl",
"external_repositories",
)
use_repo(
external_repos,
"drake_models",
"libfranka_common_v4",
"libfranka_common_v5",
"libfranka_v4",
"libfranka_v5",
)

# Poco repository (system library from /usr).
poco_repository = use_repo_rule(
"//tools/workspace/poco:repository.bzl",
"poco_repository",
)

poco_repository(name = "poco")
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# Panda Arm - Franka Emika
This repository contains the application code used to communicate with the Franka Emika arm from Drake.
This repository contains the application code used to communicate with the Franka Emika arm from Drake.

## Software Versions

This driver supports both FR3 (newer) and FE3 (older) Franka robots:

- **Drake**: v1.45.0
- **libfranka v5** (~0.15.0): For FR3 robots with firmware v5.x
- **libfranka v4** (0.9.0): For FE3 robots with firmware v4.x
- **Pinocchio**: 2.6.21 (required for libfranka v5 dynamics)
- **LCM**: Latest from main branch

## Building the driver
Before you begin, install the prerequisite:
Before you begin, install the prerequisites:
```
sudo apt install libgflags-dev
sudo apt install libgflags-dev libpoco-dev
```

To build, run `bazel build //...`. This will output two versions of
Expand All @@ -29,8 +39,8 @@ To add a gripper, update the `models/add_franka_control.yaml` with the respectiv
## Links

* [Website](https://www.franka.de/technology)
* [Franka Control Interface (FCI) Documentation](https://frankaemika.github.io/docs/)
* [`libfranka` API Docs](https://frankaemika.github.io/libfranka/)
* [Franka Control Interface (FCI) Documentation](https://frankarobotics.github.io/docs/)
* [`libfranka` API Docs](https://frankarobotics.github.io/libfranka/)
* [Panda datasheet](https://s3-eu-central-1.amazonaws.com/franka-de-uploads/uploads/Datasheet-EN.pdf)

## Notes
Expand All @@ -39,11 +49,11 @@ To add a gripper, update the `models/add_franka_control.yaml` with the respectiv
* The FCI docs have excellent instructions for getting your network
interface on Ubuntu set up.
* There are two very distinct versions of Pandas: the FE3 (older) and FR3 (newer)
* There are three version to think about: firmware on the robot (we use
`v4.x`, and `v5.x`) and `libfranka` driver software on the host PC
(`0.8.0` for `v4.x` FE3, and `0.10.0` for `v5.x` FR3).
* There are three versions to think about: firmware on the robot (we use
`v4.x` and `v5.x`), `libfranka` driver software on the host PC
(0.9.0 for `v4.x` FE3, and ~0.15.0 for `v5.x` FR3), and the robot model itself.
* You should see suffixes like `_v4` and `_v5` for relevant
libraries and binaries.
libraries and binaries throughout this codebase.
* If you use the wrong driver, you should get an error like:

terminate called after throwing an instance of 'franka::IncompatibleVersionException'
Expand Down
71 changes: 0 additions & 71 deletions WORKSPACE

This file was deleted.

14 changes: 8 additions & 6 deletions environ.bzl
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# -*- mode: python -*-
# vi: set ft=python :

# Write out a repository that contains:
# - An empty BUILD file, to define a package.
# - An environ.bzl file with variable assignments for each ENV_NAMES item.
def _impl(repository_ctx):
vars = repository_ctx.attr._vars
vars = repository_ctx.attr.vars
bzl_content = []
for key in vars:
value = repository_ctx.os.environ.get(key, "")
Expand All @@ -21,6 +18,8 @@ def _impl(repository_ctx):
executable = False,
)

_string_list = attr.string_list()

def environ_repository(name = None, vars = []):
"""Provide specific environment variables for use in a WORKSPACE file.
The `vars` are the environment variables to provide.
Expand All @@ -33,9 +32,12 @@ def environ_repository(name = None, vars = []):
rule = repository_rule(
implementation = _impl,
attrs = {
"_vars": attr.string_list(default = vars),
"vars": _string_list,
},
local = True,
environ = vars,
)
rule(name = name)
rule(
name = name,
vars = vars,
)
16 changes: 8 additions & 8 deletions franka-driver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ cc_binary(
"@drake//multibody/plant",
"@drake//multibody/parsing:parsing",
"@gflags",
"@lcm",
"@lcm//lcm:lcm-static",
"@libfranka_v5",
],
data = [
"//models:franka_control_models",
"@drake//manipulation/models/franka_description:models",
"@drake_models//:franka_description",
],
)

Expand All @@ -35,12 +35,12 @@ cc_binary(
"@drake//multibody/plant",
"@drake//multibody/parsing:parsing",
"@gflags",
"@lcm",
"@lcm//lcm:lcm-static",
"@libfranka_v4",
],
data = [
"//models:franka_control_models",
"@drake//manipulation/models/franka_description:models",
"@drake_models//:franka_description",
],
)

Expand All @@ -54,12 +54,12 @@ cc_binary(
"@drake//lcmtypes:panda",
"@drake//lcmtypes:schunk",
"@gflags",
"@lcm",
"@lcm//lcm:lcm-static",
"@libfranka_v5",
],
data = [
"//models:franka_control_models",
"@drake//manipulation/models/franka_description:models",
"@drake_models//:franka_description",
],
)

Expand All @@ -73,12 +73,12 @@ cc_binary(
"@drake//lcmtypes:panda",
"@drake//lcmtypes:schunk",
"@gflags",
"@lcm",
"@lcm//lcm:lcm-static",
"@libfranka_v4",
],
data = [
"//models:franka_control_models",
"@drake//manipulation/models/franka_description:models",
"@drake_models//:franka_description",
],
)
add_lint_tests()
2 changes: 1 addition & 1 deletion models/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ filegroup(
"add_franka_control.yaml",
],
data = [
"@drake//manipulation/models/franka_description:models",
"@drake_models//:franka_description",
],
visibility = ["//visibility:public"],
)
Loading