Skip to content
17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a newer Android version you actually have to include the permission for coarse location as well

Copy link
Author

@graiola graiola Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed that in the last commit


<application
android:allowBackup="false"
Expand All @@ -35,6 +37,8 @@
<action android:name="org.ros.android.NodeMainExecutorService" />
</intent-filter>
</service>
</application>


</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.schneewittchen.rosandroid.widgets.location;

import com.schneewittchen.rosandroid.model.repositories.rosRepo.node.BaseData;
import com.schneewittchen.rosandroid.model.entities.widgets.BaseEntity;

import org.ros.internal.message.Message;
import org.ros.node.topic.Publisher;

import sensor_msgs.NavSatFix;


/**
* TODO: Description
*
* @author Gennaro Raiola
* @version 0.0.1
* @created on 19.11.22
*/

public class LocationData extends BaseData {

public double latitude;
public double longitude;
public double altitude;
public String type;

public LocationData(double latitude, double longitude, double altitude, String type) {
this.latitude = latitude;
this.longitude = longitude;
this.altitude = altitude;
this.type = type;
}

@Override
public Message toRosMessage(Publisher<Message> publisher, BaseEntity widget) {

sensor_msgs.NavSatFix message = (NavSatFix) publisher.newMessage();

message.getHeader().setFrameId(type);
message.setLatitude(latitude);
message.setLongitude(longitude);
message.setAltitude(altitude);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider to include the position_covariance as well to enable the user to use this widget in conjunction with fused odometry.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to check how to get these info

return message;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.schneewittchen.rosandroid.widgets.location;

import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;

import com.schneewittchen.rosandroid.R;
import com.schneewittchen.rosandroid.model.entities.widgets.BaseEntity;
import com.schneewittchen.rosandroid.ui.views.details.PublisherWidgetViewHolder;
import com.schneewittchen.rosandroid.utility.Utils;

import java.util.Collections;
import java.util.List;

import sensor_msgs.NavSatFix;

/**
* TODO: Description
*
* @author Gennaro Raiola
* @version 0.0.1
* @created on 19.11.22
*/
public class LocationDetailVH extends PublisherWidgetViewHolder {

private EditText textText;
private Spinner rotationSpinner;
private ArrayAdapter<CharSequence> rotationAdapter;

@Override
public void initView(View view) {
textText = view.findViewById(R.id.btnTextTypeText);
rotationSpinner = view.findViewById(R.id.btnTextRotation);

// Init spinner
rotationAdapter = ArrayAdapter.createFromResource(view.getContext(),
R.array.button_rotation, android.R.layout.simple_spinner_dropdown_item);

rotationSpinner.setAdapter(rotationAdapter);
}

@Override
public void bindEntity(BaseEntity entity) {
LocationEntity locationEntity = (LocationEntity) entity;

textText.setText(locationEntity.text);
String degrees = Utils.numberToDegrees(locationEntity.rotation);
rotationSpinner.setSelection(rotationAdapter.getPosition(degrees));
}

@Override
public void updateEntity(BaseEntity entity) {
LocationEntity locationEntity = (LocationEntity) entity;

locationEntity.text = textText.getText().toString();
String degrees = rotationSpinner.getSelectedItem().toString();
locationEntity.rotation = Utils.degreesToNumber(degrees);
}

@Override
public List<String> getTopicTypes() {
return Collections.singletonList(NavSatFix._TYPE);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.schneewittchen.rosandroid.widgets.location;

import com.schneewittchen.rosandroid.model.entities.widgets.PublisherWidgetEntity;
import com.schneewittchen.rosandroid.model.repositories.rosRepo.message.Topic;

import sensor_msgs.NavSatFix;

/**
* TODO: Description
*
* @author Gennaro Raiola
* @version 0.0.1
* @created on 19.11.22
*/

public class LocationEntity extends PublisherWidgetEntity {

public String text;
public int rotation;
public boolean buttonPressed;

public LocationEntity() {
this.width = 4;
this.height = 4;
this.topic = new Topic("location", NavSatFix._TYPE);
this.immediatePublish = true;
//this.publishRate = 20f;
this.text = "Publish phone's location to ROS";
this.rotation = 0;
this.buttonPressed = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something the user should control via parameters from the config?

Copy link
Author

@graiola graiola Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text and rotation can be changed by the user

}
}
Loading