-
Notifications
You must be signed in to change notification settings - Fork 159
Location: a widget to publish phone's location to ROS #99
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
base: master
Are you sure you want to change the base?
Changes from 11 commits
ce9364f
5a1e2af
94b3cbb
f06ce79
45e4eec
353be36
5c9f717
d0788e6
5fa446c
226a011
1c1f344
807ba0d
70b03ea
de02273
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
| 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); | ||
|
|
||
|
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. Consider to include the position_covariance as well to enable the user to use this widget in conjunction with fused odometry. 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. 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; | ||
|
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. Is this something the user should control via parameters from the config? 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. Text and rotation can be changed by the user |
||
| } | ||
| } | ||
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.
With a newer Android version you actually have to include the permission for coarse location as well
Uh oh!
There was an error while loading. Please reload this page.
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.
I fixed that in the last commit