Visual Servoing Platform
version 3.4.0
|
#include <vpRobotBebop2.h>
Public Member Functions | |
vpRobotBebop2 (bool verbose=false, bool setDefaultSettings=true, std::string ipAddress="192.168.42.1", int discoveryPort=44444) | |
virtual | ~vpRobotBebop2 () |
Drone networking information | |
std::string | getIpAddress () |
int | getDiscoveryPort () |
General drone information | |
void | doFlatTrim () |
unsigned int | getBatteryLevel () |
void | setVerbose (bool verbose) |
void | resetAllSettings () |
Drone state checking | |
bool | isFlying () |
bool | isHovering () |
bool | isLanded () |
bool | isRunning () |
bool | isStreaming () |
Motion commands and parameters | |
void | cutMotors () |
double | getMaxTilt () |
void | setMaxTilt (double maxTilt) |
void | setPitch (int value) |
void | setPosition (float dX, float dY, float dZ, float dPsi, bool blocking) |
void | setPosition (const vpHomogeneousMatrix &M, bool blocking) |
void | setRoll (int value) |
void | setVelocity (const vpColVector &vel, double delta_t) |
void | setVerticalSpeed (int value) |
void | setYawSpeed (int value) |
void | stopMoving () |
void | takeOff (bool blocking=true) |
Streaming commands and parameters (only available if ViSP was built with FFMpeg support) | |
void | getGrayscaleImage (vpImage< unsigned char > &I) |
void | getRGBaImage (vpImage< vpRGBa > &I) |
int | getVideoHeight () |
int | getVideoWidth () |
void | setExposure (float expo) |
void | setStreamingMode (int mode) |
void | setVideoResolution (int mode) |
void | setVideoStabilisationMode (int mode) |
void | startStreaming () |
void | stopStreaming () |
Camera control commands and parameters | |
double | getCameraHorizontalFOV () const |
double | getCurrentCameraPan () const |
double | getMaxCameraPan () const |
double | getMinCameraPan () const |
double | getCurrentCameraTilt () const |
double | getMaxCameraTilt () const |
double | getMinCameraTilt () const |
void | setCameraOrientation (double tilt, double pan, bool blocking=false) |
void | setCameraPan (double pan, bool blocking=false) |
void | setCameraTilt (double tilt, bool blocking=false) |
Static Public Member Functions | |
static void | land () |
Interface for Parrot ARSDK3, allowing to control the Bebop 2 drone and get images from the camera (if ViSP was built with FFMpeg support).
Definition at line 71 of file vpRobotBebop2.h.
vpRobotBebop2::vpRobotBebop2 | ( | bool | verbose = false , |
bool | setDefaultSettings = true , |
||
std::string | ipAddress = "192.168.42.1" , |
||
int | discoveryPort = 44444 |
||
) |
Constructor (only one available).
Initialises drone control, by discovering drones with IP ipAddress and port discoveryPort on the wifi network the computer is currently connected to. Sets up signal handling to safely land the drone when something bad happens.
After having called this constructor, it is recommanded to check if the drone is running with isRunning() before sending commands to the drone.
[in] | verbose | : turn verbose on or off If verbose is true : info, warning, error and fatal error messages are displayed. If verbose is false : only warning, error and fatal error messages are displayed. |
[in] | setDefaultSettings | : set default settings or not If setDefaultSettings is true : the drone is reset to factory settings and the following parameters are set :
|
[in] | ipAddress | : ip address used to discover the drone on the wifi network. |
[in] | discoveryPort | : port used to discover the drone on the wifi network. |
vpException::fatalError | : If the program failed to connect to the drone. |
Definition at line 114 of file vpRobotBebop2.cpp.
References vpException::fatalError, resetAllSettings(), setCameraOrientation(), setExposure(), setMaxTilt(), setStreamingMode(), setVerbose(), setVideoResolution(), and setVideoStabilisationMode().
|
virtual |
Destructor. Lands the drone if not landed, safely disconnects everything, and deactivates video streaming and decoding if needed.
Definition at line 214 of file vpRobotBebop2.cpp.
void vpRobotBebop2::cutMotors | ( | ) |
Cuts the motors. Should only be used in emergency cases.
Definition at line 600 of file vpRobotBebop2.cpp.
void vpRobotBebop2::doFlatTrim | ( | ) |
Sends a flat trim command to the robot, to calibrate accelerometer and gyro.
Definition at line 222 of file vpRobotBebop2.cpp.
References isLanded(), isRunning(), and vpTime::sleepMs().
unsigned int vpRobotBebop2::getBatteryLevel | ( | ) |
Gets current battery level.
Definition at line 263 of file vpRobotBebop2.cpp.
double vpRobotBebop2::getCameraHorizontalFOV | ( | ) | const |
Gets camera horizontal FOV (degrees).
Definition at line 269 of file vpRobotBebop2.cpp.
double vpRobotBebop2::getCurrentCameraPan | ( | ) | const |
Gets current camera pan (degrees).
Definition at line 293 of file vpRobotBebop2.cpp.
Referenced by setCameraTilt().
double vpRobotBebop2::getCurrentCameraTilt | ( | ) | const |
Gets current camera tilt (degrees).
Definition at line 275 of file vpRobotBebop2.cpp.
Referenced by setCameraPan().
int vpRobotBebop2::getDiscoveryPort | ( | ) |
Gets the drone port used during wifi discovery.
Definition at line 249 of file vpRobotBebop2.cpp.
void vpRobotBebop2::getGrayscaleImage | ( | vpImage< unsigned char > & | I | ) |
Gets the last streamed and decoded image from the drone camera feed in grayscale. The image obtained has a width of 856 and a height of 480.
[in,out] | I | : grayscale image that will contain last streamed and decoded image after the function ends. |
Definition at line 788 of file vpRobotBebop2.cpp.
References vpImageConvert::BGRToGrey(), vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().
std::string vpRobotBebop2::getIpAddress | ( | ) |
Gets the drone IP address used during wifi discovery.
Definition at line 243 of file vpRobotBebop2.cpp.
double vpRobotBebop2::getMaxCameraPan | ( | ) | const |
Gets maximum camera pan (degrees).
Definition at line 305 of file vpRobotBebop2.cpp.
double vpRobotBebop2::getMaxCameraTilt | ( | ) | const |
Gets maximum camera tilt (degrees).
Definition at line 287 of file vpRobotBebop2.cpp.
double vpRobotBebop2::getMaxTilt | ( | ) |
Gets the current max pitch and roll values allowed for the drone.
Definition at line 255 of file vpRobotBebop2.cpp.
double vpRobotBebop2::getMinCameraPan | ( | ) | const |
Gets minimum camera pan (degrees).
Definition at line 299 of file vpRobotBebop2.cpp.
double vpRobotBebop2::getMinCameraTilt | ( | ) | const |
Gets minimum camera tilt (degrees).
Definition at line 281 of file vpRobotBebop2.cpp.
Gets the last streamed and decoded image from the drone camera feed in RGBa. The image obtained has a width of 856 and a height of 480.
[in,out] | I | : RGBa image that will contain last streamed and decoded image after the function ends. |
Definition at line 816 of file vpRobotBebop2.cpp.
References vpImageConvert::BGRToRGBa(), vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().
int vpRobotBebop2::getVideoHeight | ( | ) |
Gets the height of the video streamed by the drone (pixels).
Definition at line 841 of file vpRobotBebop2.cpp.
int vpRobotBebop2::getVideoWidth | ( | ) |
Gets the width of the video streamed by the drone (pixels).
Definition at line 848 of file vpRobotBebop2.cpp.
bool vpRobotBebop2::isFlying | ( | ) |
Checks if the drone is currently flying, ie if the drone is up in the air and moving.
Definition at line 434 of file vpRobotBebop2.cpp.
Referenced by setPitch(), setPosition(), setRoll(), setVerticalSpeed(), and setYawSpeed().
bool vpRobotBebop2::isHovering | ( | ) |
Checks if the drone is currently hovering, ie if the drone is up in the air but not moving.
Definition at line 425 of file vpRobotBebop2.cpp.
Referenced by setPitch(), setPosition(), setRoll(), setVerticalSpeed(), setYawSpeed(), and takeOff().
bool vpRobotBebop2::isLanded | ( | ) |
Checks if the drone is currently landed.
Definition at line 443 of file vpRobotBebop2.cpp.
Referenced by doFlatTrim(), setStreamingMode(), setVideoResolution(), stopMoving(), and takeOff().
bool vpRobotBebop2::isRunning | ( | ) |
Checks if the drone is running, ie if the drone is connected and ready to receive commands.
Definition at line 399 of file vpRobotBebop2.cpp.
Referenced by doFlatTrim(), resetAllSettings(), setCameraOrientation(), setCameraPan(), setCameraTilt(), setExposure(), setMaxTilt(), setPitch(), setPosition(), setRoll(), setStreamingMode(), setVerticalSpeed(), setVideoResolution(), setVideoStabilisationMode(), setYawSpeed(), startStreaming(), stopMoving(), and takeOff().
bool vpRobotBebop2::isStreaming | ( | ) |
Checks if the drone is currently streaming and decoding the video from its camera.
Definition at line 412 of file vpRobotBebop2.cpp.
Referenced by setStreamingMode(), and setVideoResolution().
|
static |
Sends landing command.
Definition at line 478 of file vpRobotBebop2.cpp.
Referenced by stopStreaming().
void vpRobotBebop2::resetAllSettings | ( | ) |
Resets drone settings (like max tilt or streaming mode) to factory defaults.
Definition at line 723 of file vpRobotBebop2.cpp.
References isRunning(), and vpTime::sleepMs().
Referenced by vpRobotBebop2().
void vpRobotBebop2::setCameraOrientation | ( | double | tilt, |
double | pan, | ||
bool | blocking = false |
||
) |
Sets camera orientation : tilt and pan (degrees).
[in] | tilt | : The desired tilt. |
[in] | pan | : The desired pan. |
[in] | blocking | : If true, the function returns when the camera reached the desired position. If false, returns immediately. You can check if the camera reached the desired position using getCurrentCameraTilt() and getCurrentCameraPan(). |
Definition at line 319 of file vpRobotBebop2.cpp.
References isRunning(), and vpTime::sleepMs().
Referenced by vpRobotBebop2().
void vpRobotBebop2::setCameraPan | ( | double | pan, |
bool | blocking = false |
||
) |
Sets camera pan (degrees).
[in] | pan | : The desired pan. |
[in] | blocking | : If true, the function returns when the camera reached the desired position. If false, returns immediately. You can check if the camera reached the desired position using getCurrentCameraPan(). |
Definition at line 377 of file vpRobotBebop2.cpp.
References getCurrentCameraTilt(), isRunning(), and vpTime::sleepMs().
void vpRobotBebop2::setCameraTilt | ( | double | tilt, |
bool | blocking = false |
||
) |
Sets camera tilt (degrees).
[in] | tilt | : The desired tilt. |
[in] | blocking | : If true, the function returns when the camera reached the desired position. If false, returns immediately. You can check if the camera reached the desired position using getCurrentCameraTilt(). |
Definition at line 348 of file vpRobotBebop2.cpp.
References getCurrentCameraPan(), isRunning(), and vpTime::sleepMs().
void vpRobotBebop2::setExposure | ( | float | expo | ) |
Sets the exposure compensation of the video (min : -1.5, max : 1.5).
[in] | expo | : desired video exposure compensation. |
Definition at line 857 of file vpRobotBebop2.cpp.
References isRunning(), and vpTime::sleepMs().
Referenced by vpRobotBebop2().
void vpRobotBebop2::setMaxTilt | ( | double | maxTilt | ) |
Sets the max pitch and roll values for the drone. The smallest possible angle is 5, the maximum is 35.
[in] | maxTilt | : new maximum pitch and roll value for the drone (degrees). |
Definition at line 750 of file vpRobotBebop2.cpp.
References isRunning().
Referenced by vpRobotBebop2().
void vpRobotBebop2::setPitch | ( | int | value | ) |
Sets the pitch angle, expressed as signed percentage of the maximum pitch angle.
[in] | value | : desired pitch in signed percentage, between 100 and -100. Positive values will make the drone tilt and go forward Negative values will make the drone tilt and go backward |
Definition at line 548 of file vpRobotBebop2.cpp.
References isFlying(), isHovering(), and isRunning().
void vpRobotBebop2::setPosition | ( | float | dX, |
float | dY, | ||
float | dZ, | ||
float | dPsi, | ||
bool | blocking | ||
) |
Moves the drone by the given amounts dX, dY, dZ (meters) and rotate the heading by dPsi (radian). Doesn't do anything if the drone isn't flying or hovering.
[in] | dX | : displacement along X axis (meters). |
[in] | dY | : displacement along Y axis (meters). |
[in] | dZ | : displacement along Z axis (meters). |
[in] | dPsi | : rotation of the heading (radians). |
[in] | blocking | : specifies whether the function should be blocking or not. If blocking is true, the function will wait until the drone has finished moving. If blocking is false, the function will return even if the drone is still moving. |
Definition at line 622 of file vpRobotBebop2.cpp.
References isFlying(), isHovering(), isRunning(), and vpTime::sleepMs().
Referenced by setPosition(), and setVelocity().
void vpRobotBebop2::setPosition | ( | const vpHomogeneousMatrix & | M, |
bool | blocking | ||
) |
Changes the position of the drone based on a homogeneous transformation matrix.
[in] | M | : homogeneous matrix. Translation should be expressed in meters and rotation in radians. |
[in] | blocking | : specifies whether the function should be blocking or not. If blocking is true, the function will wait until the drone has finished moving. If blocking is false, the function will return even if the drone is still moving. |
Definition at line 654 of file vpRobotBebop2.cpp.
References vpHomogeneousMatrix::getRotationMatrix(), vpRotationMatrix::getThetaUVector(), vpHomogeneousMatrix::getTranslationVector(), and setPosition().
void vpRobotBebop2::setRoll | ( | int | value | ) |
Sets the roll angle, expressed as signed percentage of the maximum roll angle.
[in] | value | : desired roll in signed percentage, between 100 and -100. Positive values will make the drone tilt and go to its right Negative values will make the drone tilt and go to its left |
Definition at line 576 of file vpRobotBebop2.cpp.
References isFlying(), isHovering(), and isRunning().
void vpRobotBebop2::setStreamingMode | ( | int | mode | ) |
Sets the streaming mode.
[in] | mode | : desired streaming mode. If mode = 0 (default mode), the streaming minimizes latency with average reliability (best for piloting). If mode = 1, the streaming maximizes the reliability with an average latency (best when streaming quality is important but not the latency). If mode = 2, the streaming maximizes the reliability using a framerate decimation with an average latency (best when streaming quality is important but not the latency). |
Definition at line 888 of file vpRobotBebop2.cpp.
References isLanded(), isRunning(), isStreaming(), and vpTime::sleepMs().
Referenced by vpRobotBebop2().
void vpRobotBebop2::setVelocity | ( | const vpColVector & | vel_cmd, |
double | delta_t | ||
) |
Sets the drone velocity.
[in] | vel_cmd | : Drone 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 681 of file vpRobotBebop2.cpp.
References vpExponentialMap::direct(), setPosition(), vpArray2D< Type >::size(), and stopMoving().
void vpRobotBebop2::setVerbose | ( | bool | verbose | ) |
Sets the verbose level for console prints.
[in] | verbose | : specifies the desired verbose level. If verbose is true : info, warning, error and fatal error messages are displayed. If verbose is false : only warning, error and fatal error messages are displayed. |
Definition at line 710 of file vpRobotBebop2.cpp.
Referenced by vpRobotBebop2().
void vpRobotBebop2::setVerticalSpeed | ( | int | value | ) |
Sets the vertical speed, expressed as signed percentage of the maximum vertical speed.
[in] | value | : desired vertical speed in signed percentage, between 100 and -100. Positive values will make the drone go up Negative values will make the drone go down |
Definition at line 495 of file vpRobotBebop2.cpp.
References isFlying(), isHovering(), and isRunning().
void vpRobotBebop2::setVideoResolution | ( | int | mode | ) |
Sets the streaming mode.
[in] | mode | : desired streaming mode. If mode = 0 (default mode), the resolution is 480p (856x480). If mode = 1, the resolution is 720p (1280x720). |
Definition at line 937 of file vpRobotBebop2.cpp.
References isLanded(), isRunning(), isStreaming(), and vpTime::sleepMs().
Referenced by vpRobotBebop2().
void vpRobotBebop2::setVideoStabilisationMode | ( | int | mode | ) |
Sets the video stabilisation mode.
[in] | mode | : desired stabilisation mode. If mode = 0, the video follows drone angles (no stabilisation, default). If mode = 1, the video is stabilised on roll only. If mode = 2, the video is stabilised on pitch only. If mode = 3, the video is stabilised on both pitch and roll. |
Definition at line 990 of file vpRobotBebop2.cpp.
References isRunning().
Referenced by vpRobotBebop2().
void vpRobotBebop2::setYawSpeed | ( | int | value | ) |
Sets the yaw speed, expressed as signed percentage of the maximum yaw speed.
[in] | value | : desired yaw speed in signed percentage, between 100 and -100. Positive values will make the drone turn to its right / clockwise Negative values will make the drone turn to its left / counterclockwise |
Definition at line 521 of file vpRobotBebop2.cpp.
References isFlying(), isHovering(), and isRunning().
void vpRobotBebop2::startStreaming | ( | ) |
Starts the video streaming from the drone camera. Every time a frame is received, it is decoded and stored into m_currentImage, which can be obtained with getImage().
Definition at line 1029 of file vpRobotBebop2.cpp.
References isRunning(), and vpTime::sleepMs().
void vpRobotBebop2::stopMoving | ( | ) |
Stops any drone movement.
Definition at line 767 of file vpRobotBebop2.cpp.
References isLanded(), and isRunning().
Referenced by setVelocity().
void vpRobotBebop2::stopStreaming | ( | ) |
Stops the streaming and decoding of the drone camera video
Definition at line 1064 of file vpRobotBebop2.cpp.
References land(), and vpTime::sleepMs().
void vpRobotBebop2::takeOff | ( | bool | blocking = true | ) |
Sends take off command.
[in] | blocking | : If true, the function returns when take off is achieved. If false, returns immediately. You can check if take off is finished using isHovering(). |
Definition at line 455 of file vpRobotBebop2.cpp.
References isHovering(), isLanded(), isRunning(), and vpTime::sleepMs().