Environment variables for the agent
You can use environment variables to control Formant agent behavior. The agent reads its environment once, when the formant-agent process starts. Editing a file without restarting the agent does nothing.
This guide outlines where to set environment variables, the list of available variables, their default values, and their usage.
Where to set environment variables
Native (Debian package) installations
Add export lines to the formant user's .bashrc:
/var/lib/formant/.bashrc
The formant user which runs the formant-agent process sources /var/lib/formant/.bashrc before running the agent process. For example:
echo 'export FORMANT_UPLOAD_RATE_LIMIT_KBPS=750' | sudo tee -a /var/lib/formant/.bashrc
sudo systemctl restart formant-agentDocker installations
The Docker agent reads the same variables. There are two ways to set them:
-
Container environment. Pass
-e NAME=valuetodocker run, or to the installer through--extra-args. Container environment is fixed when the container is created, so to change a value later, re-run the installer without the provisioning token and with the new--extra-args; it recreates the container and keeps your credentials.bash <(wget -qO - https://app.formant.io/install-agent.sh) --method docker --ros 1 \ --extra-args "-e FORMANT_UPLOAD_RATE_LIMIT_KBPS=750" -
The mounted
.bashrc. The installer mounts the host's/var/lib/formantinto the container, and the agent sources/var/lib/formant/.bashrcfrom there exactly as a native install does. Edit the file on the host, then restart the container:echo 'export FORMANT_UPLOAD_RATE_LIMIT_KBPS=750' | sudo tee -a /var/lib/formant/.bashrc docker restart formant-agentA value in
.bashrcoverrides the same variable passed with-e, because the file is sourced after the container environment is applied.
If the default value for an environment variable is empty, this variable has no effect until you set a value.
Restart the agent for changes to take effect
- Native:
sudo systemctl restart formant-agent- Docker:
docker restart formant-agent(or re-run the installer if you changed-earguments)For more information, see Installing the Formant agent: Starting and stopping the agent and Install the Formant agent via Docker: Managing a Docker installation.
ROS environment variables
| Name | Default value | Description |
|---|---|---|
CATKIN_WS (ROS 1 only) | The path to the root of the catkin workspace. The Formant agent uses this to find custom ROS 1 message definitions. | |
COLCON_WS (ROS 2 only) | Absolute path to the colcon workspace for custom ROS 2 message definitions. | |
FORMANT_AGENT_PYTHON_PATH | python | The file location of the Python interpreter used by the tf2 bridge. |
FORMANT_OVERRIDE_TIMESTAMP | false | Enables replacement of timestamps on ROS messages with the current time. |
FORMANT_ROS_BRIDGE_NAME | ROS 1: ROS 2: | Set a custom name for the ROS node. |
FORMANT_ROS_VERSION | 1 or 2: sets the ROS version for the agent. | |
ROS_MASTER_URI | http://localhost:11311 | The address of the ROS master to which the Formant ROS Bridge connects. |
SOURCE_SCRIPT | The agent will source this script before running. Useful to set environment variables, etc. If the ROS setup files are not in |
General environment variables
| Name | Default value | Description |
|---|---|---|
FORMANT_AGENT_GRPC_PORT | 5501 | The port where the Formant Agent will expose the gRPC interface. |
FORMANT_AGENT_GRPC_UNIX_SOCKET | /var/lib/formant/agent.sock | The Unix Socket where the Formant Agent will start its server. |
FORMANT_AGENT_HTTP_PORT | 5502 | The port where the Formant Agent will expose the HTTP interface. |
FORMANT_AGENT_IP | localhost | The IP address where the Formant Agent will start it's server. |
FORMANT_AGENT_PYTHON3_PATH | python3 | The file location of the python3 interpreter used by the ROS bridge and media encoder. |
FORMANT_AGENT_SERVER_CERT | File location of the TLS cert. | |
FORMANT_AGENT_SERVER_KEY | File location of the TLS key | |
FORMANT_DEBUG | false | Enables debug logs. |
FORMANT_DISABLE_PYTHON | false | Disables all python subprocesses for the agent. This includes the media encoder, ROS bridge, and ROS TF bridge. Since the media encoder is a python subprocess, disabling python will disable all video and audio encoding. |
FORMANT_DISABLE_STANDARD_HOST_METRICS | false | Disables the automatic collection and ingestion of default telemetry streams, such as CPU, memory, and IP-based location. |
FORMANT_DISABLE_SYSINFO | false | Disables system information collection. (Used for NVIDIA containers). |
FORMANT_DISABLE_TEGRA_STATS | false | Disables the automatic collection and ingestion of default telemetry streams specific to Tegra systems. Jetson products (Nano, Xavier, etc.) are Tegra systems. |
FORMANT_DISABLE_TERMINAL | false | Disables the web terminal feature that allows users to run a shell through the agent. |
FORMANT_MEMORY_STATS | false | Used to monitor ROS 1 bridge performance. If |
FORMANT_NAME | Name of the Formant Agent, used to override Agent name during provisioning. | |
FORMANT_POLL_FILE_TAILING | When When | |
FORMANT_PORT_FORWARDING | true | Enables the local port forwarding feature. |
FORMANT_PROVISIONING_TOKEN | Formant provisioning token used to provision an agent. | |
FORMANT_PYTHON_GC_COLLECT | force | When set to When set to If |
FORMANT_PYTHON_GC_INTERVAL | 600 | If FORMANT_PYTHON_GC_COLLECT is set to true, ROS 1 bridge will run a Python garbage collection routine at this interval (seconds). |
FORMANT_TERMINAL_BUFFER_SIZE | 40000 | Size in bytes of the terminal buffer. |
FORMANT_UPLOAD_DEBUG_OUTPUT | false | Enables the uploading of debug logs when the environment is not production. |
STALE_MESSAGE_MS | Timeout for teleoperation messages. Messages which are older than the timeout are deemed 'stale' and disregarded. For example, if you set | |
WEBRTC_INTERFACE | N/A | Set the network interface to connect via webRTC |
Upload pacing environment variables
Available from agent 1.372.0.
By default the agent uploads recorded assets as fast as the link allows, several files in parallel. On a shared or metered uplink, for example several robots behind one satellite or cellular link, a backlog draining after a connectivity gap can take the whole uplink and degrade a live teleoperation session. These two variables put a ceiling on that traffic.
| Name | Default value | Description |
|---|---|---|
FORMANT_UPLOAD_RATE_LIMIT_KBPS | Caps the agent's total asset upload rate, in kilobits per second (1 kbps = 1000 bits/s, the same unit link speeds are quoted in). Applies to everything the agent stores as a file: video clips, images, point clouds, and JSON payloads larger than 2000 bytes, whether freshly recorded or draining from the on-disk backlog. Unset or Values below | |
FORMANT_TELEOP_UPLOAD_RATE_LIMIT_KBPS | A lower cap applied while a teleoperation session is open on this device. Has no effect unless Unset or Set: asset uploads continue during teleop, paced at this rate, and the backlog keeps draining. Same floor, clamp and parsing rules as the normal cap. |
What is and is not paced
- Numeric, text, bitset, location and small JSON datapoints are not paced. They travel on the low-latency ingest path so that dashboards and teleop telemetry stay live.
- During a teleop session the agent also stops draining its on-disk backlog of datapoints and logs until the session ends. Live values keep flowing; only buffered history waits.
- On-demand uploads share the asset path and are paced and held the same way.
Sizing the cap
The cap is per agent, not per network link. To protect a shared uplink:
- Divide the uplink capacity by the number of robots on the link.
- Subtract headroom for the teleop video you want to keep smooth.
- Set the result on every robot on the link. One robot without a cap can fill the link by itself.
Example: four robots on a 5 Mbps uplink. 5000 ÷ 4 = 1250 kbps would still fill the link, so 750 kbps per robot leaves about 2 Mbps for teleop. In Formant's test of this exact setup, a 3000 kbps cap on each robot changed nothing (4 × 3000 = 12 Mbps of demand never binds), while 750 kbps held the link at about 64% with a worst-case round trip of 35 ms.
A capped backlog drains more slowly: a large multi-part upload takes roughly three times longer under a cap, because paced uploads send one part at a time. Choose a cap that lets the backlog clear between sessions, and use a teleop cap of 0 (hold) or a small value if teleop quality matters more than upload latency.
Verifying the cap
The agent logs the caps it applied once at startup:
pacing uploads at 750 kbps; asset uploads are held during teleop (FORMANT_TELEOP_UPLOAD_RATE_LIMIT_KBPS unset)
pacing uploads at 750 kbps, and 250 kbps while teleop is active
upload pacing is off (FORMANT_UPLOAD_RATE_LIMIT_KBPS unset)
Native: journalctl -u formant-agent | grep "pacing uploads". Docker: docker logs formant-agent 2>&1 | grep "pacing uploads". If you see upload pacing is off after setting the variable, the agent did not see it: check the file or -e argument, then restart the agent (see Where to set environment variables).
Media environment variables
FORMANT_ACCELERATED_VIDEO_ENCODING | true | Enables jetson hardware accelerated encoding of video. |
FORMANT_ACCELERATED_ENCODE_SPEED_PRESET | 1 | The speed-preset for Jetson hardware-accelerated video encoding. Values are in the range [0,4]. |
FORMANT_ALLOW_H264_SOURCE | false | If other pixel formats do not work well, allow H264 to also be chosen. This will be true if FORMANT_PREFER_H264_SOURCE is also true. |
FORMANT_AUDIO_BITRATE | 96k | Desired bitrate of uploaded audio. |
FORMANT_AUDIO_NUM_CHANNELS | 1 | Number of channels of the audio device. |
FORMANT_AUDIO_USE_FILTER | true | Use anlmdn filter on audio to reduce noise. |
FORMANT_AUDIO_SAMPLE_FORMAT | s16le | Sample format of the audio device. |
FORMANT_AUDIO_SAMPLE_RATE | 16000 | Sample rate of audio device's signal. |
FORMANT_DISABLE_RESIZE_VIDEO | false | Disable Formant agent resizing the aspect ratio of the video. |
FORMANT_ENABLE_ADAPTIVE_BITRATE | true | Allow Formant to automatically reduce the video bitrate if network degradation is detected during teleoperation. Note: this will also affect encoding for telemetry streams. |
FORMANT_ENABLE_ENCODER_STATS | false | Adds encoder statistics to Formant agent logs. Experimental feature. |
FORMANT_ENCODE_SPEED_PRESET | "ultrafast" | Set the quality/speed tradeoff with GStreamer speed preset (corresponds to the enum Options from fastest (least CPU time) to slowest (highest quality): |
FORMANT_ENCODING_BITRATE | 512 | Overrides the bitrate (Kbps) of all agent-encoded video streams. |
FORMANT_ENCODING_BUFFER_SIZE | 30 | Set the Video Buffering Verifier buffer size in milliseconds. This is used to control the maximum bitrate that the encoder can produce at any given time. The default of 30 milliseconds favors a stricter control suitable for high bitrate and framerate. Shorter buffer times may allow for more consistent throughput, while being more vulnerable to network spikes. |
FORMANT_FLV_DECODE | true | Decode RTMP stream as FLV (Turn off if RTMP stream isn't working, usually because it has an audio stream). |
FORMANT_FORCE_ACCELERATED_VIDEO_ENCODING | false | If the Jetson accelerated encoder crashes, the Formant agent will turn it off. Set this to true to prevent this and keep retrying with acceleration. |
FORMANT_FORCE_ALLOW_PICAM | false | Enable use of Picam on Raspberry Pi or Jetson |
FORMANT_FRAMERATE_CAP | 24 | Formant's encoder will not output frames at a rate higher than the frame rate cap. If the hardware source is greater than this value, Formant will re-encode it to this value. |
FORMANT_GST_INFO | false | Enable log info for GStreamer. |
FORMANT_KEY_FRAME_INTERVAL | 10 | Interval in frames at which the encoder should insert full frames into output video. If you are experiencing blocky or glitchy video, consider decreasing this interval. This will transmit full frames more frequently. This may increase data consumption. |
FORMANT_LOW_BANDWIDTH_BITRATE | 64 | Bitrate to set video to when low bandwidth mode is enabled. |
FORMANT_OVERRIDE_AUDIO_CONFIGURATION | false | Override audio configuration with provided values. |
FORMANT_OVERRIDE_BITRATE | false | Override video bitrate from configuration. |
FORMANT_PREFER_H264_SOURCE | false | Receive h264 video directly from hardware camera if offered. |
FORMANT_PREFER_MJPG | false | Prefer the MJPG hardware video stream, if there is one. Typically, MJPG will be the last choice. |
FORMANT_RTSP_BUFFER_LENGTH | 0 | Length in ms of RTSP buffer. Increase this to add stability to RTSP video (at cost of latency). |
FORMANT_RTSP_PROTOCOLS | '"udp+tcp"' | Protocol for RTSP stream. Choose udp, tcp or udp+tcp. |
FORMANT_TARGET_FRAMERATE | 30 | Target framerate for hardware video streams. |
FORMANT_USE_RTP_JITTER_BUFFER | false | Enables use of jitter buffer (debug only). |
FORMANT_VIDEO_FRAMERATE | 24 | Assumed framerate of video, if framerate cannot be determined from source. |
FORMANT_VIDEO_GST_STRING | " ! clockoverlay" | Overlay a timestamp and other GStreamer strings on your video stream |
FORMANT_VIDEO_PASS | 0 (or "cbr") | Sets the 'rate control' of the video encoder. Corresponds to the enum "GstX264EncPass". If it is |
FORMANT_VIDEO_QUANTIZER | 21 | If using "quant" (4) or "qual" (5) above, then this will be the parameter passed to the quantizer. See the documentation here for more details. |
FORMANT_X264ENC_PARAMS | '' | Override Formant's standard Refer to |
See also
- Install the Formant agent
- Install the Formant agent via Docker
- Ingesting telemetry data
- Teleoperation
If you notice an issue with this page or need help, please reach out to us! Use the 'Did this page help you?' buttons below, or get in contact with our Customer Success team via the Intercom messenger in the bottom-right corner of this page, or at [email protected].
Updated 7 days ago
