How can I send MAVLink commands directly using Dronkit-Android? - dronekit

I am trying to have it go on a mission by only setting to auto. After some research it cannot perform the takeoff on the mission as it requires initiate throttle to begin that. With more research to by pass this I can use MAV_CMD_MISSION_START. Only issue is I have been searching the docs and I can't find anything that has it send a MavLink Message. The docs has something like this, but I have no clue how to use it properly and there is little example or documentation on how to use it.
Was hoping if there was some simple command to send commands to the drone?
Hopefully, someone has some experience in this.

This command isn't supported by the current version of APM:Copter (v3.2). It is only supported in 3.3 (which is in beta as of July '15). That's why this command isn't in Dronekit-Android yet. But it will be supported by Dronekit-Android in about a week. You will call it like this:
MissionApi.getApi(drone).startMission(true, true, new AbstractCommandListener() {
#Override
public void onSuccess() {
Toast.makeText(getContext(), "success", Toast.LENGTH_LONG).show();
}
#Override
public void onError(int i) {
Toast.makeText(getContext(), "failcode: " + i, Toast.LENGTH_LONG).show();
}
#Override
public void onTimeout() {
Toast.makeText(getContext(), "timeout", Toast.LENGTH_LONG).show();
}
});

To accomplish your task, you can issue a takeoff command to the drone as shown in this guide.
After the takeoff command is issued, you can switch the flight mode to auto to start the mission, using the Drone#changeVehicleMode(...) method.

Related

“The page has expired due to inactivity” appears when using a services methods - Laravel 5.5

According to other asked questions like this one, I did many doings to prevent this request expired message but there is no solution for my issue.
In the long run I recognized that the message appears when I call a service method inside a controller which run on form action!
Here is my codes samples with some descriptions:
My route:
Route::post('Material/{id}', 'MaterialController#updateMaterial')->name('updateMaterial');
Material Controller Constructor:
public function __construct(CustomService $srv)
{
$this->middleware('admin')->only(['updateMaterial']);
$this->srv= $srv;
}
srv is a protected attribute in MaterialController class.
updateMaterial Method:
public function updateMaterial($id,Request $request)
{
$this->validate($request, [...]);
$material = $this->srv->updateMaterial($request, $id);
if ($material)
return view('panel._materials.edit-material')
->with('material', $material)
->with('success', 1);
}
I also have a provider for CustomService with name CustomServiceProvider and here is the register method of the provider:
public function register()
{
$this->app->bind(CustomService::class,function($app){
return new CustomService();
});
}
and I registered it as a provider in config/app.php.
So when I return something before calling service updateMaterial method, it's OK. but when the method runs, the issue appears!
I don'n have any idea about!
Update:
And here is updateMaterial of CustomService:
public function updateMaterial($request, $id)
{
$material = Material::find($id);
if (!$material)
return false;
if ($request->has('unit'))
$material->unit = $request['unit'];
if ($request->has('price'))
$material->price = $request['price'];
if ($request->has('type'))
$material->type = $request['type'];
if ($request->has('is_active'))
$material->is_active = $request['is_active'];
$material->updated_at = Carbon::now();
$material->save();
return $material;
}
I also create a new project with Laravel 5.5.0 and without adding any complexity I just added a post route and call it in form action, but nothing changed!
This is just an issue for Windows users on Local Environment. I suffered a lot with this also when on Windows. Once you deploy to your production server, you won't have any issue at all.
It's important to note that this is not an issue with Laravel 5.5 version only. I first saw this issue in version 5.2.
I think a good fix for this would maybe be using something like Homestead or Vessel from Fideloper. Honestly I only suffered this problem when using Windows.

Can I force a Cassandra table flush from the C/C++ driver like nodetool does?

I'm wondering whether I could replicate the forceKeyspaceFlush() function found in the nodetool utility from the C/C++ driver of Cassandra.
The nodetool function looks like this:
public class Flush extends NodeToolCmd
{
#Arguments(usage = "[<keyspace> <tables>...]", description = "The keyspace followed by one or many tables")
private List<String> args = new ArrayList<>();
#Override
public void execute(NodeProbe probe)
{
List<String> keyspaces = parseOptionalKeyspace(args, probe);
String[] tableNames = parseOptionalTables(args);
for (String keyspace : keyspaces)
{
try
{
probe.forceKeyspaceFlush(keyspace, tableNames);
} catch (Exception e)
{
throw new RuntimeException("Error occurred during flushing", e);
}
}
}
}
What I would like to replicate in my C++ software is this line:
probe.forceKeyspaceFlush(keyspace, tableNames);
Is it possible?
That's an unusual request, primarily because Cassandra is designed to be distributed, so if you're executing a query, you'd need to perform that blocking flush on each of the (potentially many) replicas. Rather than convince you that you don't really need this, I'll attempt to answer your question - however, you probably don't really need this.
Nodetool is using the JMX interface (on tcp/7199) to force that flush - Your c/c++ driver talks over the native protocol (on tcp/9042). At this time, flush is not possible via the native protocol.
Work around the limitation, you'd need to either exec a jmx-capable commandline utility (nodetool or other), implement a JMX client in c++ (it's been done), or extend the native protocol. None of those are particularly pleasant options, but I imagine executing a jmx CLI utility is significantly easier than the other two.

