Skip to content
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
2 changes: 1 addition & 1 deletion src/example_robot_brain/launch/task_mapping.launch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<include file="$(find example_robot_description)/launch/spawn_example_robot.launch"/>

<!-- Spawn your custom robot using the generated robot spawner -->
<include file="$(find virtual_maize_field)/launch/robot_spawner.launch">
<include file="$(eval optenv('ROS_HOME', env('HOME')+'/.ros')+'/virtual_maize_field/robot_spawner.launch')">
<arg name="robot_name" value="example_robot"/>
</include>

Expand Down
1 change: 1 addition & 0 deletions src/example_robot_brain/scripts/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
]
i = 0


# Does not actually detect anything, just returns hardcoded locations
def detect():
global i
Expand Down
1 change: 0 additions & 1 deletion src/example_robot_brain/scripts/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ def drive(duration=10):
msg.linear.x = 1
pub.publish(msg)
rate.sleep()

12 changes: 5 additions & 7 deletions src/example_robot_brain/scripts/task_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
import csv

import rospy
import rospkg

from navigation import drive
from detection import detect

from std_msgs.msg import String

from virtual_maize_field import get_markers_file


if __name__ == "__main__":
rospy.init_node("task_mapping_node")

pkg_path = rospkg.RosPack().get_path("virtual_maize_field")

# Read the relative position of the pillars
markers_path = os.path.join(pkg_path, "map/markers.csv")
with open(markers_path, "r") as f:
with open(get_markers_file(), "r") as f:
reader = csv.reader(f)

# Skip header
Expand All @@ -34,7 +32,7 @@

# Create path to file where we have to save the predicted coordinates of the
# litter and weeds
out_map_path = os.path.join(pkg_path, "map/pred_map.csv")
out_map_path = os.path.join(os.path.expanduser("~"), "pred_map.csv")

try:
# Open output file
Expand Down Expand Up @@ -63,7 +61,7 @@

# Write found position to file
writer.writerow([obj_position[0], obj_position[1], obj_type])

rospy.loginfo("Done driving")

except rospy.ROSInterruptException:
Expand Down
16 changes: 7 additions & 9 deletions src/example_robot_brain/scripts/task_navigation.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
#!/usr/bin/env python3
import os
import rospkg

import rospy

from navigation import drive

from virtual_maize_field import get_driving_pattern_file


if __name__ == "__main__":
rospy.init_node("task_navigation_node")

# Read the driving directions from the file
pkg_path = rospkg.RosPack().get_path("virtual_maize_field")
dp_path = os.path.join(pkg_path, "map/driving_pattern.txt")

with open(dp_path) as direction_f:
with open(get_driving_pattern_file()) as direction_f:
directions = direction_f.readline()

rospy.loginfo(f"Driving directions are: {directions}")

try:
# Drive
rospy.loginfo("Starting to drive")

drive()

rospy.loginfo("Done driving")
except rospy.ROSInterruptException:
pass