High-level motion control for the Go2 robot is implemented using a request-response pattern. You can control the robot's movement by subscribing to the /api/sport/request topic and publishing unitree_api::msg::Request messages.
To simplify creating these requests, use the SportClient class (found in example/src/common/ros2_sport_client.cpp). For example, you can use SportClient::Euler to generate a request for Euler angle (roll, pitch, yaw) attitude control.
A complete high-level motion control example is provided in example/src/sport_mode_ctrl.cpp. After building, you can run it with ./install/unitree_ros2_example/bin/sport_mode_ctrl to see the robot walk back and forth along the X-axis.
// Create a ROS2 publisher
rclcpp::Publisher<unitree_api::msg::Request>::SharedPtr req_puber = this->create_publisher<unitree_api::msg::Request>("/api/sport/request", 10);
SportClient sport_req; // Instantiate a SportClient
unitree_api::msg::Request req; // Create a motion request msg
sport_req.Euler(req, roll, pitch, yaw); // Get Euler angle motion request and assign to req
req_puber->publish(req); // Publish the data