How to properly use Google API Client on Glass XE22

I'm currently trying to use the following code to create an ApiClient connection
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
mGoogleApiClient.connect();
but in
#Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.d(TAG, "Connection failed");
mGoogleApiClient.reconnect();
}
I'm getting this:
ConnectionResult{statusCode=SERVICE_INVALID, resolution=null}
If I'm reading correctly in the manual, this corresponds to the version of Play being wrong to begin with.
As such, am I missing something from properly connecting running the code on Glass or this is not supported yet?
To give you a rough idea of what I want to do, I want to implement this example.
Google Play Services is not supported on Glass at this time. This is currently being tracked as issue 176 in our issue tracker, so you can follow that for more info in the future.

AWS SWF createTimer promise not returning

I want a loop that after each iteration waits for a while. I'm trying to use a timer to do the waiting, but the timer never returns, so the below code only runs once and then waits forever. When I remove the timer condition, the code executes successfully. There are no errors, it just waits...
Any help is appreciated!
#override
public void doWorkflow() {
validate("test", 1);
}
#Asynchronous
private void validate(String id, int retries, Promise<?>... waitFor) {
Promise<Boolean> isValid = activityClient.validate(id);
doWork(id, retries, isValid);
}
#Asynchronous
private void doWork(String id, int retries, Promise<Boolean> isValid) {
if (!isValid.get()) {
return;
}
Promise<Void> waitFor = decisionContext.getWorkflowClock().createTimer(5);
validate(id, retries - 1, waitFor);
}
I was using Spring to set up the application. To get the decision context I was using
#Autowired
DecisionContext decisionContext
The problem is when constructing the Workflow implementation I didn't use a scope. The solution was to add the scope="workflow" attribute:
<bean id="myWorkflow" class="com.example.myWorkflowImpl" scope="workflow">
After doing this, the workflow history began showing the TimerStarted event.
I don't see any obvious problems with your code. First I would look at the workflow history (either through console or by printing it using WorkflowExecutionHistoryPrinter) to see if timer is scheduled and if it ever fires. If the history looks OK I would get "asynchronous thread dump" using WorkflowExecutionFlowThreadDumper to see what exactly your code waits for.

Ratchet WAMP $topic error:Call to a member function broadcast() on a non-object

The title says it all.Here's my code:
(Shell script)
$loop = React\EventLoop\Factory::create();
$pusher = new MyApp\Chat;
//Receiving IPC messages:
$socket = new React\Socket\Server($loop);
$socket->on('connection', function ($conn) {
$pusher = new MyApp\Chat;
echo date('H:i:s'). "!!IPC Connection opened!!\n";
$conn->on('data', array($pusher, 'onUpdate'));
});
$socket->listen(1337, '127.0.0.1'); //Binding to our IP so remotes can't connect.
echo "%%% IPC listener started succesfully. %%%\n%%%\n";
// WebSocket server:
//here the code is identical to that on the Ratchet 'push-server' tutorial
...and the "onUpdate" function...
public function onUpdate($entry)
{
echo(date('H:i:s'). ": !<<---IPC Data Received.DATA:::". $entry. ":::--->>!\n");
$topic = 'Prime_mover';
$topic->broadcast($entry);
}
...the "onPublish" function:
public function onPublish(Conn $conn, $topic, $event, array $exclude, array $eligible )
{
echo $topic. "\n";
//echo implode(array_keys($topic)). "\n";
$channel = $topic->getId();
if($topic->broadcast($event))
{
echo(date('H:i:s') . ": ***A client has published ###" .
implode('', $event) . "### to (((". $channel. ")))***\n");
} else {
echo(date('H:i:s'). ": !!<--An error occured during publish-->!!\n");
}
}
The client code is trivial.
I am sure the bug, if any (I've been at this for about 10 hours), does not reside there.
I confirm via the console that indeed the browser is subscribed to "Prime_mover". This also shows up on the CLI. In addition, I have put a button that publishes to this channel, via the "onPublish" function. This works.
As can be seen above, I am not using ZeroiMQ for IPC because I am developing on a windows machine, on PHP 5. AFAIK, there exists no working ZeroMQ bindings for PHP5.
I resorted to using bare sockets. They work just as beautifully, and I can see on the CLI that the messages do get to this particular script.
The "onUpdate" function does get called, confirmed, again, via the CLI.
I had previously tried using the URL "http:\example.com\Prime_mover", when it did not work, out of desperation, I tried the string "Prime_mover". You're probably shaking your head right now-I know, does't work that way.
I have tried to use $topica as an array too, does not work.I guess the most important question here is, what kind of object is $topic, why won't a simple string work in it's place?Am I missing something here?How is it "constructed" correctly?
$topic = 'Prime_mover';
$topic->broadcast($entry);
$topic is a string! And it doesn't have any methods.