Restructure codebase
This commit is contained in:
@@ -76,7 +76,9 @@ GUI_ENVS=(
|
|||||||
CUSTOM_VOLUMES+=("/etc/localtime:/etc/localtime:ro")
|
CUSTOM_VOLUMES+=("/etc/localtime:/etc/localtime:ro")
|
||||||
|
|
||||||
# Pass USB devices to container
|
# Pass USB devices to container
|
||||||
USB_VOLUME+=("/dev/bus/usb:/dev/bus/usb")
|
#USB_VOLUME+=("/dev/bus/usb:/dev/bus/usb")
|
||||||
|
DEVICE_VOLUME+=("/dev:/dev:rw")
|
||||||
|
#USB_SERIAL+=("/dev/ttyACM0:/dev/ttyACM0")
|
||||||
|
|
||||||
## Additional environment variables
|
## Additional environment variables
|
||||||
# Synchronize ROS_DOMAIN_ID with host
|
# Synchronize ROS_DOMAIN_ID with host
|
||||||
@@ -114,7 +116,9 @@ DOCKER_RUN_CMD=(
|
|||||||
"${GPU_OPT}"
|
"${GPU_OPT}"
|
||||||
"${GPU_ENVS[@]/#/"--env "}"
|
"${GPU_ENVS[@]/#/"--env "}"
|
||||||
"${CUSTOM_VOLUMES[@]/#/"--volume "}"
|
"${CUSTOM_VOLUMES[@]/#/"--volume "}"
|
||||||
"${USB_VOLUME[@]/#/"--volume "}"
|
"${DEVICE_VOLUME[@]/#/"--volume "}"
|
||||||
|
#"${USB_VOLUME[@]/#/"--volume "}"
|
||||||
|
#"${USB_SERIAL[@]/#/"--volume "}"
|
||||||
"${CUSTOM_ENVS[@]/#/"--env "}"
|
"${CUSTOM_ENVS[@]/#/"--env "}"
|
||||||
"${TAG}"
|
"${TAG}"
|
||||||
"${CMD}"
|
"${CMD}"
|
||||||
|
|||||||
16
README.md
16
README.md
@@ -12,3 +12,19 @@ ros2 launch draw_svg draw_svg.launch.py
|
|||||||
|
|
||||||
## xArm lite6
|
## xArm lite6
|
||||||
- web interface: http://192.168.1.150:18333
|
- web interface: http://192.168.1.150:18333
|
||||||
|
## ROS2 rpi4
|
||||||
|
https://github.com/ros-realtime/ros-realtime-rpi4-image/releases
|
||||||
|
|
||||||
|
After unpacking the tar file, flash it to sd card.
|
||||||
|
Log in with "ubuntu:ubuntu".
|
||||||
|
|
||||||
|
``` sh
|
||||||
|
sudo -i
|
||||||
|
loadkeys fi
|
||||||
|
passwd ubuntu #change from default 'ubuntu' to '1234'
|
||||||
|
apt-mark hold $(uname -r) linux-firmware u-boot-rpi u-boot-tools #prevent kernel updates
|
||||||
|
apt-mark hold libraspberrypi-bin libraspberrypi-dev libraspberrypi-doc libraspberrypi0
|
||||||
|
apt-mark hold raspberrypi-bootloader raspberrypi-kernel raspberrypi-kernel-headers
|
||||||
|
|
||||||
|
apt update && apt upgrade
|
||||||
|
```
|
||||||
|
|||||||
25
src/axidraw_controller/CMakeLists.txt
Normal file
25
src/axidraw_controller/CMakeLists.txt
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
project(axidraw_controller)
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# find dependencies
|
||||||
|
find_package(ament_cmake REQUIRED)
|
||||||
|
# uncomment the following section in order to fill in
|
||||||
|
# further dependencies manually.
|
||||||
|
# find_package(<dependency> REQUIRED)
|
||||||
|
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
find_package(ament_lint_auto REQUIRED)
|
||||||
|
# the following line skips the linter which checks for copyrights
|
||||||
|
# uncomment the line when a copyright and license is not present in all source files
|
||||||
|
#set(ament_cmake_copyright_FOUND TRUE)
|
||||||
|
# the following line skips cpplint (only works in a git repo)
|
||||||
|
# uncomment the line when this package is not in a git repo
|
||||||
|
#set(ament_cmake_cpplint_FOUND TRUE)
|
||||||
|
ament_lint_auto_find_test_dependencies()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
ament_package()
|
||||||
18
src/axidraw_controller/package.xml
Normal file
18
src/axidraw_controller/package.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<package format="3">
|
||||||
|
<name>axidraw_controller</name>
|
||||||
|
<version>0.0.0</version>
|
||||||
|
<description>TODO: Package description</description>
|
||||||
|
<maintainer email="root@todo.todo">root</maintainer>
|
||||||
|
<license>TODO: License declaration</license>
|
||||||
|
|
||||||
|
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||||
|
|
||||||
|
<test_depend>ament_lint_auto</test_depend>
|
||||||
|
<test_depend>ament_lint_common</test_depend>
|
||||||
|
|
||||||
|
<export>
|
||||||
|
<build_type>ament_cmake</build_type>
|
||||||
|
</export>
|
||||||
|
</package>
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
from pyaxidraw import axidraw # import module
|
from pyaxidraw import axidraw # import module
|
||||||
ad = axidraw.AxiDraw() # Initialize class
|
ad = axidraw.AxiDraw() # Initialize class
|
||||||
ad.interactive() # Enter interactive context
|
ad.interactive() # Enter interactive context
|
||||||
|
ad.options.port = "/dev/ttyAXI"
|
||||||
if not ad.connect(): # Open serial port to AxiDraw;
|
if not ad.connect(): # Open serial port to AxiDraw;
|
||||||
quit() # Exit, if no connection.
|
quit() # Exit, if no connection.
|
||||||
ad.options.units = 1 # set working units to cm.
|
ad.options.units = 1 # set working units to cm.
|
||||||
@@ -55,7 +55,7 @@ class PublishTarget(Node):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__('publisher')
|
super().__init__('publisher')
|
||||||
self.publisher_ = self.create_publisher(PoseStamped, '/target_pose', 10)
|
self.publisher_ = self.create_publisher(PoseStamped, '/target_pose', 10)
|
||||||
timer_period = 7.0 # seconds
|
timer_period = 4.0 # seconds
|
||||||
self.timer = self.create_timer(timer_period, self.timer_callback)
|
self.timer = self.create_timer(timer_period, self.timer_callback)
|
||||||
self.i = 0
|
self.i = 0
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ class PublishTarget(Node):
|
|||||||
#print(p.orientation)
|
#print(p.orientation)
|
||||||
xml = ET.parse('svg/test.svg')
|
xml = ET.parse('svg/test.svg')
|
||||||
svg = xml.getroot()
|
svg = xml.getroot()
|
||||||
self.map_point = map_point_function(float(svg.get('width')), float(svg.get('height')), 0.1, 0.5, -0.2, 0.2)
|
self.map_point = map_point_function(float(svg.get('width')), float(svg.get('height')), 0.2, 0.4, -0.1, 0.1)
|
||||||
self.points = []
|
self.points = []
|
||||||
for child in svg:
|
for child in svg:
|
||||||
if (child.tag == 'line'):
|
if (child.tag == 'line'):
|
||||||
|
|||||||
25
src/drawing_controller/CMakeLists.txt
Normal file
25
src/drawing_controller/CMakeLists.txt
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
project(drawing_controller)
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# find dependencies
|
||||||
|
find_package(ament_cmake REQUIRED)
|
||||||
|
# uncomment the following section in order to fill in
|
||||||
|
# further dependencies manually.
|
||||||
|
# find_package(<dependency> REQUIRED)
|
||||||
|
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
find_package(ament_lint_auto REQUIRED)
|
||||||
|
# the following line skips the linter which checks for copyrights
|
||||||
|
# uncomment the line when a copyright and license is not present in all source files
|
||||||
|
#set(ament_cmake_copyright_FOUND TRUE)
|
||||||
|
# the following line skips cpplint (only works in a git repo)
|
||||||
|
# uncomment the line when this package is not in a git repo
|
||||||
|
#set(ament_cmake_cpplint_FOUND TRUE)
|
||||||
|
ament_lint_auto_find_test_dependencies()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
ament_package()
|
||||||
18
src/drawing_controller/package.xml
Normal file
18
src/drawing_controller/package.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<package format="3">
|
||||||
|
<name>drawing_controller</name>
|
||||||
|
<version>0.0.0</version>
|
||||||
|
<description>TODO: Package description</description>
|
||||||
|
<maintainer email="root@todo.todo">root</maintainer>
|
||||||
|
<license>TODO: License declaration</license>
|
||||||
|
|
||||||
|
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||||
|
|
||||||
|
<test_depend>ament_lint_auto</test_depend>
|
||||||
|
<test_depend>ament_lint_common</test_depend>
|
||||||
|
|
||||||
|
<export>
|
||||||
|
<build_type>ament_cmake</build_type>
|
||||||
|
</export>
|
||||||
|
</package>
|
||||||
110
src/drawing_controller/src/drawing_controller.py
Normal file
110
src/drawing_controller/src/drawing_controller.py
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Sends motions individually to robot_controller"""
|
||||||
|
|
||||||
|
import rclpy
|
||||||
|
from geometry_msgs.msg import Pose, PoseStamped
|
||||||
|
from rclpy.callback_groups import ReentrantCallbackGroup
|
||||||
|
from rclpy.node import Node
|
||||||
|
from rclpy.qos import QoSProfile
|
||||||
|
from random import uniform as rand
|
||||||
|
import math
|
||||||
|
#from tf2_ros.transformations import quaternion_from_euler
|
||||||
|
import lxml.etree as ET
|
||||||
|
|
||||||
|
|
||||||
|
def quaternion_from_euler(ai, aj, ak):
|
||||||
|
ai /= 2.0
|
||||||
|
aj /= 2.0
|
||||||
|
ak /= 2.0
|
||||||
|
ci = math.cos(ai)
|
||||||
|
si = math.sin(ai)
|
||||||
|
cj = math.cos(aj)
|
||||||
|
sj = math.sin(aj)
|
||||||
|
ck = math.cos(ak)
|
||||||
|
sk = math.sin(ak)
|
||||||
|
cc = ci*ck
|
||||||
|
cs = ci*sk
|
||||||
|
sc = si*ck
|
||||||
|
ss = si*sk
|
||||||
|
|
||||||
|
q = [0,0,0,0]
|
||||||
|
q[0] = cj*sc - sj*cs
|
||||||
|
q[1] = cj*ss + sj*cc
|
||||||
|
q[2] = cj*cs - sj*sc
|
||||||
|
q[3] = cj*cc + sj*ss
|
||||||
|
|
||||||
|
return q
|
||||||
|
|
||||||
|
def translate(val, lmin, lmax, rmin, rmax):
|
||||||
|
lspan = lmax - lmin
|
||||||
|
rspan = rmax - rmin
|
||||||
|
val = float(val - lmin) / float(lspan)
|
||||||
|
return rmin + (val * rspan)
|
||||||
|
|
||||||
|
def map_point_function(x_pixels, y_pixels, xlim_lower, xlim_upper, ylim_lower, ylim_upper):
|
||||||
|
def map_point(xpix,ypix):
|
||||||
|
x = translate(xpix, 0, x_pixels, xlim_lower, xlim_upper)
|
||||||
|
y = translate(ypix, 0, y_pixels, ylim_lower, ylim_upper)
|
||||||
|
return (x,y)
|
||||||
|
return map_point
|
||||||
|
|
||||||
|
|
||||||
|
class DrawingController(Node):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__('drawing_controller')
|
||||||
|
self.publisher_ = self.create_publisher(PoseStamped, '/target_pose', 10)
|
||||||
|
timer_period = 7.0 # seconds
|
||||||
|
self.timer = self.create_timer(timer_period, self.timer_callback)
|
||||||
|
self.i = 0
|
||||||
|
|
||||||
|
# TODO get dimensions from svg
|
||||||
|
|
||||||
|
#print(p)
|
||||||
|
#print(p.position)
|
||||||
|
#print(p.orientation)
|
||||||
|
xml = ET.parse('svg/test.svg')
|
||||||
|
svg = xml.getroot()
|
||||||
|
self.map_point = map_point_function(float(svg.get('width')), float(svg.get('height')), 0.1, 0.5, -0.2, 0.2)
|
||||||
|
self.points = []
|
||||||
|
for child in svg:
|
||||||
|
if (child.tag == 'line'):
|
||||||
|
self.points.append((float(child.get('x1')), float(child.get('y1'))))
|
||||||
|
self.points.append((float(child.get('x2')), float(child.get('y2'))))
|
||||||
|
|
||||||
|
|
||||||
|
def timer_callback(self):
|
||||||
|
next_point = self.points[self.i]
|
||||||
|
point = self.map_point(float(next_point[0]),float(next_point[1]))
|
||||||
|
p = Pose()
|
||||||
|
p.position.x = point[0]
|
||||||
|
p.position.y = point[1]
|
||||||
|
p.position.z = 0.1
|
||||||
|
q = quaternion_from_euler(0.0, math.pi, 0.0)
|
||||||
|
#p.orientation = q
|
||||||
|
p.orientation.x = q[0]
|
||||||
|
p.orientation.y = q[1]
|
||||||
|
p.orientation.z = q[2]
|
||||||
|
p.orientation.w = q[3]
|
||||||
|
ps = PoseStamped()
|
||||||
|
ps.pose = p
|
||||||
|
#print(ps)
|
||||||
|
self.publisher_.publish(ps)
|
||||||
|
self.get_logger().info('Publishing to /target_pose: "%s"' % p)
|
||||||
|
self.i = (self.i + 1) % len(self.points)
|
||||||
|
|
||||||
|
def main(args=None):
|
||||||
|
rclpy.init(args=args)
|
||||||
|
|
||||||
|
publisher = PublishTarget()
|
||||||
|
|
||||||
|
rclpy.spin(publisher)
|
||||||
|
|
||||||
|
# Destroy the node explicitly
|
||||||
|
# (optional - otherwise it will be done automatically
|
||||||
|
# when the garbage collector destroys the node object)
|
||||||
|
publisher.destroy_node()
|
||||||
|
rclpy.shutdown()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
25
src/lite6_controller/CMakeLists.txt
Normal file
25
src/lite6_controller/CMakeLists.txt
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
project(lite6_controller)
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# find dependencies
|
||||||
|
find_package(ament_cmake REQUIRED)
|
||||||
|
# uncomment the following section in order to fill in
|
||||||
|
# further dependencies manually.
|
||||||
|
# find_package(<dependency> REQUIRED)
|
||||||
|
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
find_package(ament_lint_auto REQUIRED)
|
||||||
|
# the following line skips the linter which checks for copyrights
|
||||||
|
# uncomment the line when a copyright and license is not present in all source files
|
||||||
|
#set(ament_cmake_copyright_FOUND TRUE)
|
||||||
|
# the following line skips cpplint (only works in a git repo)
|
||||||
|
# uncomment the line when this package is not in a git repo
|
||||||
|
#set(ament_cmake_cpplint_FOUND TRUE)
|
||||||
|
ament_lint_auto_find_test_dependencies()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
ament_package()
|
||||||
18
src/lite6_controller/package.xml
Normal file
18
src/lite6_controller/package.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<package format="3">
|
||||||
|
<name>lite6_controller</name>
|
||||||
|
<version>0.0.0</version>
|
||||||
|
<description>TODO: Package description</description>
|
||||||
|
<maintainer email="root@todo.todo">root</maintainer>
|
||||||
|
<license>TODO: License declaration</license>
|
||||||
|
|
||||||
|
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||||
|
|
||||||
|
<test_depend>ament_lint_auto</test_depend>
|
||||||
|
<test_depend>ament_lint_common</test_depend>
|
||||||
|
|
||||||
|
<export>
|
||||||
|
<build_type>ament_cmake</build_type>
|
||||||
|
</export>
|
||||||
|
</package>
|
||||||
37
src/robot_controller/CMakeLists.txt
Normal file
37
src/robot_controller/CMakeLists.txt
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
project(robot_controller)
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# find dependencies
|
||||||
|
find_package(ament_cmake REQUIRED)
|
||||||
|
# uncomment the following section in order to fill in
|
||||||
|
# further dependencies manually.
|
||||||
|
# find_package(<dependency> REQUIRED)
|
||||||
|
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
find_package(ament_lint_auto REQUIRED)
|
||||||
|
# the following line skips the linter which checks for copyrights
|
||||||
|
# uncomment the line when a copyright and license is not present in all source files
|
||||||
|
#set(ament_cmake_copyright_FOUND TRUE)
|
||||||
|
# the following line skips cpplint (only works in a git repo)
|
||||||
|
# uncomment the line when this package is not in a git repo
|
||||||
|
#set(ament_cmake_cpplint_FOUND TRUE)
|
||||||
|
ament_lint_auto_find_test_dependencies()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(ament_cmake REQUIRED)
|
||||||
|
find_package(rclcpp REQUIRED)
|
||||||
|
find_package(robot_interfaces REQUIRED)
|
||||||
|
|
||||||
|
#add_executable(robotcontroller src/robotcontroller.cpp)
|
||||||
|
#ament_target_dependencies(robotcontroller rclcpp robot_interfaces)
|
||||||
|
|
||||||
|
install(TARGETS
|
||||||
|
talker
|
||||||
|
listener
|
||||||
|
DESTINATION lib/${PROJECT_NAME})
|
||||||
|
|
||||||
|
ament_package()
|
||||||
18
src/robot_controller/package.xml
Normal file
18
src/robot_controller/package.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<package format="3">
|
||||||
|
<name>robot_controller</name>
|
||||||
|
<version>0.0.0</version>
|
||||||
|
<description>TODO: Package description</description>
|
||||||
|
<maintainer email="root@todo.todo">root</maintainer>
|
||||||
|
<license>TODO: License declaration</license>
|
||||||
|
|
||||||
|
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||||
|
|
||||||
|
<test_depend>ament_lint_auto</test_depend>
|
||||||
|
<test_depend>ament_lint_common</test_depend>
|
||||||
|
|
||||||
|
<export>
|
||||||
|
<build_type>ament_cmake</build_type>
|
||||||
|
</export>
|
||||||
|
</package>
|
||||||
41
src/robot_controller/src/robotcontroller.cpp
Normal file
41
src/robot_controller/src/robotcontroller.cpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#include <cstdio>
|
||||||
|
#include <rclcpp/rclcpp.hpp>
|
||||||
|
|
||||||
|
class RobotController : public rclcpp::Node
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// Constructor
|
||||||
|
RobotController();
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Callback that executes path on robot
|
||||||
|
virtual void add(const std::shared_ptr<robot_interfaces::srv::AddThreeInts::Request> request,
|
||||||
|
std::shared_ptr<robot_interfaces::srv::AddThreeInts::Response> response);
|
||||||
|
};
|
||||||
|
|
||||||
|
RobotController::RobotController(string name) : Node(name)
|
||||||
|
{
|
||||||
|
// Subscribe to target pose
|
||||||
|
target_pose_sub_ = this->create_subscription<geometry_msgs::msg::PoseStamped>("/target_pose", rclcpp::QoS(1), std::bind(&MoveItFollowTarget::target_pose_callback, this, std::placeholders::_1));
|
||||||
|
|
||||||
|
RCLCPP_INFO(this->get_logger(), "Initialization successful.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char ** argv)
|
||||||
|
{
|
||||||
|
//rclcpp::init(argc, argv);
|
||||||
|
|
||||||
|
//auto target_follower = std::make_shared<MoveItFollowTarget>();
|
||||||
|
|
||||||
|
//rclcpp::executors::SingleThreadedExecutor executor;
|
||||||
|
//executor.add_node(target_follower);
|
||||||
|
//executor.spin();
|
||||||
|
|
||||||
|
//rclcpp::shutdown();
|
||||||
|
//return EXIT_SUCCESS;
|
||||||
|
(void) argc;
|
||||||
|
(void) argv;
|
||||||
|
|
||||||
|
printf("hello world\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user