Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implementation of sendPilotingMoveBy method #189

Open
wants to merge 1 commit into
base: indigo-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bebop_driver/include/bebop_driver/bebop.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class Bebop
void PauseAutonomousFlight();
void StopAutonomousFlight();
void AnimationFlip(const uint8_t& anim_id);
void GoTo(const double& dx,const double& dy, const double& dz, const double& dpsi);

// -1..1
void Move(const double& roll, const double& pitch, const double& gaz_speed, const double& yaw_speed);
Expand Down
3 changes: 3 additions & 0 deletions bebop_driver/include/bebop_driver/bebop_driver_nodelet.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ class BebopDriverNodelet : public nodelet::Nodelet
ros::Publisher camera_joint_pub_;
ros::Publisher gps_fix_pub_;

ros::Subscriber goto_sub_;

boost::shared_ptr<camera_info_manager::CameraInfoManager> cinfo_manager_ptr_;
boost::shared_ptr<image_transport::ImageTransport> image_transport_ptr_;
image_transport::CameraPublisher image_transport_pub_;
Expand Down Expand Up @@ -164,6 +166,7 @@ class BebopDriverNodelet : public nodelet::Nodelet
void TakeSnapshotCallback(const std_msgs::EmptyConstPtr& empty_ptr);
void SetExposureCallback(const std_msgs::Float32ConstPtr& exposure_ptr);
void ToggleRecordingCallback(const std_msgs::BoolConstPtr& toggle_ptr);
void GotoCallBack(const geometry_msgs::TwistConstPtr& twist_ptr);

void ParamCallback(bebop_driver::BebopArdrone3Config &config, uint32_t level);

Expand Down
7 changes: 7 additions & 0 deletions bebop_driver/src/bebop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,13 @@ void Bebop::StopAutonomousFlight()
"Stop autonomous flight failed");
}

void Bebop::GoTo(const double &dx,const double &dy, const double &dz, const double &dpsi){
ThrowOnInternalError("Navigate Go to failed");
ThrowOnCtrlError(
device_controller_ptr_->aRDrone3->sendPilotingMoveBy( device_controller_ptr_->aRDrone3, dx,dy,dz,dpsi),
"Navigate Go to failed");
}

void Bebop::AnimationFlip(const uint8_t &anim_id)
{
ThrowOnInternalError("Animation failed");
Expand Down
17 changes: 17 additions & 0 deletions bebop_driver/src/bebop_driver_nodelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ void BebopDriverNodelet::onInit()
snapshot_sub_ = nh.subscribe("snapshot", 10, &BebopDriverNodelet::TakeSnapshotCallback, this);
exposure_sub_ = nh.subscribe("set_exposure", 10, &BebopDriverNodelet::SetExposureCallback, this);
toggle_recording_sub_ = nh.subscribe("record", 10, &BebopDriverNodelet::ToggleRecordingCallback, this);
goto_sub_ = nh.subscribe("goto", 1, &BebopDriverNodelet::GotoCallBack, this);

odom_pub_ = nh.advertise<nav_msgs::Odometry>("odom", 30);
camera_joint_pub_ = nh.advertise<sensor_msgs::JointState>("joint_states", 10, true);
Expand Down Expand Up @@ -688,4 +689,20 @@ void BebopDriverNodelet::AuxThread()
}
}

void BebopDriverNodelet::GotoCallBack(const geometry_msgs::TwistConstPtr& twist_ptr)
{
try
{
const double dx = twist_ptr->linear.x; //displacement along the front axis
const double dy = twist_ptr->linear.y; //displacement along the right axis
const double dz = twist_ptr->linear.z; //displacement along the down axis
const double dpsi = twist_ptr->angular.z; // rotation of heading
bebop_ptr_->GoTo(dx,dy,dz,dpsi);
}
catch (const std::runtime_error& e)
{
ROS_ERROR_STREAM("[Goto] " << e.what());
}
}

} // namespace bebop_driver