Skip to content

Commit

Permalink
Merge pull request mirte-robot#3 from ArendJan/martinmain
Browse files Browse the repository at this point in the history
select set encoder function based on type
  • Loading branch information
ArendJan authored Jun 1, 2023
2 parents 7cd4409 + 1e0274e commit 9f74836
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions mirte_telemetrix/config/mirte_user_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ device:
mirte:
type: breadboard
mcu: pico
max_frequency: 100
max_frequency: 10
distance:
left:
name: left
device: mirte
pins:
trigger: 7
echo: 6
motor:
encoder:
left:
name: left
device: mirte
Expand Down
8 changes: 7 additions & 1 deletion mirte_telemetrix/scripts/ROS_telemetrix_aio_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import signal
import aiorospy
import io
from inspect import signature


# Import the right Telemetrix AIO
devices = rospy.get_param('/mirte/device')
Expand Down Expand Up @@ -336,6 +338,7 @@ def get_data(self, req):
return GetDistanceResponse(self.last_publish_value.range)

async def start(self):
await self.board.set_scan_delay(100)
await self.board.set_pin_mode_sonar(self.pins["trigger"], self.pins["echo"], self.publish_data)

async def publish_data(self, data):
Expand Down Expand Up @@ -407,7 +410,10 @@ def get_data(self, req):
return GetEncoderResponse(self.last_publish_value.value)

async def start(self):
await self.board.set_pin_mode_encoder(self.pins["pin"], 2, self.ticks_per_wheel, self.publish_data)
if("encoder_pin" in signature(self.board.set_pin_mode_encoder).parameters):
await self.board.set_pin_mode_encoder(self.pins["pin"], 2, self.ticks_per_wheel, self.publish_data)
else:
await self.board.set_pin_mode_encoder(self.pins["pin"], 0, self.publish_data, False)
rospy.Timer(rospy.Duration(1.0/10.0), self.publish_speed_data)

def publish_speed_data(self, event=None):
Expand Down

0 comments on commit 9f74836

Please sign in to comment.