Skip to content

Parking service interface

functionC++ROS
setting stopping parameters
Switch stop

Setting stopping parameters

C++ interface

rcClientInterfaceSetGuardianintroduction

cpp
/**
* @brief Sets the Guardian parameters.
*
* This function sets the Guardian's velocity decay ratio and trigger source.
*
* @param from Specifies the operation mode (navigation or joystick).
* @param velocity_decay_ratio Specifies the velocity decay ratio.
* @param trigger_source Specifies the trigger source.
* @return bool Returns `true` for a successful setting, `false` for a failed setting.
*/
bool rcClientInterfaceSetGuardian(
    common::NAV_OR_JOY_MODE from,
    float velocity_decay_ratio,
    std::string trigger_source);

use Case

cpp
robot_control::common::NAV_OR_JOY_MODE mode = robot_control::common::NAV_OR_JOY_MODE::joy_control;
float decay_ratio = 0.5; // 示例值,表示速度衰减比率
std::string source = "SOURCE_A"; // 示例触发源
bool success = rcClientInterfaceSetGuardian(mode, decay_ratio, source);
if (success) {
    std::cout << "Guardian Parameters Set Successfully." << std::endl;
} else {
    std::cout << "Failed to Set Guardian Parameters." << std::endl;
}

Precautions

  • ensure that the incoming velocity decay ratio and trigger source are valid.

ROS2 interface

this interface is used to subscribe to guardian topic. This topic uses daystar_navigation_msgs::msg::Guardian message type, which contains information related to parking. Set the parking parameters after obtaining the information.

Topic NameTopic typerole
/guardiandaystar_navigation_msgs::msg::Guardiansubscriber

Message structure

daystar_navigation_msgs::msg::Guardian the message type is defined and usually contains parameters related to parking.

sample message

cpp
daystar_navigation_msgs::msg::Guardian guardian_msg;
// 根据daystar_navigation_msgs::msg::Guardian的定义填充消息内容

test Method

  • publish a one-time message:
bash
ros2 topic pub --once /guardian daystar_navigation_msgs/msg/Guardian "{...}"
  • continued release of news:
bash
ros2 topic pub --rate 10 /guardian daystar_navigation_msgs/msg/Guardian "{...}"

Precautions

  • make sure the ROS2 node is up and subscribing guardian topic.

  • the format of the published message must be strictly daystar_navigation_msgs::msg::Guardian the definition of the message type.

  • when continuously publishing messages, pay attention to controlling the publishing frequency to avoid network congestion.


Switch stop

C++ interface

rcClientInterfaceSetGuardianSwitchintroduction

cpp
/**
* @brief Turns Guardian on or off.
*
* This function is used to turn Guardian on or off.
*
* @param from Specifies the mode of operation (navigation or joystick).
* @param enable Specifies whether to enable Guardian (true means on, false means off).
* @return bool Returns `true` for a successful setting, `false` for a failed setting.
*/
bool rcClientInterfaceSetGuardianSwitch(
    robot_control::common::NAV_OR_JOY_MODE from,
    bool enable);

use Case

cpp
robot_control::common::NAV_OR_JOY_MODE mode = robot_control::common::NAV_OR_JOY_MODE::joy_control;
bool enable_guardian = true; // 示例值,表示开启Guardian
bool success = rcClientInterfaceSetGuardianSwitch(mode, enable_guardian);
if (success) {
    std::cout << "Guardian Switch Set Successfully." << std::endl;
} else {
    std::cout << "Failed to Set Guardian Switch." << std::endl;
}

precautions

  • ensure that the enabled state passed in is valid.