-
Notifications
You must be signed in to change notification settings - Fork 191
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
Use dynamic reconfigure to set GUI parameters #53
base: indigo-devel
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
<launch> | ||
<arg name="drone_ip" default="127.0.0.1"/> | ||
|
||
<node name="drone_stateestimation" pkg="tum_ardrone" type="drone_stateestimation"> | ||
</node> | ||
<node name="drone_autopilot" pkg="tum_ardrone" type="drone_autopilot"> | ||
</node> | ||
<node name="drone_gui" pkg="tum_ardrone" type="drone_gui"> | ||
<param name="DroneIP" value="$(arg drone_ip)"/> | ||
</node> | ||
</launch> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,10 @@ PingThread::PingThread() | |
{ | ||
line1[0] = '\0'; | ||
line2[0] = '\0'; | ||
keepRunning = true; | ||
keepRunning = true; | ||
started = false; | ||
measure = true; | ||
ip = std::string(""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indent |
||
|
||
p500 = 25; | ||
p20000 = 50; | ||
|
@@ -58,6 +60,18 @@ void PingThread::stopSystem() | |
join(); | ||
} | ||
|
||
void PingThread::setIp(std::string newip) | ||
{ | ||
bool wasRunning = started; | ||
if (wasRunning) | ||
stopSystem(); | ||
|
||
ip = newip; | ||
|
||
if (wasRunning) | ||
startSystem(); | ||
} | ||
|
||
double parsePingResult(std::string s) | ||
{ | ||
// 20008 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.075 ms | ||
|
@@ -76,9 +90,9 @@ double parsePingResult(std::string s) | |
void PingThread::run() | ||
{ | ||
std::cout << "Starting PING Thread" << std::endl; | ||
|
||
sprintf(pingCommand20000,"ping -c 1 -s 20000 -w 1 192.168.1.1"); | ||
sprintf(pingCommand500,"ping -c 1 -s 500 -w 1 192.168.1.1"); | ||
started = true; | ||
sprintf(pingCommand20000,"ping -c 1 -s 20000 -w 1 %s", ip.c_str()); | ||
sprintf(pingCommand500,"ping -c 1 -s 500 -w 1 %s", ip.c_str()); | ||
ros::Rate r(2.0); | ||
FILE *p; | ||
|
||
|
@@ -113,8 +127,8 @@ void PingThread::run() | |
std::cout << "new ping values: 500->" << res500 << " 20000->" << res20000 << std::endl; | ||
|
||
// clip between 10 and 1000. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adapt comment |
||
res500 = std::min(1000.0,std::max(10.0,res500)); | ||
res20000 = std::min(1000.0,std::max(10.0,res20000)); | ||
res500 = std::min(1000.0,std::max(1.0,res500)); | ||
res20000 = std::min(1000.0,std::max(1.0,res20000)); | ||
|
||
// update | ||
p500 = 0.7 * p500 + 0.3 * res500; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,11 @@ | |
*/ | ||
#ifndef __PINGTHREAD_H | ||
#define __PINGTHREAD_H | ||
|
||
|
||
#include "cvd/thread.h" | ||
|
||
|
||
#include "cvd/thread.h" | ||
#include <string> | ||
|
||
|
||
class tum_ardrone_gui; | ||
class RosThread; | ||
|
@@ -36,13 +38,14 @@ class PingThread : private CVD::Thread | |
|
||
// keep Running | ||
bool keepRunning; | ||
|
||
bool started; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indent |
||
|
||
// buffers | ||
char pingCommand500[100]; | ||
char pingCommand20000[100]; | ||
char line1[200]; | ||
char line2[200]; | ||
char line2[200]; | ||
std::string ip; | ||
|
||
|
||
// running averages | ||
|
@@ -58,7 +61,9 @@ class PingThread : private CVD::Thread | |
// start and stop system and respective thread. | ||
// to be called externally | ||
void startSystem(); | ||
void stopSystem(); | ||
void stopSystem(); | ||
|
||
void setIp(std::string); | ||
|
||
// start and stop pinging | ||
void setEnabled(bool); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use spaces instead of tabs