![]() |
Visual Servoing Platform
version 3.5.1 under development (2023-03-14)
|
#include <visp3/robot/vpRobotMavsdk.h>
Public Member Functions | |
vpRobotMavsdk () | |
vpRobotMavsdk (const std::string &connection_info) | |
virtual | ~vpRobotMavsdk () |
Robot connection | |
void | connect (const std::string &connection_info) |
General robot information | |
float | getBatteryLevel () const |
void | getPose (vpHomogeneousMatrix &pose) const |
std::string | getAddress () const |
Robot state checking | |
bool | isRunning () const |
Sending state info | |
bool | sendMocapData (const vpHomogeneousMatrix &M) |
Commands and parameters | |
bool | arm () |
void | doFlatTrim () |
void | holdPosition () |
bool | kill () |
bool | land () |
void | setForwardSpeed (double vx) |
void | setLateralSpeed (double vy) |
void | setPosition (float dX, float dY, float dZ, float dPsi) |
void | setPosition (const vpHomogeneousMatrix &M) |
void | setVelocity (const vpColVector &vel, double delta_t) |
void | setVelocity (const vpColVector &vel) |
void | setVerticalSpeed (double vz) |
void | setYawSpeed (double wz) |
void | stopMoving () |
void | setTakeOffAlt (double altitude) |
bool | takeOff (bool interactive=true) |
Interface for Mavlink allowing to control drones or rovers using a MavLink compatible controller.
This class needs cxx17 or more recent standard enabled during ViSP cmake configuration.
This class is enabled when MavSDK C++ is installed and detected by ViSP during cmake configuration step.
Definition at line 68 of file vpRobotMavsdk.h.
vpRobotMavsdk::vpRobotMavsdk | ( | ) |
Default constructor without parameters. You need to use the connect() function afterwards.
Definition at line 747 of file vpRobotMavsdk.cpp.
vpRobotMavsdk::vpRobotMavsdk | ( | const std::string & | connection_info | ) |
Constructor.
Initializes robot controller, by discovering robots connected either with an Ethernet TCP or UDP link, or with a serial link the computer is currently connected to. Sets up signal handling to safely land/stop the robot when something wrong happens or when the user stops the binary using CRTL-C.
After having called this constructor, it is recommended to check if the robot is running with isRunning() before sending commands to the robot.
[in] | connection_info | : Specify connection information. This parameter must be written following these conventions:
|
vpException::fatalError | : If the program failed to connect to the robot. |
Definition at line 740 of file vpRobotMavsdk.cpp.
|
virtual |
Destructor. Lands the drone if not landed or stops the robot if it is a rover and safely disconnects everything.
Definition at line 753 of file vpRobotMavsdk.cpp.
bool vpRobotMavsdk::arm | ( | ) |
Arms the robot.
Definition at line 822 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::connect | ( | const std::string & | connection_info | ) |
Connects to the robot and setups the different controllers.
[in] | connection_info | : The connection information given to connect to the robot. You may use:
|
Example: udp://192.168.30.111:14550.
For more information see here.
Definition at line 768 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::doFlatTrim | ( | ) |
Sends a flat trim command to the robot, to calibrate accelerometer and gyro.
Definition at line 807 of file vpRobotMavsdk.cpp.
std::string vpRobotMavsdk::getAddress | ( | ) | const |
Gives the address given to connect to the robot.
Definition at line 788 of file vpRobotMavsdk.cpp.
float vpRobotMavsdk::getBatteryLevel | ( | ) | const |
Gets current battery level in Volts.
Definition at line 794 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::getPose | ( | vpHomogeneousMatrix & | Pose | ) | const |
Gets the current robot pose in its local NED frame.
[in] | Pose | : Homogeneous matrix describing the position and attitude of the robot. |
Definition at line 800 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::holdPosition | ( | ) |
Makes the robot hold its position.
Definition at line 838 of file vpRobotMavsdk.cpp.
bool vpRobotMavsdk::isRunning | ( | ) | const |
Checks if the robot is running, ie if the robot is connected and ready to receive commands.
Definition at line 773 of file vpRobotMavsdk.cpp.
bool vpRobotMavsdk::kill | ( | ) |
Cuts the motors. Should only be used in emergency cases.
Definition at line 909 of file vpRobotMavsdk.cpp.
bool vpRobotMavsdk::land | ( | ) |
Sends landing command. To use if your robot is a drone.
Definition at line 852 of file vpRobotMavsdk.cpp.
bool vpRobotMavsdk::sendMocapData | ( | const vpHomogeneousMatrix & | M | ) |
Sends MoCap position data to the robot.
[in] | M | : Homogeneous matrix containing the pose of the robot for the MoCap system. |
Definition at line 780 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::setForwardSpeed | ( | double | vx | ) |
Sets the forward speed, expressed in m/s , in the Front-Right-Down body frame.
[in] | vx | : Desired forward speed in m/s.
|
Definition at line 931 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::setLateralSpeed | ( | double | vy | ) |
Sets the lateral speed, expressed in m/s, in the Front-Right-Down body frame.
[in] | vy | : desired lateral speed in m/s.
|
Definition at line 942 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::setPosition | ( | const vpHomogeneousMatrix & | M | ) |
Changes the relative position of the robot based on a homogeneous transformation matrix.
[in] | M | : Homogeneous matrix with translation be expressed in meters and rotation in radians. |
Definition at line 879 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::setPosition | ( | float | dX, |
float | dY, | ||
float | dZ, | ||
float | dPsi | ||
) |
Moves the robot by the given amounts dX, dY, dZ (meters) and rotate the heading by dPsi (radian) in the Front-Right-Down (FRD) body frame. Doesn't do anything if the drone isn't flying or hovering. This function is blocking.
[in] | dX | : Relative displacement along X axis (meters). |
[in] | dY | : Relative displacement along Y axis (meters). |
[in] | dZ | : Relative displacement along Z axis (meters). |
[in] | dPsi | : Relative rotation of the heading (radians). |
Definition at line 866 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::setTakeOffAlt | ( | double | altitude | ) |
Sets the take off altitude.
[in] | altitude | : Desired altitude for take off in meters, equal to 1.0 m by default. |
Definition at line 816 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::setVelocity | ( | const vpColVector & | vel_cmd | ) |
Sets the robot velocity in its own Front-Right-Down (FRD) frame.
[in] | vel_cmd | : 4-dim robot velocity commands, vx, vy, vz, wz. Translation velocities (vx, vy, vz) should be expressed in meters and rotation velocity (wz) in radians. |
Definition at line 902 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::setVelocity | ( | const vpColVector & | vel_cmd, |
double | delta_t | ||
) |
Sets the robot velocity in its own Front-Right-Down (FRD) frame for a duration delta_t. The robot stops afterwards.
[in] | vel_cmd | : 4-dim robot velocity commands, vx, vy, vz, wz. Translation velocities (vx, vy, vz) should be expressed in meters and rotation velocity (wz) in radians. |
[in] | delta_t | : Sampling time (in seconds), time during which the velocity vel_cmd is applied. |
Definition at line 891 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::setVerticalSpeed | ( | double | vz | ) |
Sets the vertical speed, expressed in m/s, in the Front-Right-Down body frame.
[in] | vz | : desired vertical speed in m/s.
|
Definition at line 953 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::setYawSpeed | ( | double | wz | ) |
Sets the yaw speed, expressed as signed rotation speed.
[in] | wz | : Desired yaw speed in rad/s. Positive values will make the robot turn to its right / clockwise Negative values will make the robot turn to its left / counterclockwise |
Definition at line 920 of file vpRobotMavsdk.cpp.
void vpRobotMavsdk::stopMoving | ( | ) |
Stops any robot movement.
Definition at line 845 of file vpRobotMavsdk.cpp.
bool vpRobotMavsdk::takeOff | ( | bool | interactive = true | ) |
Sends take off command. To use if your robot is a drone.
[in] | interactive | : If True asks the user if the offboard mode is to be forced through the terminal. If false Offboard mode is automatically set. |
Definition at line 831 of file vpRobotMavsdk.cpp.