Skip to content

Commit

Permalink
Rebuilt the extender for more range
Browse files Browse the repository at this point in the history
Kind of -- running into binding issues due to weight distribution.
  • Loading branch information
EAGrahamJr committed Nov 12, 2023
1 parent e5417a0 commit 3872bfa
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 67 deletions.
6 changes: 1 addition & 5 deletions armthing/src/main/kotlin/crackers/kobots/app/Thingie.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package crackers.kobots.app

import crackers.kobots.app.AppCommon.REMOTE_PI
import crackers.kobots.app.AppCommon.executor
import crackers.kobots.app.arm.ArmMonitor
import crackers.kobots.app.arm.ManualController
Expand All @@ -39,8 +40,6 @@ var manualMode: Boolean

private val logger = LoggerFactory.getLogger("BRAINZ")

const val REMOTE_PI = "diozero.remote.hostname"

/**
* Run this.
*/
Expand All @@ -60,9 +59,6 @@ fun main(args: Array<String>? = null) {
DieAufseherin.start()
RosetteStatus.start()

// start alive-check
AppCommon.mqttClient.startAliveCheck()

AppCommon.awaitTermination()
logger.warn("Exiting")
// always "home" the Arm
Expand Down
23 changes: 10 additions & 13 deletions armthing/src/main/kotlin/crackers/kobots/app/arm/TheArm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package crackers.kobots.app.arm

import com.diozero.api.ServoTrim
import crackers.kobots.app.AppCommon
import crackers.kobots.app.AppCommon.SLEEP_TOPIC
import crackers.kobots.app.AppCommon.runFlag
import crackers.kobots.app.crickitHat
import crackers.kobots.app.execution.armSleep
import crackers.kobots.app.execution.homeSequence
import crackers.kobots.devices.MG90S_TRIM
import crackers.kobots.devices.at
import crackers.kobots.parts.app.KobotsAction
import crackers.kobots.parts.app.KobotsSubscriber
Expand Down Expand Up @@ -68,7 +68,7 @@ object TheArm : SequenceExecutor("TheArm", AppCommon.mqttClient) {
val _OPEN = 0f
val _CLOSE = 65f

val servo = crickitHat.servo(3, ServoTrim.TOWERPRO_SG90).apply {
val servo = crickitHat.servo(3, MG90S_TRIM).apply {
this at _CLOSE
}

Expand All @@ -77,16 +77,16 @@ object TheArm : SequenceExecutor("TheArm", AppCommon.mqttClient) {
}

val extender by lazy {
val _IN = 180f
val _OUT = 0f
val servo = crickitHat.servo(1, ServoTrim.TOWERPRO_SG90).apply {
val _IN = 0f
val _OUT = 90f
val servo = crickitHat.servo(1, MG90S_TRIM).apply {
this at _IN
}
ServoLinearActuator(servo, _IN, _OUT)
}

val elbow by lazy {
val servo2 = crickitHat.servo(2, ServoTrim.TOWERPRO_SG90).apply {
val servo2 = crickitHat.servo(2, MG90S_TRIM).apply {
this at 0
}
val physicalRange = IntRange(ELBOW_DOWN, ELBOW_UP)
Expand All @@ -95,13 +95,10 @@ object TheArm : SequenceExecutor("TheArm", AppCommon.mqttClient) {
}

val waist by lazy {
val _HOME = 0
val _MAX = 180

val servoRange = IntRange(_HOME, _MAX)
val physicalRange = IntRange(0, 140) // MG90S servo trim
val servo = crickitHat.servo(4, ServoTrim(1500, 1100)).apply {
this at _HOME
val servoRange = IntRange(0, 180)
val physicalRange = IntRange(0, 140)
val servo = crickitHat.servo(4, MG90S_TRIM).apply {
this at 0
}
ServoRotator(servo, physicalRange, servoRange)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import crackers.kobots.app.execution.PickUpAndMoveStuff.moveEyeDropsToDropZone
import crackers.kobots.app.execution.excuseMe
import crackers.kobots.app.execution.homeSequence
import crackers.kobots.app.execution.sayHi
import crackers.kobots.devices.sensors.VCNL4040
import crackers.kobots.mqtt.KobotsMQTT.Companion.KOBOTS_EVENTS
import crackers.kobots.parts.app.publishToTopic
import crackers.kobots.parts.enumValue
Expand Down Expand Up @@ -57,33 +56,8 @@ object DieAufseherin {
// AppCommon.executor.scheduleAtFixedRate(5.seconds, 100.milliseconds, ::youHaveOneJob)
}

const val CLOSE_ENOUGH = 15 // this is **approximately** 25mm
const val PROXIMITY_TOPIC = "Prox.TooClose"

private val sensor by lazy {
VCNL4040().apply {
proximityEnabled = true
ambientLightEnabled = true
}
}
private var wasTriggered = false
private fun youHaveOneJob() {
try {
val prox = sensor.proximity
wasTriggered = if (prox > CLOSE_ENOUGH) {
if (!wasTriggered) {
logger.info("Proximity sensor triggered: $prox")
// publishToTopic(PROXIMITY_TOPIC, prox)
}
true
} else false

} catch (e: Exception) {
logger.error("Proximity sensor error: ${e.message}")
}
}

private fun mqttStuff() = with(AppCommon.mqttClient) {
startAliveCheck()
allowEmergencyStop()

subscribeJSON("homebody/bedroom/casey") { payload ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ package crackers.kobots.app.enviro
import crackers.kobots.app.AppCommon
import crackers.kobots.app.AppCommon.SLEEP_TOPIC
import crackers.kobots.app.AppCommon.whileRunning
import crackers.kobots.app.execution.*
import crackers.kobots.app.execution.MoveStuffAround.Companion.ROTO_PICKUP
import crackers.kobots.app.execution.MoveStuffAround.Companion.ROTO_RETURN
import crackers.kobots.app.execution.armSleep
import crackers.kobots.app.execution.excuseMe
import crackers.kobots.app.execution.homeSequence
import crackers.kobots.app.execution.sayHi
import crackers.kobots.devices.display.HT16K33
import crackers.kobots.devices.display.QwiicAlphanumericDisplay
import crackers.kobots.parts.app.KobotSleep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,8 @@ import crackers.kobots.app.arm.TheArm.waist
import crackers.kobots.parts.movement.sequence

/**
* Picks up stuff from the places and returns it.
* Defines how to pick something up from a place and put it somewhere else, with the reverse also available.
*/
object PickUpAndMoveStuff {
private val dropMover = MoveStuffAround(
closeOnItem = 93,
extenderToPickupTarget = 85,
elbowForPickupTarget = 15,
dropOffElbow = 10,
dropOffExtender = 15
)
val moveEyeDropsToDropZone = dropMover.moveObjectToTarget()
val returnDropsToStorage = dropMover.pickupAndReturn()
}

/**
* Magic things for transporting stuff.
*/
const val MAGIC_EXTENDER = 15
const val ROTO_PICKUP = "LocationPickup"
const val ROTO_RETURN = "ReturnPickup"

class MoveStuffAround(
val closeOnItem: Int = 90, // how much to close the gripper to grab the item - this stresses the technic a bit

Expand Down Expand Up @@ -130,4 +111,10 @@ class MoveStuffAround(
}
this += returnToPickupLocation
}

companion object {
const val MAGIC_EXTENDER = 15
const val ROTO_PICKUP = "LocationPickup"
const val ROTO_RETURN = "ReturnPickup"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,19 @@ import crackers.kobots.parts.movement.ActionSpeed
import crackers.kobots.parts.movement.sequence

/**
* Home the arm.
* Picks up stuff from the places and returns it.
*/
object PickUpAndMoveStuff {
val dropMover = MoveStuffAround(
closeOnItem = 93,
extenderToPickupTarget = 80,
elbowForPickupTarget = 10,
dropOffElbow = 0,
dropOffExtender = 15
)
val moveEyeDropsToDropZone = dropMover.moveObjectToTarget()
val returnDropsToStorage = dropMover.pickupAndReturn()
}

/**
* Wave hello kinda.
Expand Down Expand Up @@ -61,6 +72,9 @@ val sayHi by lazy {
}
}

/**
* Get attention
*/
val excuseMe by lazy {
sequence {
name = "Excuse Me"
Expand All @@ -83,6 +97,9 @@ val excuseMe by lazy {
}
}

/**
* Kinda sorta sleepy
*/
val armSleep by lazy {
sequence {
name = "Go To Sleep"
Expand All @@ -99,6 +116,9 @@ val armSleep by lazy {
}
}

/**
* Send it home
*/
val homeSequence by lazy {
sequence {
name = "Home"
Expand Down

0 comments on commit 3872bfa

Please sign in to comment.