ros2_control - rolling
Loading...
Searching...
No Matches
action_processor.hpp
1// Copyright 2025 ros2_control Development Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Author: Julia Jia
16
17#ifndef ONNX_POLICY_CONTROLLER__ACTION_PROCESSOR_HPP_
18#define ONNX_POLICY_CONTROLLER__ACTION_PROCESSOR_HPP_
19
20#include <string>
21#include <vector>
22
23namespace onnx_policy_controller
24{
25
26class ActionProcessor
27{
28public:
29 ActionProcessor(
30 const std::vector<std::string> & joint_names, double action_scale = 0.25,
31 bool use_default_offset = true);
32
33 // motor_targets = default_actuator + action * action_scale (Ref: mujoco_infer.py)
34 std::vector<double> process(
35 const std::vector<double> & model_outputs, const std::vector<double> & default_joint_positions);
36
37 double get_action_scale() const { return action_scale_; }
38
39private:
40 std::vector<std::string> joint_names_;
41 size_t num_joints_;
42 double action_scale_;
43 bool use_default_offset_;
44};
45
46} // namespace onnx_policy_controller
47
48#endif // ONNX_POLICY_CONTROLLER__ACTION_PROCESSOR_HPP_